refactor: update skeleton and scripts

This commit is contained in:
Strix 2023-10-18 20:58:24 +02:00
parent fad2dcf339
commit 07994c11c5
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
7 changed files with 18 additions and 24 deletions

View file

@ -19,30 +19,23 @@ fi
## MAIN
if ! [ -d "/neb" ]; then
echo "setting up ixvd/neb repo"
git clone \
--recurse-submodules \
git@git.ixvd.net:ixvd/neb \
/neb
if ! [ -f "/etc/ixvd/version" ]; then
echo "applying overlay..."
cp -r skel /
fi
if ! [ -d "/etc/ixvd/secrets" ]; then
echo "setting up ixvd/secrets"
git clone git@git.ixvd.net/ixvd/secrets /etc/ixvd/secrets
fi
if ! [ -f "/root/.ssh/authorized_keys" ]; then
echo "importing authorized_keys..."
mkdir -p /root/.ssh
cp secrets/ssh/authorized_keys /root/.ssh/authorized_keys
cp /etc/ixvd/secrets/ssh/authorized_keys /root/.ssh/authorized_keys
else
if ! grep -q "# IXVD keys" /root/.ssh/authorized_keys; then
echo "importing authorized_keys..."
cat secrets/ssh/authorized_keys >> /root/.ssh/authorized_keys
cat /etc/ixvd/secrets/ssh/authorized_keys >> /root/.ssh/authorized_keys
fi
fi
mkdir -p /etc/cron.d
cd common/cron
for cronfile in *.crontab; do
[ -f "/etc/cron.d/$cronfile" ] && continue
echo "installing $cronfile..."
cp $cronfile /etc/cron.d/$cronfile
done
cd $ORIGIN_PWD
fi

View file

@ -1,10 +1,10 @@
# /etc/cron.d/restic.crontab
# every 4 hours create a backup
0 */4 * * * root /neb/common/restic/backup.sh
0 */4 * * * root /opt/scripts/restic/backup.sh
# every day at 2 in the morning, forget old backups
0 2 * * * root /neb/common/restic/forget.sh
0 2 * * * root /opt/scripts/restic/forget.sh
# every 1st of the month at 2 in the morning, prune
50 2 1 * * root /neb/common/restic/prune.sh
50 2 1 * * root /opt/scripts/restic/prune.sh

1
skel/etc/ixvd/version Normal file
View file

@ -0,0 +1 @@
1

View file

@ -1,7 +1,7 @@
#!/bin/sh
ntfy() {
sh /opt/ixvd/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@"
sh /opt/scripts/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@"
}
ntfy -m "performing backup..."

View file

@ -1,7 +1,7 @@
#!/bin/sh
ntfy() {
sh /opt/ixvd/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@"
sh /opt/scripts/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@"
}
ntfy -m "forgetting old backups..."

View file

@ -1,7 +1,7 @@
#!/bin/sh
ntfy() {
sh /opt/ixvd/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@"
sh /opt/scripts/ntfy.sh -s "/neb/secrets/ntfy/ixvd-backups" -u "https://push.ixvd.net/ixvd-backups" "$@"
}
ntfy -m "pruning old backups..."