-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·41 lines (32 loc) · 1.07 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
readonly INSTALL_PATH="$( cd $( dirname $0 )/../ && pwd -P )"
source $INSTALL_PATH/lib/cli.sh
process_input() {
local user_response="$1"
local accept_msg="$2"
case $user_response in
y|Y) echo "$accept_msg" ;;
n|N) echo "Exiting..."; exit ;;
*) CLI_abort "Invalid option. Exiting." ;;
esac
}
path="${1:-/usr/local/bin}"
if ! [[ -d $path ]]; then
CLI_abort "[$path] is not a directory. Exiting."
elif ! [[ $PATH =~ $path ]]; then
echo "[$path] is not in your \$PATH."
echo "This means you won't be able to source the files without"
printf "specifying the full path to the file. Continue anyway? (y/n): "
read
process_input "$REPLY" "Continuing with installation"
fi
printf "About to install files to [$path]. Continue? (y/n): "
read
process_input "$REPLY" "Installing to [$path]."
for file in "$INSTALL_PATH"/lib/*.sh; do
if [[ -f "$path/${file##*/}" ]]; then
echo "$path/${file##*/} already exists. Skipping."
continue
fi
ln -s "$file" "$path/${file##*/}"
done