#!/usr/bin/env bash PASS="$(ls "/run/media/"*/*"/key.fsojp.aes256" | head -n 1)" PUBKEY=1KwpZECcrGWnM3AFVSbv3Xr5qguV4yG2sV 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=for-slow-organization-job-private fi echo "" echo "This script is expected to be kept in sync with:" echo " ${URLPFX}/get.sh" echo "" # 2. mkdir -p .git/encrypted and git init 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/ # 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 - for encpack in $(<.git/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 - done for pack in .git/objects/pack/*.pack do git index-pack "$pack" done git checkout echo DONE