Files
schul-laptops/files/schul-pull.sh
Herb 22bb3ccec9 Pull-Mechanik: local.yml, schul-pull.sh, systemd-Units
Laptops ziehen sich das Repo selbst (HTTPS via git.lehrstun.de,
SSH-Fallback mit Deploy-Key) und fuehren local.yml aus. Timer laeuft
bei Boot + alle 30 min. local.yml haelt die Mechanik selbst aktuell.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 13:17:14 +02:00

25 lines
727 B
Bash

#!/bin/bash
#
# Zieht das schul-laptops-Repo und fuehrt local.yml aus.
# HTTPS zuerst (funktioniert auch im Schulnetz), SSH mit Deploy-Key als Fallback.
# Wird vom systemd-Timer (ansible-pull.timer) als root aufgerufen.
#
set -u
HTTPS_URL="https://git.lehrstun.de/admin/schul-laptops.git"
SSH_URL="ssh://git@46.225.114.15:2222/admin/schul-laptops.git"
DEPLOY_KEY="/root/.ssh/ansible-pull-deploy"
CHECKOUT="/var/lib/schul-laptops"
run_pull() {
ansible-pull -U "$1" -d "$CHECKOUT" -c local -i localhost, local.yml
}
if run_pull "$HTTPS_URL"; then
exit 0
fi
echo "HTTPS fehlgeschlagen, versuche SSH-Fallback (Port 2222) ..." >&2
export GIT_SSH_COMMAND="ssh -i $DEPLOY_KEY -p 2222 -o BatchMode=yes"
run_pull "$SSH_URL"