-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·93 lines (74 loc) · 2.21 KB
/
bootstrap
File metadata and controls
executable file
·93 lines (74 loc) · 2.21 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
set -e
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# shellcheck disable=SC1091
. lib/util.sh
# shellcheck disable=SC1091
. lib/profile.sh
function ensure_profile_includes() {
local profile
local include
profile=${1}
include=${2}
present=$(yq e "[\"${include}\"] - (.profiles.\"${profile}\".include // []) | length == 0" ../config.yaml)
if [[ ${present} == "false" ]]; then
yq eval ".profiles.\"${profile}\".\"include\" += [\"${include}\"]" -i ../config.yaml
fi
}
function list_includes() {
local profile
profile="${1}"
yq eval ".profiles.\"${profile}\".include[]" ../config.yaml
}
function set_host_ssh_key_name_if_present() {
local profile
local key_name
profile=${1}
key_name="${profile} key"
if op item get "${key_name}" >/dev/null 2>&1; then
yq eval ".profiles.\"${profile}\".variables.host_ssh_key_name = \"${key_name}\"" -i ../config.yaml
fi
}
function main() {
if ! command -v brew >/dev/null; then
echo "need sudo permission for initial Homebrew install"
util::is_mac && util::sudo_check_then_alive
profile::install_homebrew
fi
if ! command -v yq >/dev/null; then
brew install yq
fi
for action in _goenv_install _pyenv_install; do
profile::run_dotdrop_action "${action}"
done
# create a new profile (if necessary), including default & os-specific ones
PROFILE=$(hostname)
included_profiles=(default)
if util::is_mac; then
included_profiles+=(mac)
elif util::is_linux; then
included_profiles+=(linux)
elif util::is_synology_dsm; then
included_profiles+=(synology_dsm)
fi
included_profiles+=("${@}")
for named in "${included_profiles[@]}"; do
ensure_profile_includes "${PROFILE}" "${named}"
done
for named in $(list_includes "${PROFILE}"); do
if command -v "profile::${named}"; then
"profile::${named}"
fi
done
eval "$(op signin)"
set_host_ssh_key_name_if_present "${PROFILE}"
# Install all dotfiles into the home directory
dotdrop install --force --profile="${PROFILE}" --cfg ../config.yaml
for named in $(list_includes "${PROFILE}"); do
if command -v "profile::${named}_after"; then
"profile::${named}_after"
fi
done
profile::finalize
}
main "${@}"