Fix merge conflict
This commit is contained in:
commit
914b5a88e4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
variables.conf
|
variables.conf
|
||||||
|
.disabled
|
||||||
|
10
README.md
10
README.md
@ -11,6 +11,12 @@ 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.template` 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.
|
||||||
|
|
||||||
|
### TODO
|
||||||
|
* Add install support for OpenBSD
|
||||||
|
17
conf-sync.sh
Normal file → Executable file
17
conf-sync.sh
Normal file → Executable file
@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
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,9 +17,9 @@ 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
|
||||||
elif [ $REMOTE = $BASE ]; then
|
elif [ $REMOTE = $BASE ]; then
|
||||||
|
79
install.sh
79
install.sh
@ -1,41 +1,56 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source "$(dirname "$0")/variables.conf"
|
run_directory=$(dirname "$0")
|
||||||
|
|
||||||
# TODO handle non-Systemd systems
|
source "$run_directory/variables.conf"
|
||||||
|
|
||||||
echo "Copying Systemd units to system directory..."
|
if [ -f $run_directory/.disabled ]; then
|
||||||
if [[ $user != 'root' ]]; then
|
echo "Installation is disabled. Exiting..."
|
||||||
sudo cp systemd-templates/conf-sync.service /etc/systemd/system/
|
exit 0
|
||||||
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 systemd-templates/conf-sync-server.timer /etc/systemd/system/conf-sync.timer
|
|
||||||
else
|
|
||||||
sudo cp systemd-templates/conf-sync-desktop.timer /etc/systemd/system/conf-sync.timer
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
cp systemd-templates/conf-sync.service /etc/systemd/system/
|
|
||||||
sed -i -e "s/PH_USER/$(whoami)/g" /etc/systemd/system/conf-sync.service
|
|
||||||
sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conf-sync.service
|
|
||||||
if $client_type == "server"; then
|
|
||||||
cp systemd-templates/conf-sync-server.timer /etc/systemd/system/conf-sync.timer
|
|
||||||
else
|
|
||||||
cp systemd-templates/conf-sync-desktop.timer /etc/systemd/system/conf-sync.timer
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Reloading Systemd..."
|
# NOTE: the handling of init/service manager comes from this discussion:
|
||||||
if [[ $user != 'root' ]]; then
|
# https://unix.stackexchange.com/questions/18209/detect-init-system-using-the-shell
|
||||||
sudo systemctl daemon-reload
|
|
||||||
|
if [ -e /run/systemd/system ]; then # service manager is Systemd
|
||||||
|
echo "Copying Systemd units to system directory..."
|
||||||
|
if [[ $user != 'root' ]]; then
|
||||||
|
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 systemd-templates/conf-sync-server.timer /etc/systemd/system/conf-sync.timer
|
||||||
|
else
|
||||||
|
sudo cp systemd-templates/conf-sync-desktop.timer /etc/systemd/system/conf-sync.timer
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cp systemd-templates/conf-sync.service /etc/systemd/system/
|
||||||
|
sed -i -e "s/PH_USER/$(whoami)/g" /etc/systemd/system/conf-sync.service
|
||||||
|
sed -i -e "s:PH_DIRECTORY:$(pwd):g" /etc/systemd/system/conf-sync.service
|
||||||
|
if $client_type == "server"; then
|
||||||
|
cp systemd-templates/conf-sync-server.timer /etc/systemd/system/conf-sync.timer
|
||||||
|
else
|
||||||
|
cp systemd-templates/conf-sync-desktop.timer /etc/systemd/system/conf-sync.timer
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Reloading Systemd..."
|
||||||
|
if [[ $user != 'root' ]]; then
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
else
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
echo "Enabling timer (not starting it, either do it manually or reboot)..."
|
||||||
|
if [[ $user != 'root' ]]; then
|
||||||
|
sudo systemctl enable conf-sync.timer
|
||||||
|
else
|
||||||
|
systemctl enable conf-sync.timer
|
||||||
|
fi
|
||||||
|
elif [ "$(uname)" = "OpenBSD" ]; then
|
||||||
|
echo "ERROR: OpenBSD is not yet supported, but this is planned."
|
||||||
|
exit 0
|
||||||
else
|
else
|
||||||
systemctl daemon-reload
|
echo "ERROR: could not determine a supported system. Exiting."
|
||||||
fi
|
exit 1
|
||||||
echo "Enabling timer (not starting it, either do it manually or reboot)..."
|
|
||||||
if [[ $user != 'root' ]]; then
|
|
||||||
sudo systemctl enable conf-sync.timer
|
|
||||||
else
|
|
||||||
systemctl enable conf-sync.timer
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Finished install. Exiting..."
|
echo "Finished install. Exiting..."
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copy this file as variables.conf, with the correct values
|
# Copy this file as variables.conf, with the correct values
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user