-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·46 lines (36 loc) · 1.11 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
41
42
43
44
45
46
#!/usr/bin/env bash
set -e
CONFIG_SUFFIX=".conf.yaml"
DOTBOT_DIR="dotbot"
DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROFILES_FILE="${BASEDIR}/.profiles"
cd "${BASEDIR}"
git submodule update --init --recursive "${DOTBOT_DIR}"
load_config() {
config="$1"
if [ -f "${config}" ]; then
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${config}"
else
echo "Skipping nonexistent file: ${config}"
fi
}
OS_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
if [ "$#" -gt 0 ]; then
profiles=("${@}")
elif [ -f "${PROFILES_FILE}" ]; then
# MacOS bash 3.2 doesn't have mapfile. Workaround from
# http://mywiki.wooledge.org/BashFAQ/005#Loading_lines_from_a_file_or_stream
unset profiles
while IFS= read -r; do
profiles+=("$REPLY")
done < "${PROFILES_FILE}"
[[ $REPLY ]] && profiles+=("$REPLY")
else
profiles=()
fi
for conf in default "${OS_NAME}" "${profiles[@]}" postinstall; do
echo "Applying config: ${conf}"
load_config "${conf}${CONFIG_SUFFIX}"
done
printf "%s\n" "${profiles[@]}" > "${PROFILES_FILE}"