diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2020-01-08 20:18:46 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2020-01-08 20:18:46 -0800 |
commit | ba3ab9c0bdf6c069d1da927f7a0eab82bf02c918 (patch) | |
tree | aa77d2cc49ef7359247094feb1d2fbb8119dbb15 /git-maintenance/dog.sh | |
parent | c6de0352d5798c839bea5f66e43e9663bd9028b2 (diff) | |
download | standingwithresilience-ba3ab9c0bdf6c069d1da927f7a0eab82bf02c918.tar.gz standingwithresilience-ba3ab9c0bdf6c069d1da927f7a0eab82bf02c918.zip |
password is cat
Diffstat (limited to 'git-maintenance/dog.sh')
-rwxr-xr-x | git-maintenance/dog.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/git-maintenance/dog.sh b/git-maintenance/dog.sh new file mode 100755 index 0000000..757fcc4 --- /dev/null +++ b/git-maintenance/dog.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +#PASS="file:$(ls "/run/media/"*/*"/key.fsojp.aes256" | head -n 1)" +echo +echo == Enter password. == +echo +PASS="pass:$(echo 53616c7465645f5f6eb8e165b79052263e125e4070138e26b3d127bb36e3e943f212d2d761a4426170cc2c17c58bc5d67c99eddb1df6ee1c02d7b33dd95ecdf0 | xxd -ps -r | openssl aes-256-cbc -salt -pbkdf2 -d)" +PUBKEY=1KwpZECcrGWnM3AFVSbv3Xr5qguV4yG2sV +NONCE="$(date +%s)" + +if ! curl -sfI "https://bico.media/">/dev/null; then echo; echo "== Remember to get on internet. =="; echo; exit 2; fi + +#if [ "$PASS" = "pass:" ]; then echo "Need better password."; exit 1; fi + + +URLPFX="https://bico.media/$PUBKEY" +if [ "$1" != "" ] +then + REPONAME="$1" +fi +if [ "$REPONAME" = "" ] +then + REPONAME="$(git rev-parse --show-toplevel 2>/dev/null)" +fi +if [ "$REPONAME" = "" ] +then + REPONAME=dog +fi + +echo "" +echo "This script is expected to be kept in sync with:" +echo " ${URLPFX}/dog.sh" +echo "" + +# 2. mkdir -p .git/encrypted and git init +mkdir -p "$REPONAME" +cd "$REPONAME" +if ! [ -d ".git" ]; then git init; fi + +git config gc.auto 0 + +pushd .git +# prevent recreation of existing data +mkdir -p encrypted +mkdir -p bak +cp -va HEAD refs objects/pack bak +rm objects/pack/* + +# 3. download .git/encrypted with wget +curl -sfI "$URLPFX"/refs.aes?"$NONCE">/dev/null && wget "$URLPFX"/refs.aes?"$NONCE" -O encrypted/refs.aes || echo "==== BROKEN REMOTE refs.aes PLEASE RE-STORE OR RECOVER ====" +openssl aes-256-cbc -salt -pbkdf2 -pass "$PASS" -d -in encrypted/refs.aes | tar -Jxvf - + +for encpack in $(<encrypted/list.txt) +do + while ! curl -sfI "$URLPFX"/"$encpack"?"$NONCE" + do + sleep 1; + NONCE="$(date +%s)" + done + wget "$URLPFX"/"$encpack"?"$NONCE" -O encrypted/"$encpack" + openssl aes-256-cbc -salt -pbkdf2 -pass "$PASS" -d -in encrypted/"$encpack" | tar -Jxvf - +done + +for pack in objects/pack/*.pack +do + git index-pack "$pack" +done +popd + +git checkout + +echo DONE |