Files
git-sync/rootfs/usr/local/bin/git-sync.sh

48 lines
1.0 KiB
Bash

#!/bin/bash
REPO="/opt/git-sync/"
TARGET="/"
# sicherstellen dass Repo existiert
if [ ! -d "$REPO/.git" ]; then
echo "Git-Repo nicht gefunden: $REPO"
mkdir -p /opt/
cd /opt
echo "Klone Git-Repo nach /opt"
git clone http://vpnafgeissler.selfhost.co:8418/andre/git-sync.git
exit 1
fi
echo "Aktualisiere Git-Repo"
# Aktualisieren
cd "$REPO" || exit 1
git stash push -m "auto-sync"
git pull --rebase
git stash pop
echo "Verteile Dateien"
# Dateien verteilen (rootfs → /)
#sudo rsync --no-o --no-g -a rootfs/ "$TARGET"
rsync -rltpD rootfs/ "$TARGET"
echo "Setze Besitz und Berechtigungen"
chmod +x /usr/local/bin/*.sh
chown andre:andre /home/andre/
chown andre:andre /home/andre/* -R
chown andre:andre /home/andre/.* -R
chmod +x /home/andre/*.sh
chmod 600 /home/andre/.ssh/*
echo "Systemd Daemon Reload"
systemctl daemon-reload
echo "Services aktivieren"
systemctl enable git-sync.timer
systemctl enable git-sync
systemctl enable home-sync.timer
systemctl enable home-sync
echo "Fertig"
exit 0