refactot encrytion- and decryption scripts.

This commit is contained in:
2026-08-03 15:43:39 +02:00
parent a318e1258c
commit 55f9a6f5b8
8 changed files with 476 additions and 111 deletions
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
echoerr() { echo "$@" 1>&2; }
PWFILE="$HOME/.private/ansible/ansible-oopen-vault-passphrase"
if test ! -f "$PWFILE"
then
echoerr "File doesn't exist!"
exit 1
fi
perm=$(/bin/ls -l "$PWFILE" | awk '{print $1}')
owner=$(/bin/ls -l "$PWFILE" | awk '{print $3}')
group=$(/bin/ls -l "$PWFILE" | awk '{print $4}')
#not everyone is using debian based foo. get primary group of user and test file group permission against it
pgroup=$(id -gn)
if [[ "$perm" != "-rw-------" ]] && [[ "$perm" != "-r--------" ]]
then
echoerr "Wrong permissions!"
exit 1
fi
if test "$USER" != "$owner"
then
echoerr "Wrong owner!"
exit 1
fi
if test "$pgroup" != "$group"
then
echoerr "Wrong group!"
exit 1
fi
cat "$PWFILE"
exit 0