From d2f1d006905b5d7c4bdf9255ae050330a6a7fbaa Mon Sep 17 00:00:00 2001 From: olpc user Date: Tue, 7 Jan 2020 17:16:17 -0800 Subject: bugfix attempts --- git-maintenance/get.sh | 20 +++++++++++--------- git-maintenance/store.sh | 13 ++++++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/git-maintenance/get.sh b/git-maintenance/get.sh index 12b8470..a655762 100755 --- a/git-maintenance/get.sh +++ b/git-maintenance/get.sh @@ -27,27 +27,29 @@ mkdir -p "$REPONAME" cd "$REPONAME" if ! [ -d ".git" ]; then git init; fi -# prevent recreation of existing data git config gc.auto 0 -mkdir -p .git/encrypted -mkdir -p .git/objects/pack.bak -mv -f .git/objects/pack/* .git/objects/pack.bak/ +pushd .git +# prevent recreation of existing data +mkdir -p encrypted +mkdir -p objects/pack.bak +mv -f objects/pack/* objects/pack.bak/ # 3. download .git/encrypted with wget -curl -sfI "$URLPFX"/refs.aes>/dev/null && wget "$URLPFX"/refs.aes -O .git/encrypted/refs.aes || echo "==== BROKEN REMOTE refs.aes PLEASE RE-STORE OR RECOVER ====" -openssl aes-256-cbc -salt -pbkdf2 -pass "file:$PASS" -d -in .git/encrypted/refs.aes | tar -zxvf - +curl -sfI "$URLPFX"/refs.aes>/dev/null && wget "$URLPFX"/refs.aes -O encrypted/refs.aes || echo "==== BROKEN REMOTE refs.aes PLEASE RE-STORE OR RECOVER ====" +openssl aes-256-cbc -salt -pbkdf2 -pass "file:$PASS" -d -in encrypted/refs.aes | tar -zxvf - -for encpack in $(<.git/encrypted/list.txt) +for encpack in $( "$tmpfile" openssl aes-256-cbc -salt -pbkdf2 -pass "file:$PASS" -e -in "$tmpfile" -out "$tmpfile".aes fn="$({ cat "$tmpfile"; echo -n "$PASS"; } | sha256sum | cut -f 1 -d ' ')".aes + if [ -e encrypted/"$fn" ] + then + echo "$fn ALREADY EXISTS LOCALLY ($packfile)" + else + echo "$fn IS NEW LOCALLY ($packfile)" + fi mv "$tmpfile".aes encrypted/"$fn" - if [ "$(curl "$URLPFX"/"$fn" | sha256sum)" = "$(cat encrypted/"$fn" | sha256sum)" ]; then mv -v encrypted/"$fn" encrypted.bak; fi + if [ "$(curl "$URLPFX"/"$fn" | sha256sum)" = "$(cat encrypted/"$fn" | sha256sum)" ]; then + echo "$fn ALREADY EXISTS REMOTELY ($packfile)" + mv -v encrypted/"$fn" encrypted.bak + else + echo "$fn FAILED GET MATCH REMOTELY ($packfile)" + fi echo "$fn" >> "$tmpfile".list done rm "$tmpfile" -- cgit v1.2.3