shoo, update.sh and qcrypt/drive

master
Bel LaPointe 2023-04-17 11:11:06 -06:00
parent 6e040073a6
commit 3b9e50c9e6
1 changed files with 0 additions and 78 deletions

View File

@ -1,78 +0,0 @@
#! /bin/bash
set -e
gpg="gpg"
target="all"
if [[ "$#" -gt 1 ]]; then
target="$2"
fi
tarred="${target%.*}-$(date +%Y-%m-%d-%H-%M).tar"
function recursive_clean() {
d="$1"
echo "Removing pycache $(find "$d" -maxdepth 6 -name "__pycache__")"
rm -fr $(find "$d" -maxdepth 6 -name "__pycache__")
execs=$(find "$d" -maxdepth 6 -exec file {} \; | grep -i mach.o | awk '{print $1}')
for i in ${execs[@]}; do
i="${i%:*}"
echo "Removing executables $i"
rm "$i"
done
execs=$(find "$d" -maxdepth 6 -exec file {} \; | grep -i elf | awk '{print $1}')
for i in ${execs[@]}; do
i="${i%:*}"
echo "Removing executables $i"
rm "$i"
done
}
recursive_clean "$target"
function qcrypt() {
# if ends with encrypted, decrypt and expand $target.tar
if [[ "$#" -gt 0 ]]; then
if [ "${1: -3}" == "gpg" ]; then
echo "IN QCRYPT"
if [ "$(ls ./$target 2> /dev/null)" != "" ]; then
echo "Moving $target to $target-old"
rm -rf ./$target-old
mv ./$target ./$target-old
fi
echo "Decrypting $*..."
$gpg -d $* > $pulltarget.tar
echo "Expanding ./$pulltarget.tar"
tar -xf ./$pulltarget.tar
fi
# else encrypt #and commit
else
echo "Encrypting $target"
echo tar -czf ./$tarred ./$target
tar -czf ./$tarred ./$target
$gpg --encrypt -r breel@qualtrics.com -u lapoba16@wfu.edu $tarred
fi
}
if [[ "$#" -lt 1 ]]; then
echo "USAGE: bash ./update pull/push"
exit 0
fi
if [ "$1" == "pull" ]; then
echo "PULL"
pulltarget="$(drive ls | grep "$target-" | sort | tail -n 1)"
pulltarget="${pulltarget%.tar.gpg}"
pulltarget="$(basename $pulltarget)"
$GOPATH/bin/drive pull -depth 1 ./$pulltarget.tar.gpg
qcrypt ./$pulltarget.tar.gpg
fi
if [ "$1" == "push" ]; then
echo "PUSH"
qcrypt
$GOPATH/bin/drive push -depth 1 ./$tarred.gpg
fi