-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·58 lines (47 loc) · 1.54 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
#!/usr/bin/env bash
set -e
DOTBOT_DIR="dotbot"
DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${BASEDIR}"
# Migrate .envrc from previous .envrc configuration within repo
if [ -f "${BASEDIR}/base/.envrc" ] && [ ! -L "${BASEDIR}/base/.envrc" ]; then
[ -L "${HOME}/.envrc" ] && rm "${HOME}/.envrc"
mv "${BASEDIR}/base/.envrc" "${HOME}/.envrc"
fi
# Create local .envrc
if [ ! -f "${HOME}/.envrc" ]; then
cp "${BASEDIR}/base/example.envrc" "${HOME}/.envrc"
# Not linked out of this repo so it's maintained even if dotfiles are removed
# Symlinked to this repo for easy editing
ln -s "${HOME}"/.envrc "${BASEDIR}/base/.envrc"
fi
# Update dotbot submodule
(cd "${DOTBOT_DIR}" && git submodule update --init --recursive)
# If not set, add default group and assumptions for optional groups
if [ -z "$DOTFILE_GROUPS" ]; then
DOTFILE_GROUPS="base"
if [ -f "/etc/arch-release" ]; then
# is Arch
DOTFILE_GROUPS="${DOTFILE_GROUPS},archlinux"
fi
if [ xset q &>/dev/null ]; then
# is running X11
DOTFILE_GROUPS="${DOTFILE_GROUPS},x11"
fi
fi
echo "Using groups: $DOTFILE_GROUPS"
# Run dotbot on defined groups
IFS=', ' read -r -a DOTFILE_ARRAY <<< "$DOTFILE_GROUPS"
for GROUP_EL in "${DOTFILE_ARRAY[@]}"; do
if [ ! -z "$GROUP_EL" ]; then
CONFIG="$GROUP_EL.yml"
if [ -f "${BASEDIR}/${CONFIG}" ]; then
echo "Configuring ${CONFIG}"
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}"
else
echo "Cannot find ${CONFIG}"
exit 1
fi
fi
done