aboutsummaryrefslogtreecommitdiff
path: root/scripts/multiconfig.sh
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-20 21:19:05 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-20 21:22:36 +0200
commitf287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch)
tree5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /scripts/multiconfig.sh
parent65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff)
downloadmulticonfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.gz
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.bz2
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.zip
Commit current statecomplicated
Diffstat (limited to 'scripts/multiconfig.sh')
-rwxr-xr-xscripts/multiconfig.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/multiconfig.sh b/scripts/multiconfig.sh
new file mode 100755
index 0000000..1519e48
--- /dev/null
+++ b/scripts/multiconfig.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+set -e
+
+ARGS=""
+LOCAL=false
+SYSLOG=false
+
+# TODO email notifications
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -h|--help)
+ echo "Multiconfig system call script"
+ echo "Usage: multiconfig.sh [OPTION]..."
+ echo
+ echo "Options:"
+ echo "--local - Use current working directory as multiconfig source."
+ echo "--syslog - pipe output to syslog"
+ echo "Passed options:"
+ echo "--verbose - Make output more verbose"
+ echo "--quiet - Make output more quiet"
+ echo "--operation OPT - run only given operation"
+ exit 0
+ ;;
+ --verbose|-v|--quiet|-q)
+ ARGS="$ARGS $1"
+ ;;
+ --operation|-o)
+ ARGS="$ARGS $1 $2"
+ shift
+ ;;
+ --local)
+ LOCAL=true
+ ;;
+ --syslog)
+ SYSLOG=true
+ ;;
+ esac
+ shift
+done
+
+[ "$(id -u)" == 0 ] || {
+ echo "Please run this script only as root."
+ exit 1
+}
+
+PREFIX="/root/.multiconfig"
+
+# Check if we have key
+if [ ! -f "$PREFIX/key" ]; then
+ echo "Key is not in expected path. Please setup this host for multiconfig."
+ exit 1
+fi
+
+# TODO check key access rights
+
+if ! $LOCAL; then
+ if [ -d "$PREFIX/repo" ]; then
+ true
+ # TODO git clone
+ fi
+ cd "$PREFIX/repo"
+ # Pull git repository
+ git fetch
+ git reset --hard origin/master
+ git clean -xdf
+fi
+
+# TODO check repository signature
+
+CMD="./run.sh --key $PREFIX/key $ARGS"
+# Run command
+$CMD