-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_profile
executable file
·55 lines (48 loc) · 1.28 KB
/
install_profile
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
#!/usr/bin/env bash
set -e
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIGDIR="${BASEDIR}/meta/config"
PROFILESDIR="${BASEDIR}/meta/profiles"
DOTBOT="${BASEDIR}/installer/dotbot/bin/dotbot"
PLUGINDIR="${BASEDIR}/installer/plugins"
# Parse arguement
declare -a ARGS
declare -a FLAGS
while (( "$#" )); do
case "$1" in
-*)
FLAGS+=("$1")
;;
*)
ARGS+=("$1")
;;
esac
shift
done
set -- "${ARGS[@]}"
# Read configs from profile
declare -a CONFIGS
while IFS= read -r config; do
if [[ -n "$config" ]]; then
CONFIGS+=("${config}")
fi
done < "${META_DIR}/${PROFILESDIR}/$1"
shift
# Load configurations
for config in "${CONFIGS[@]}" "${@}"; do
echo -e "Adding configuration $config"
CONFIGCONTENT="${CONFIGCONTENT}\n$(<"${CONFIGDIR}/${config}.yaml")"
done
# Get Plugins
declare -a PLUGINS
PLUGINS=("--plugin-dir" "${PLUGINDIR}" \
"--plugin-dir" "${PLUGINDIR}/dotbot-ifplatform" \
"--plugin-dir" "${PLUGINDIR}/dotbot-template" \
"--plugin-dir" "${PLUGINDIR}/dotbot-pip" \
"--plugin-dir" "${PLUGINDIR}/dotbot-sudo")
# Run dotbot
if [[ "${#FLAGS[@]}" -gt 0 ]]; then
"${DOTBOT}" "${FLAGS[@]}" -d "${BASEDIR}" "${PLUGINS[@]}" -c <(echo -e "${CONFIGCONTENT}")
else
"${DOTBOT}" -d "${BASEDIR}" "${PLUGINS[@]}" -c <(echo -e "${CONFIGCONTENT}")
fi