Compare commits

..

No commits in common. "d0e825b329d7950b0b30ff99106e8ae42a99f2a8" and "1b7aa49227192eb8520b7564c02fcf71feb4e0a8" have entirely different histories.

3 changed files with 12 additions and 16 deletions

View File

@ -11,9 +11,6 @@ Version 2 implementation works roughly as follows:
* if changes are detected, it runs install script (if present). * if changes are detected, it runs install script (if present).
### Files ### Files
* `conf-sync.sh` is the main script, which updates the files. * `conf-sync.sh`
* `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 #### Installation
* `install.sh` script copies Systemd templates to their destination, and enables conf-sync timer. * `install.sh`

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

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

View File

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