Assorted shell and Python scripts
1#!/usr/bin/env bash
2
3set -euxo pipefail
4
5if [ -f "${HOME}/.env_common" ]; then
6 source "${HOME}/.env_common"
7else
8 echo ".env_common not found"
9 exit 1
10fi
11
12TILDEGIT_URL="https://tildegit.org"
13TILDEGIT_CLONE_URL="git@tildegit.org:hyperreal"
14TILDEGIT_BACKUP_DIR="/naspool/tildegit-backup"
15KNOT_BACKUP_DIR="/naspool/knot-backup"
16KNOT_CLONE_URL="git@knot.moonshadow.dev:hyperreal.bsky.moonshadow.dev"
17
18curl -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
25while 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 30
34done <"${TILDEGIT_BACKUP_DIR}/repos.txt"
35
36knot_repos=(
37 "ansible-homelab"
38 "bin"
39 "dotfiles"
40 "hyperreal.coffee"
41 "justfiles"
42)
43
44for repo in "${knot_repos[@]}"; do
45 if [ -d "${KNOT_BACKUP_DIR}/${repo}" ]; then
46 cd "${KNOT_BACKUP_DIR}/${repo}"
47 git pull
48 else
49 cd "${KNOT_BACKUP_DIR}"
50 git clone "${KNOT_CLONE_URL}/${repo}"
51 fi
52 sleep 30
53done
54
55# vim: ts=4 sw=4 sts=4 ai et ft=bash