-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun
More file actions
executable file
·37 lines (35 loc) · 1.31 KB
/
Copy pathrun
File metadata and controls
executable file
·37 lines (35 loc) · 1.31 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
#!/bin/bash
set -eu
set -o pipefail
if [ $# -eq 1 ] && [[ "$1" == "system" ]]; then
pushd "$(dirname "$0")" &>/dev/null
if [ ! -f /usr/local/bin/run-chef ]; then
echo >&2 "/usr/local/bin/run-chef not present, cannot do a system run"
exit 1
fi
hostname="$(hostname -s)"
secrets="secrets/${hostname}.json"
chefrepo_secrets="/usr/local/src/chefrepo/secrets/${hostname}.json"
sudo mkdir -p /usr/local/src/chefrepo
if [[ "$secrets" -nt "${chefrepo_secrets}" ]]; then
if ! jq -re '""' < "$secrets" &>/dev/null; then
echo >&2 "Cannot parse secrets file at $secrets"
jq < "$secrets" .
exit 5
fi
echo >&2 "Copying secrets to $chefrepo_secrets"
sudo cp "$secrets" "$chefrepo_secrets"
sudo chmod 400 "$chefrepo_secrets"
fi
set -x
if [ ! -f .Berksfile.vendored ] || [ .Berksfile.vendored -ot Berksfile.lock ]; then
cinc exec berks vendor --delete >/dev/null
touch .Berksfile.vendored
else
echo "Vendor is skipped as it's up to date"
fi
sudo rsync --verbose --delete --exclude "data" --exclude butane --exclude "boostrap" --exclude "local-mode-cache" --exclude ".git" --exclude "nodes" --exclude "secrets" --exclude "ohai/plugins" --exclude ".gnupg" --exclude ".cache" -pthrvz -q ./ /usr/local/src/chefrepo/
sudo /usr/local/bin/run-chef
else
uv run fab run "$@"
fi