-
Notifications
You must be signed in to change notification settings - Fork 0
/
.install.sh
53 lines (42 loc) · 1.12 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
#!/usr/bin/zsh
abort() {
printf "%s\n" "$@"
exit 1
}
if [ -z "${ZSH_VERSION:-}" ]; then
abort "ZShell is required in order to run this script"
fi
is_runnable() {
command -v "$@" >/dev/null 2>&1
}
if [[ "$OSTYPE" == "darwin"* ]]; then
if ! is_runnable brew; then
abort "Homebrew is required in order to run this script"
fi
fi
if ! is_runnable git; then
abort "Git is required in order to run this script"
fi
if ! is_runnable curl; then
abort "Curl is required in order to run this script"
fi
SCRIPTPATH="${0:a:h}"
config() {
git --git-dir="$HOME/.cfg/" --work-tree="$HOME" "$@"
}
if [ -z "$SKIP_PACKAGES" ]; then
echo "== Installing packages =="
if is_runnable brew; then
brew install "$(cat "$SCRIPTPATH"/.homebrew_packages)"
elif is_runnable apt-get; then
sudo apt-get install -y "$(cat "$SCRIPTPATH"/.apt-get_packages)"
else
abort "Don't know how to install packages on this platform. Aborting..."
fi
fi
echo "== Installing modules =="
for file in "$SCRIPTPATH"/.modules/*/install.sh; do
source "$file"
done
echo "== Installing submodules =="
config -C "$SCRIPTPATH" submodule update --init