Last active
June 11, 2021 22:18
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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