Repository navigation
Expand file tree
/
Copy pathprovision.sh
More file actions
executable file
·55 lines (45 loc) · 1.76 KB
/
Copy pathprovision.sh
File metadata and controls
executable file
·55 lines (45 loc) · 1.76 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
#!/usr/bin/env bash
#
# provision.sh - installs the tools the selected modules' configs assume,
# by running each module's provision.sh in role order.
#
# ./provision.sh --roles desktop # first run on a machine of that kind
# ./provision.sh # re-apply the saved selection
#
# Every module script is independently runnable and idempotent: pins are
# floors (lib/provision-lib.sh), every download is sha256-verified, and any
# failure aborts loudly. Run ./install afterwards to link the configs.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/provision-lib.sh
. "$REPO_ROOT/lib/provision-lib.sh"
# shellcheck source=lib/roles.sh
. "$REPO_ROOT/lib/roles.sh"
usage() {
cat <<EOF
usage: $0 [--roles <role>[,<role>...]] [--modules <module>[,<module>...]]
Installs the tools the selected modules' configs assume, running each
module's provision.sh in role order. With no selection, the one saved by
the last run ($ROLES_FILE) is re-applied.
--roles r[,r] roles to provision (available: $(list_roles | paste -sd' '))
--modules m[,m] extra modules, or a selection with no role
-h, --help show this help
Run ./install afterwards to link the configs.
EOF
}
require_not_root
PARSE_TARGETS_STRICT=1 parse_targets "$@"
mapfile -t MODULES < <(resolve_modules "${TARGETS[@]}")
check_requires "${MODULES[@]}"
init_provision_log "$REPO_ROOT/provision.log"
require_supported_platform
mkdir -p "$HOME/.local/bin" "$HOME/.local/share"
log "Provisioning started: ${MODULES[*]}"
for m in "${MODULES[@]}"; do
script="$REPO_ROOT/modules/$m/provision.sh"
[ -x "$script" ] || continue
log "module $m"
"$script"
done
save_targets "${TARGETS[@]}"
log "Provisioning complete. Run ./install to link the configs."