Assorted shell and Python scripts

-git_backup

-36
-36
git_backup
··· 1 - #!/usr/bin/env bash 2 - 3 - set -euxo pipefail 4 - 5 - if [ -f "${HOME}/.env_common" ]; then 6 - source "${HOME}/.env_common" 7 - else 8 - echo ".env_common not found" 9 - exit 1 10 - fi 11 - 12 - TILDEGIT_URL="https://tildegit.org" 13 - TILDEGIT_CLONE_URL="git@tildegit.org:hyperreal" 14 - TILDEGIT_BACKUP_DIR="/naspool/tildegit-backup" 15 - 16 - rm -fv "${TILDEGIT_BACKUP_DIR}/repos.txt" 17 - 18 - curl -s -k \ 19 - -u "hyperreal:${GITEA_TOKEN}" \ 20 - "${TILDEGIT_URL}/api/v1/user/repos?limit=100&page=1" | 21 - jq '.[].name | select(.!="keyoxide_proof")' | 22 - tr -d '"' | 23 - tee "${TILDEGIT_BACKUP_DIR}/repos.txt" 24 - 25 - while read -r line; do 26 - if [ -d "${TILDEGIT_BACKUP_DIR}/${line}" ]; then 27 - cd "${TILDEGIT_BACKUP_DIR}/${line}" 28 - git pull 29 - else 30 - cd "${TILDEGIT_BACKUP_DIR}" 31 - git clone "${TILDEGIT_CLONE_URL}/${line}.git" 32 - fi 33 - sleep 15 34 - done <"${TILDEGIT_BACKUP_DIR}/repos.txt" 35 - 36 - # vim: ts=4 sw=4 sts=4 ai et ft=bash