Skip to content

Instantly share code, notes, and snippets.

@CodeArtha
Last active June 11, 2021 22:18
Show Gist options
  • Save CodeArtha/a77caaff4bd6d054acf6265c163e2cdb to your computer and use it in GitHub Desktop.
Save CodeArtha/a77caaff4bd6d054acf6265c163e2cdb to your computer and use it in GitHub Desktop.
Script to pull latest version of a repo and decrypt any files containing sensitive information for ease of use locally.
#!/bin/dash
echo "[INFO] Updating repository to latest version..."
git pull
echo "[INFO] Deobfuscating password files..."
find . -type f -name "*.pass.asc" | gpg --yes --decrypt-files
# Gets the number of files in the current directory + subdirectories that have a certain extension.
ASC=`find . -type f -name "*.asc" | wc -l`
PASS=`find . -type f -name "*.pass" | wc -l`
# checking that all the encrypted files yielded an unencrypted one before deleting encrypted version.
if [ "$ASC" = "$PASS" ]; then
echo "[INFO] Password files decrypted correctly"
# Deleting files after decryption
echo "[INFO] Cleaning up..."
find . -type f -name "*.asc" -exec shred -u {} \ ;
else
echo "[ERROR] Not all files decrypted, something went wrong."
echo "[INFO] Check files manually. Aborting..."
fi
echo "[INFO] Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment