Add a service sync script

This commit is contained in:
Neale Pickett 2023-12-28 11:08:58 -07:00
parent 5400171298
commit 06c27447fc
6 changed files with 42 additions and 11 deletions

View File

@ -1 +1,8 @@
These are docker-compose stacks I run on various servers. These are docker-compose stacks I run on various servers.
My [homelab](homelab/) now uses podman, invoked by runit.
I did this for two reasons:
1. My homelab now runs from a RAM disk,
and podman takes half as much space as docker.
2. docker swarm had some CPU overhead that podman doesn't have.

View File

@ -0,0 +1,3 @@
Periodically syncs the live system into my git repository.
In case anybody is ever curious about how this works.

View File

@ -0,0 +1 @@
s16384

3
homelab/service-sync/log/run Executable file
View File

@ -0,0 +1,3 @@
#! /bin/sh
svlogd -tt .

28
homelab/service-sync/run Executable file
View File

@ -0,0 +1,28 @@
#! /bin/sh
set -e
exec 2>&1
echo "=== Copying newer files"
cd /etc/service
find . \
! -path './*/supervise*' \
! -path './*/log/lock' \
! -path './*/log/current' \
! -path './*/log/@*' \
| cpio -R neale -m -p /home/neale/src/stacks/homelab
echo "=== Removing deleted files"
cd /home/neale/src/stacks/homelab
find */ \
| while read fn; do
if ! [ -e /etc/service/"$fn" ]; then
echo " - $fn"
rm -rf "$fn"
fi
done
echo "=== Waiting..."
sleep 4h

View File

@ -1,11 +0,0 @@
#! /bin/sh
service=/host/etc/service
if ! [ -d $service ]; then
echo "=== $service is not a directory" 1>&2
exit 1
fi
rsync -vaxp --delete \
--exclude=supervise/ \
$service/* .