This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·97 lines (77 loc) · 2.17 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -e
# ---------------
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
META_DIR="${BASE_DIR}/meta"
# ---------------
QUIET=false
VERBOSE=0
while getopts :hqv opt 2>/dev/null; do
case $opt in
h)
show_help
exit
;;
q)
QUIET=true
;;
v)
VERBOSE=1
;;
:)
echo "Missing argument for option -$OPTARG"
exit 1
;;
?)
echo "Unknown option -$OPTARG"
exit 1
;;
esac
done
[ $QUIET ] && echo -e "quiet mode on"
[ $VERBOSE ] && echo -e "verbose mode on"
BIN_DOTBOT="${BASE_DIR}/modules/dotbot/bin/dotbot $([ $QUIET ] && echo "-q") $([ $VERBOSE ] && echo "-v") -d ${BASE_DIR}"
BIN_OSDETECT="${BASE_DIR}/bin/osdetection"
# ---------------
. "$BIN_OSDETECT"
# detect user defined dotfiles profile
if [ -z "${1+x}" ]; then
if [ -f ~/.dotfiles.use_profile ]; then
PROFILE_NAME=$(cat ~/.dotfiles.use_profile)
else
PROFILE_NAME="workstation"
$QUIET && echo "${PROFILE_NAME}" >~/.dotfiles.use_profile
fi
else
PROFILE_NAME="$1"
$QUIET && echo "${PROFILE_NAME}" >~/.dotfiles.use_profile
shift
fi
$QUIET && echo -e "=========\nConfigure profile ${PROFILE_NAME} for os ${OS_SHORT}\n"
$QUIET && echo -e " - os-base: ${OS_BASE}"
$QUIET && echo -e " - os: ${OS_SHORT}"
systemRoles=(
"${OS_BASE}"
"${OS_BASE}_${OS_SHORT}"
)
if [ "$OS_IS_WSL" = "wsl" ]; then
systemRoles+=("${OS_BASE}_${OS_SHORT}_wsl")
$QUIET || echo -e " - subsystem: ${OS_IS_WSL}"
fi
echo -e "\n=========\n"
# ---------------
cd "${BASE_DIR}"
git submodule update --init --recursive --remote
bash -c "${BIN_DOTBOT} -c ${META_DIR}/main.yml"
for systemRole in "${systemRoles[@]}"; do
bash -c "${BIN_DOTBOT} -c ${META_DIR}/${systemRole}/main.yml"
profile="${META_DIR}/${systemRole}/profiles/${PROFILE_NAME}"
if [ -f "${profile}" ]; then
while IFS= read -r pack; do
if [[ $pack != *"#"* ]]; then
$QUIET || echo -e "\nConfigure pack ${pack} for ${systemRole}"
bash -c "${BIN_DOTBOT} -c ${BASE_DIR}/packs/${pack}/main.yml"
fi
done <"${profile}"
fi
done