-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-profile
executable file
·55 lines (42 loc) · 1.61 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
# Update custom-dirs
xdg-user-dirs-update
# Root dir of dotfiles repo (where this script is located)
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
META_DIR="meta"
# Folders for multiprofile/multiconfig scenarios
CONFIG_DIR="${META_DIR}/configs"
PROFILES_DIR="${META_DIR}/profiles"
# Dotbot location for multiprofile/multiconfig scenarios
DOTBOT_DIR="${META_DIR}/dotbot"
DOTBOT_BIN="${DOTBOT_DIR}/bin/dotbot"
# Base config name, started first before processing other configs if some
BASE_CONFIG="base"
# Config suffix (can be json or yaml)
CONFIG_SUFFIX=".yaml"
# Settings for plugins if some (can handle up to 1 subfolder, if you like submodules as I do)
PLUGINS_ROOT_DIR="${META_DIR}/dotbot_plugins"
PLUGIN_DIRS=$(find "$BASE_DIR/$PLUGINS_ROOT_DIR" -maxdepth 1 -type d | paste -d,)
PLUGINS_COMMAND=""
if [[ $PLUGIN_DIRS ]]; then
for PLUGIN_DIR in $PLUGIN_DIRS; do
PLUGINS_COMMAND="$PLUGINS_COMMAND --plugin-dir ${PLUGIN_DIR}"
done
fi
# Collect configs for the given profile
while IFS= read -r config; do
CONFIGS+=" ${config}"
done < "${PROFILES_DIR}/$1"
shift
# Setup
cd "${BASE_DIR}"
# Uncomment if not using base config
# git submodule update --init --recursive --remote
# Run Dotbot with base config before all
"${BASE_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "${META_DIR}/${BASE_CONFIG}${CONFIG_SUFFIX}" $PLUGINS_COMMAND
# Do some magic (run Dotbot for all configs collected for the given profile)
for config in ${CONFIGS} ${@}; do
echo -e "\nConfigure $config"
"${BASE_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "${CONFIG_DIR}/${config}${CONFIG_SUFFIX}" $PLUGINS_COMMAND
done