From 863ab4c3c3cc924d52939b4c75b536d61130b48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Thu, 24 Jul 2025 13:07:41 +0300 Subject: [PATCH] Add Protect script --- protect.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 protect.sh diff --git a/protect.sh b/protect.sh new file mode 100755 index 0000000..4a22573 --- /dev/null +++ b/protect.sh @@ -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