Compare commits
No commits in common. "d0e825b329d7950b0b30ff99106e8ae42a99f2a8" and "1b7aa49227192eb8520b7564c02fcf71feb4e0a8" have entirely different histories.
d0e825b329
...
1b7aa49227
@ -11,9 +11,6 @@ Version 2 implementation works roughly as follows:
|
||||
* if changes are detected, it runs install script (if present).
|
||||
|
||||
### Files
|
||||
* `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.
|
||||
* `conf-sync.sh`
|
||||
#### 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
13
conf-sync.sh
Executable file → Normal file
@ -2,13 +2,12 @@
|
||||
|
||||
source "$(dirname "$0")/variables.conf"
|
||||
|
||||
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"
|
||||
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
|
||||
continue
|
||||
fi
|
||||
git -C $dir fetch 2>/dev/null >/dev/null
|
||||
git -C $dir fetch
|
||||
UPSTREAM=${1:-'@{u}'}
|
||||
LOCAL=$(git -C $dir rev-parse @)
|
||||
REMOTE=$(git -C $dir rev-parse "$UPSTREAM")
|
||||
@ -17,8 +16,8 @@ for dir in $sync_directory/*; do
|
||||
echo "$dir: up-to-date"
|
||||
elif [ $LOCAL = $BASE ]; then
|
||||
echo "pulling $dir"
|
||||
git -C $dir pull 2>/dev/null >/dev/null
|
||||
if [ -e $dir/install.sh ]; then
|
||||
git -C pull
|
||||
if []; then
|
||||
echo "Running $dir\'s install script..."
|
||||
$dir/install.sh
|
||||
fi
|
||||
|
@ -5,13 +5,13 @@ source "$(dirname "$0")/variables.conf"
|
||||
# TODO handle non-Systemd systems
|
||||
|
||||
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_DIRECTORY:$(pwd):g" /etc/systemd/system/conf-sync.service
|
||||
if [ $client_type = "server" ]; then
|
||||
sudo cp $(dirname "$0")/systemd-templates/dns-update.timer /etc/systemd/system/conf-sync.timer
|
||||
if $client_type == "server"; then # TODO not finished
|
||||
sudo cp systemd-templates/dns-update.timer /etc/systemd/system/conf-sync.timer
|
||||
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
|
||||
|
||||
echo "Reloading Systemd..."
|
||||
|
Loading…
Reference in New Issue
Block a user