-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall
More file actions
executable file
·76 lines (66 loc) · 1.84 KB
/
install
File metadata and controls
executable file
·76 lines (66 loc) · 1.84 KB
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
#!/usr/bin/env bash
set -e
CONFIG=".install.yaml"
DOTBOT_DIR=".dotbot"
DOTBOT_BIN="bin/dotbot"
DOTBOT_PLUGINS_DIR=".dotbot-plugins"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOTBOT_PLUGINS=(
"${DOTBOT_PLUGINS_DIR}/crontab/crontab.py"
"${DOTBOT_PLUGINS_DIR}/git/git.py"
"${DOTBOT_PLUGINS_DIR}/if/if.py"
"${DOTBOT_PLUGINS_DIR}/sudo/sudo.py"
"${DOTBOT_PLUGINS_DIR}/sync/sync.py"
)
# Get the names of available themes
cd "${BASEDIR}/themes"
themes=()
for dir in */ ; do
themes+=("$(basename ${dir})")
done
printf -v THEMES_STR '%s|' "${themes[@]}"
# Print help if requested
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "usage: install [--theme ${THEMES_STR%|}] (...dotbot OPTIONS...)"
exit 0
fi
# Loop over arguments and check for --theme flag
args=()
rflag=false
for var in "${@}" ; do
if [[ "${rflag}" == true ]] ; then
if [[ " ${themes[*]} " =~ " ${var} " ]] ; then
echo "Theme selected for install: ${var}"
THEME_NAME="${var}"
else
echo >&2 "${var} is not a valid theme! Choose one of ${THEMES_STR%|}"
exit 1
fi
rflag=false
continue
elif [[ "${var}" == "--theme" ]] ; then
rflag=true
continue
fi
args+=("${var}")
done
# dotbot setup
cd "${BASEDIR}"
git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"
# Add each plugin to the arguments
for plugin in "${DOTBOT_PLUGINS[@]}"; do
args+=(-p "$plugin")
done
# Run dotbot with the base config
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -vv \
-d "${BASEDIR}" \
-c "${CONFIG}" \
"${args[@]}"
# If a theme was selected, run dotbot again with the config within that theme's directory
if [[ "${THEME_NAME+x}" ]] ; then
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -vv \
-d "${BASEDIR}/themes/${THEME_NAME}" \
-c "themes/${THEME_NAME}/${CONFIG}" \
"${args[@]}"
fi