-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·91 lines (77 loc) · 1.7 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
set -e
CONFIG_DIR="configs"
DOTBOT_DIR="dotbot"
PLUGINS_DIR="plugins"
PROFILES_DIR="profiles"
DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BASEDIR
function print_usage() {
cat <<EOF
Usage: $0 {-p profile | -c config [...]}
Available profiles:
EOF
ls -1 ${PROFILES_DIR}
}
if [[ $# -eq 0 ]]
then
print_usage
exit 0
fi
cd "${BASEDIR}"
git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"
git submodule update --init --recursive "${PLUGINS_DIR}"
while [[ $# -gt 0 ]]
do
cmd="$1"
case "$cmd" in
(-h|--help)
print_usage
exit 0
;;
(-p|--profile)
shift
PROFILE=$1
shift
;;
(-c|--config)
shift
CONFIGS+=" $1"
shift
;;
(*)
print_usage
exit 0
;;
esac
done
if [[ -n ${PROFILE} ]]
then
PROFILE_FILE=${PROFILES_DIR}/${PROFILE}
if [[ ! -f ${PROFILE_FILE} ]]
then
echo "Invalid profile: ${PROFILE_FILE}"
echo
print_usage
exit 1
fi
while IFS= read -r config; do
CONFIGS+=" ${config}"
done < "${PROFILE_FILE}"
fi
plugin_opts=()
while read -r dir
do
plugin_opts+=("--plugin-dir=${PLUGINS_DIR}/${dir}")
done <<< "$(ls ${PLUGINS_DIR})"
echo -n "root password:"
read -r -s PW
export PW
for config in ${CONFIGS} "${@}"; do
echo -e "\n=== Configure $config ==="
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" --verbose -d "${CONFIG_DIR}/${config}" -c "${CONFIG_DIR}/${config}/dotbot.yaml" \
"${plugin_opts[@]}" \
"${@}"
done