-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·47 lines (37 loc) · 1.33 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
#!/bin/bash
set -e
# Config
BASE_CONFIG="base"
CONFIG_SUFFIX=".yaml"
META_DIR="meta"
CONFIG_DIR="configs"
PROFILES_DIR="profiles"
DOTBOT_DIR=".dotbot"
DOTBOT_BIN="bin/dotbot"
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${BASE_DIR}"
# Without dos2unix, this script won't work on WSL
if command -v dos2unix &> /dev/null ; then dos2unix "${META_DIR}/${PROFILES_DIR}/$1" ; fi
while IFS= read -r config; do
CONFIGS+=" ${config}"
done <"${META_DIR}/${PROFILES_DIR}/$1"
# Remove profile (e.g. "linux") from being selected as a config
shift
for config in ${CONFIGS} ${@}; do
echo -e "\nConfigure $config"
IFS=':' read -r -a CONFIG_PLUGINS <<< "$config"
PLUGINS=""
if [ ${#CONFIG_PLUGINS[@]} -gt 1 ]; then
config=${CONFIG_PLUGINS[0]}
CONFIG_PLUGINS=("${CONFIG_PLUGINS[@]:1}")
for plugin in "${CONFIG_PLUGINS[@]}"; do
PLUGINS="${PLUGINS} --plugin-dir ./$plugin"
done
fi
echo " Plugins for $config: ${PLUGINS}"
configFile="$(mktemp)"
if command -v dos2unix &> /dev/null ; then dos2unix $configFile ; fi
echo -e "$(<"${BASE_DIR}/${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}")\n$(<"${BASE_DIR}/${META_DIR}/${CONFIG_DIR}/${config}${CONFIG_SUFFIX}")" >"$configFile"
"${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" ${PLUGINS} -c "$configFile"
rm -f "$configFile"
done