-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_setting.sh
executable file
·31 lines (26 loc) · 960 Bytes
/
set_setting.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
#!/bin/bash
# Decrypt vault
make decrypt
echo "Finding key: $1"
echo "New setting: $2"
# Try to figure out where key is defined
FILE=settings/config.yml
SETTING_VALUE=$(sudo docker run --rm -v ${PWD}:/workdir:Z mikefarah/yq:3 yq r "$FILE" "$1" "$2")
if [ -z "${SETTING_VALUE}" ]; then
FILE=settings/vault.yml
SETTING_VALUE=$(sudo docker run --rm -v ${PWD}:/workdir:Z mikefarah/yq:3 yq r "$FILE" "$1" "$2")
if [ -z "${SETTING_VALUE}" ]; then
echo "Key does not exist in config.yml nor vault.yml."
# Re-encrypt vault
make encrypt
exit 1
fi
fi
echo "Found value in file: $FILE"
echo "Old setting value: " ${SETTING_VALUE}
# Setting the new value
sudo docker run --rm -v ${PWD}:/workdir:Z mikefarah/yq:3 yq w -i "$FILE" "$1" "$2"
NEW_SETTING_VALUE=$(sudo docker run --rm -v ${PWD}:/workdir:Z mikefarah/yq:3 yq r "$FILE" "$1" "$2")
echo "New setting value: " ${NEW_SETTING_VALUE}
# Re-encrypt vault
make encrypt