-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·50 lines (42 loc) · 1.43 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
#!/bin/bash
set -euo pipefail
SRC_DIR="$(dirname "$0")"
USAGE=$(cat <<-END
Usage: ./install.sh [OPTION]
Install dotfile dependencies on mac or linux
If OPTIONS are passed they will be installed
with apt if on linux or brew if on OSX
OPTIONS:
--force force reinstall the zsh and tmux plugins
--no-root install without root permissions
END
)
# parse args
FORCE=false
NO_ROOT=false
while (( "$#" )); do
case "$1" in
-h|--help)
echo "$USAGE" && exit 1 ;;
-f|--force)
FORCE=true && shift ;;
--no-root)
NO_ROOT=true && shift ;;
--) # end argument parsing
shift && break ;;
-*|--*=) # unsupported flags
echo "Error: Unsupported flag $1" >&2 && exit 1 ;;
esac
done
cd "$(dirname $0)"
# Source all the env files in case thy set variables needed by the installers
for file in $SRC_DIR/**/*env.zsh; do . $file; done
if [[ $NO_ROOT == "true" ]]; then
# find the no root installers and run them iteratively
find . -name install_no_root.sh -mindepth 2 | while read installer ; do "${installer}" ; done
else
# find the installers and run them iteratively, pass args recieved
find . -name install_first.sh | while read installer ; do "${installer}" ; done
# find the installers and run them iteratively
find . -name install.sh -mindepth 2 | while read installer ; do "${installer}" $([ $FORCE = true ] && echo --force) ; done
fi