Compare commits
4 Commits
1b7aa49227
...
d0e825b329
Author | SHA1 | Date | |
---|---|---|---|
d0e825b329 | |||
410d179a07 | |||
213c7f3dc3 | |||
5d5c9033f4 |
@ -11,6 +11,9 @@ 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`
|
* `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
|
#### 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
13
conf-sync.sh
Normal file → Executable file
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
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
|
git -C $dir rev-parse 2>/dev/null >/dev/null
|
||||||
if [ "$?" -ne 0 ]; then # ie. this is not a git repo
|
if [ "$?" -ne 0 ]; then
|
||||||
|
echo "$dir: not a Git repo"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
git -C $dir fetch
|
git -C $dir fetch 2>/dev/null >/dev/null
|
||||||
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")
|
||||||
@ -16,8 +17,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 pull
|
git -C $dir pull 2>/dev/null >/dev/null
|
||||||
if []; then
|
if [ -e $dir/install.sh ]; then
|
||||||
echo "Running $dir\'s install script..."
|
echo "Running $dir\'s install script..."
|
||||||
$dir/install.sh
|
$dir/install.sh
|
||||||
fi
|
fi
|
||||||
|
@ -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 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_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 # TODO not finished
|
if [ $client_type = "server" ]; then
|
||||||
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
|
||||||
else
|
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
|
fi
|
||||||
|
|
||||||
echo "Reloading Systemd..."
|
echo "Reloading Systemd..."
|
||||||
|
Loading…
Reference in New Issue
Block a user