Compare commits

...

4 Commits

Author SHA1 Message Date
d0e825b329 Complete README 2022-03-13 11:55:33 +01:00
410d179a07 Add dirname to systemd-templates paths 2022-03-13 11:55:24 +01:00
213c7f3dc3 Finish install.sh 2022-03-13 11:47:57 +01:00
5d5c9033f4 Finish conf-sync.sh 2022-03-13 11:40:33 +01:00
3 changed files with 16 additions and 12 deletions

View File

@ -11,6 +11,9 @@ Version 2 implementation works roughly as follows:
* if changes are detected, it runs install script (if present).
### Files
* `conf-sync.sh`
* `conf-sync.sh` is the main script, which updates the files.
* `variables.conf.templates` contains examples variables definitions, and should be copied locally to `variables.conf`
(with any required modifications).
* `systemd-templates/` contains Systemd units templates for running the script unattended.
#### Installation
* `install.sh`
* `install.sh` script copies Systemd templates to their destination, and enables conf-sync timer.

13
conf-sync.sh Normal file → Executable file
View File

@ -2,12 +2,13 @@
source "$(dirname "$0")/variables.conf"
for dir in $sync_directory; do
git -C $dir rev-parse 2>/dev/null
if [ "$?" -ne 0 ]; then # ie. this is not a git repo
for dir in $sync_directory/*; do
git -C $dir rev-parse 2>/dev/null >/dev/null
if [ "$?" -ne 0 ]; then
echo "$dir: not a Git repo"
continue
fi
git -C $dir fetch
git -C $dir fetch 2>/dev/null >/dev/null
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git -C $dir rev-parse @)
REMOTE=$(git -C $dir rev-parse "$UPSTREAM")
@ -16,8 +17,8 @@ for dir in $sync_directory; do
echo "$dir: up-to-date"
elif [ $LOCAL = $BASE ]; then
echo "pulling $dir"
git -C pull
if []; then
git -C $dir pull 2>/dev/null >/dev/null
if [ -e $dir/install.sh ]; then
echo "Running $dir\'s install script..."
$dir/install.sh
fi

View File

@ -5,13 +5,13 @@ source "$(dirname "$0")/variables.conf"
# TODO handle non-Systemd systems
echo "Copying Systemd units to system directory..."
sudo cp systemd-templates/conf-sync.service /etc/systemd/system/
sudo cp $(dirname "$0")/systemd-templates/conf-sync.service /etc/systemd/system/
sudo sed -i -e "s/PH_USER/$(whoami)/g" /etc/systemd/system/conf-sync.service
sudo sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conf-sync.service
if $client_type == "server"; then # TODO not finished
sudo cp systemd-templates/dns-update.timer /etc/systemd/system/conf-sync.timer
if [ $client_type = "server" ]; then
sudo cp $(dirname "$0")/systemd-templates/dns-update.timer /etc/systemd/system/conf-sync.timer
else
sudo cp systemd-templates/dns-update.timer /etc/systemd/system/conf-sync.timer
sudo cp $(dirname "$0")/systemd-templates/dns-update.timer /etc/systemd/system/conf-sync.timer
fi
echo "Reloading Systemd..."