From 0a4fccef3c0d934cc820e2720c46297414f057f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 20 Sep 2017 22:05:39 +0200 Subject: Initial commit --- multiconfig.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 multiconfig.sh (limited to 'multiconfig.sh') diff --git a/multiconfig.sh b/multiconfig.sh new file mode 100755 index 0000000..1519e48 --- /dev/null +++ b/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 -- cgit v1.2.3