-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·46 lines (44 loc) · 1008 Bytes
/
install.sh
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
41
42
43
44
45
46
#!/usr/bin/env bash
PREFIX=~/.local
FILES="bin/appenv.bash bin/appenv.fish share/appenv/api.bash share/appenv/commands.bash share/appenv/run.bash share/appenv/merge.bash"
BASE="https://raw.githubusercontent.com/sebastien/appenv/master"
METHOD="copy"
if [ "$1" = "uninstall" ]; then
for FILE in $FILES; do
FILE="$PREFIX/$FILE"
if [ -e "$FILE" ]; then
echo "Removing $FILE"
unlink "$FILE"
fi
done
exit 0
elif [ "$1" = "link" ]; then
METHOD="link"
fi
if [ ! -d $PREFIX/bin ]; then
mkdir -p $PREFIX/bin
fi
for FILE in $FILES; do
DST=$PREFIX/$FILE
DIR=$(dirname "$DST")
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR"
fi
if [ -f "$FILE" ]; then
SRC="$FILE"
if [ "$METHOD" = "link" ]; then
echo "Linking $SRC → $DST"
ln -sfr "$SRC" "$DST"
else
echo "Copying $SRC → $DST"
cp -a "$SRC" "$DST"
fi
else
SRC="$BASE/$FILE"
echo "Installing $SRC → $DST"
curl --silent "$SRC" > "$DST"
fi
done
chmod +x "$PREFIX/bin/appenv.bash"
chmod +x "$PREFIX/bin/appenv.fish"
# EOF