2 # Copyright (C) 2017 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
19 [[ $EUID == 0 ]] ||
exec sudo
"$BASH_SOURCE" "$@"
24 Install or uninstall files to /usr/local/bin
27 -u|--uninstall Uninstall. default is to install
28 -h|--help Print help and exit.
30 Note: Uses GNU getopt options parsing style
35 uninstall
=false
# default
36 temp
=$
(getopt
-l help,uninstall
,dry-run hun
"$@") || usage
1
40 -n|
--dry-run) dry
=true
; shift ;;
41 -u|
--uninstall) uninstall
=true
; shift ;;
44 *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
49 x
="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*} # directory of this file
53 if [[ -x $f && ! -d $f && ! -L $f && $f != setup
]]; then
60 echo "setup dry run: cd /usr/local/bin"
61 echo "setup dry run: rm -fv ${files[*]}"
68 echo "setup dry run: install ${files[*]} /usr/local/bin"
70 install -C ${files[@]} /usr
/local
/bin