mirror of
https://github.com/cwchristerw/tjas-infra
synced 2025-08-08 15:24:35 +00:00
Add Protect script
This commit is contained in:
57
protect.sh
Executable file
57
protect.sh
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
underline=`tput smul`
|
||||||
|
nounderline=`tput rmul`
|
||||||
|
bold=$(tput bold)
|
||||||
|
normal=$(tput sgr0)
|
||||||
|
|
||||||
|
echo "${bold}PVJJK 1.VOS TJAS / Infra / Protect${normal}"
|
||||||
|
action=$1
|
||||||
|
|
||||||
|
encrypt() {
|
||||||
|
echo "${underline}Encrypting...${nounderline}"
|
||||||
|
execute "ansible-vault encrypt --vault-id pvjjk-1vos-tjas@vault/pvjjk-1vos-tjas"
|
||||||
|
}
|
||||||
|
|
||||||
|
decrypt() {
|
||||||
|
echo "${underline}Decrypting...${nounderline}"
|
||||||
|
execute "ansible-vault decrypt --vault-id pvjjk-1vos-tjas@vault/pvjjk-1vos-tjas"
|
||||||
|
}
|
||||||
|
|
||||||
|
list() {
|
||||||
|
echo "${underline}Listing...${nounderline}"
|
||||||
|
i=0
|
||||||
|
for file in inventories/*/group_vars/* inventories/*/host_vars/*;
|
||||||
|
do
|
||||||
|
i=$((i + 1))
|
||||||
|
echo $i")"$file
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
execute() {
|
||||||
|
for file in inventories/*/group_vars/* inventories/*/host_vars/*;
|
||||||
|
do
|
||||||
|
i=$((i + 1))
|
||||||
|
echo $i")"$file
|
||||||
|
$1 $file
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case $action in
|
||||||
|
encrypt)
|
||||||
|
encrypt
|
||||||
|
;;
|
||||||
|
decrypt)
|
||||||
|
decrypt
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
list
|
||||||
|
;;
|
||||||
|
help)
|
||||||
|
echo "encrypt, decrypt, list"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "..."
|
||||||
|
;;
|
||||||
|
esac
|
Reference in New Issue
Block a user