-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·59 lines (54 loc) · 1.26 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
PACKAGES="emacs X zsh scripts systemd email music"
TARGET=$HOME
TRAIL=""
UNINSTALL=""
usage() {
echo "Usage:"
echo "install.sh [-n] [-t|--target target] [-D] [packages]"
echo "Options:"
echo "-n : dry-run, no action. Run as normally, but do not modify file system"
echo '-t : set target, defaults to $HOME, but can be set if you want to install somewhere else'
echo "-D : uninstall instead of installing"
echo ""
echo "Specify packages to install as final arguments, or nothing to install default packages"
echo "Default packages are: $PACKAGES"
echo ""
}
# Loop thrugh every option args
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-t|--target)
TARGET="$2"
shift
;;
-n|--dry-run)
TRAIL="-n"
;;
-D|--uninstall|--delete)
UNINSTALL="-D"
;;
-h|--help|-?)
usage
exit
;;
*)
break
;;
esac
shift
done
# Check if there are positional args left
if [ $# -gt 0 ]
then
PACKAGES=$@
shift
fi
if [ ! -x "$(command stow)" ]; then
echo "Installing packages: $PACKAGES ..."
stow $TRAIL -t $TARGET -v $UNINSTALL $PACKAGES
else
echo "GNU Stow not installed, please install stow for easy management, or symlink the files in the subdirectories manually"
fi