diff options
-rwxr-xr-x | git-maintenance/get.sh | 20 | ||||
-rwxr-xr-x | 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 $(<encrypted/list.txt) do wget "$URLPFX"/"$encpack" -O .git/encrypted/"$encpack" - openssl aes-256-cbc -salt -pbkdf2 -pass "file:$PASS" -d -in .git/encrypted/"$encpack" | tar -zxvf - -C .git + openssl aes-256-cbc -salt -pbkdf2 -pass "file:$PASS" -d -in .git/encrypted/"$encpack" | tar -zxvf - done -for pack in .git/objects/pack/*.pack +for pack in objects/pack/*.pack do git index-pack "$pack" done +popd git checkout diff --git a/git-maintenance/store.sh b/git-maintenance/store.sh index 99c71d7..1361226 100755 --- a/git-maintenance/store.sh +++ b/git-maintenance/store.sh @@ -42,8 +42,19 @@ do $TAR -cv "$packfile" > "$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" |