-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-init.sh
executable file
·37 lines (30 loc) · 1.34 KB
/
git-init.sh
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
#!/usr/bin/env bash
# sets up a pre-commit hook to ensure that vault.yaml is encrypted
#
# extended from https://github.com/IronicBadger/compose-secret-mgt/blob/master/git-init.sh
hook_path="$(git rev-parse --git-path hooks)/pre-commit"
cat <<EOT > "$hook_path"
#!/usr/bin/env bash
set -e
./vault-check.py
EOT
chmod +x "$hook_path"
declare -A remote_map=(
["roles/alertmanager"]="https://github.com/cloudalchemy/ansible-alertmanager.git"
["roles/blackbox_exporter"]="https://github.com/cloudalchemy/ansible-blackbox-exporter.git"
["roles/grafana"]="https://github.com/cloudalchemy/ansible-grafana.git"
["roles/libvirt_vm"]="https://github.com/stackhpc/ansible-role-libvirt-vm.git"
["roles/postgresql"]="https://github.com/geerlingguy/ansible-role-postgresql.git"
["roles/nginx"]="https://github.com/geerlingguy/ansible-role-nginx.git"
["roles/prometheus"]="https://github.com/cloudalchemy/ansible-prometheus.git"
["roles/wireguard"]="https://github.com/githubixx/ansible-role-wireguard.git"
)
for dir in "${!remote_map[@]}"; do
if git -C "$dir" remote show | grep -q upstream; then
echo "$dir already has upstream defined"
continue
fi
git -C "$dir" remote add upstream "${remote_map[$dir]}"
git -C "$dir" remote set-url upstream --push DISABLED
echo "$dir added ${remote_map[$dir]} as upstream"
done