Fix merge conflict
This commit is contained in:
commit
914b5a88e4
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
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).
|
||||
|
||||
### 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
|
||||
* `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"
|
||||
|
||||
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,9 +17,9 @@ for dir in $sync_directory; do
|
||||
echo "$dir: up-to-date"
|
||||
elif [ $LOCAL = $BASE ]; then
|
||||
echo "pulling $dir"
|
||||
git -C pull
|
||||
if []; then
|
||||
echo "Running $dir\'s install script..."
|
||||
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
|
||||
elif [ $REMOTE = $BASE ]; then
|
||||
|
23
install.sh
23
install.sh
@ -1,9 +1,18 @@
|
||||
#!/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"
|
||||
|
||||
if [ -f $run_directory/.disabled ]; then
|
||||
echo "Installation is disabled. Exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# NOTE: the handling of init/service manager comes from this discussion:
|
||||
# https://unix.stackexchange.com/questions/18209/detect-init-system-using-the-shell
|
||||
|
||||
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/
|
||||
@ -24,7 +33,6 @@ 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
|
||||
@ -37,6 +45,13 @@ if [[ $user != 'root' ]]; then
|
||||
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
|
||||
echo "ERROR: could not determine a supported system. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Finished install. Exiting..."
|
||||
exit 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copy this file as variables.conf, with the correct values
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user