-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun
More file actions
executable file
·32 lines (30 loc) · 1.13 KB
/
Copy pathrun
File metadata and controls
executable file
·32 lines (30 loc) · 1.13 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
#!/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
cinc exec berks vendor >/dev/null
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