aboutsummaryrefslogtreecommitdiff
path: root/multiconfig.sh
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-30 13:49:11 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-30 14:11:58 +0200
commit496fad1b1059118900d8450ce400330c65116497 (patch)
treeba833dad00cbbdb2b4e5e0fd2e7ad97a3db5c8d2 /multiconfig.sh
parent315dd7ca36cd0118f5dd4a98d5321c8ac642643f (diff)
downloadmulticonfig-0.1.2.tar.gz
multiconfig-0.1.2.tar.bz2
multiconfig-0.1.2.zip
Implement firewall script and morev0.1.2
Diffstat (limited to 'multiconfig.sh')
-rwxr-xr-xmulticonfig.sh81
1 files changed, 43 insertions, 38 deletions
diff --git a/multiconfig.sh b/multiconfig.sh
index 1519e48..e85f0c0 100755
--- a/multiconfig.sh
+++ b/multiconfig.sh
@@ -1,39 +1,27 @@
#!/bin/sh
set -e
-ARGS=""
+MODS=""
LOCAL=false
-SYSLOG=false
# TODO email notifications
+# TODO version verification
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
- echo "Multiconfig system call script"
- echo "Usage: multiconfig.sh [OPTION]..."
+ echo "Multiconfig system script"
+ echo "Usage: multiconfig.sh [OPTION]... [MODULE]..."
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"
+ echo "--local - use current working directory as source for files"
exit 0
;;
- --verbose|-v|--quiet|-q)
- ARGS="$ARGS $1"
- ;;
- --operation|-o)
- ARGS="$ARGS $1 $2"
- shift
- ;;
--local)
LOCAL=true
;;
- --syslog)
- SYSLOG=true
+ *)
+ MODS="$MODS $1"
;;
esac
shift
@@ -44,30 +32,47 @@ done
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
+ if [ ! -d "/root/.multiconfig" ]; then
+ echo "No files directory. Please setup it first."
+ exit 1
fi
- cd "$PREFIX/repo"
- # Pull git repository
+ cd "/root/.multiconfig"
+ # Update git repository
git fetch
git reset --hard origin/master
git clean -xdf
+ # Verify trunk
+ # TODO gpg home?
+ #git verify-commit HEAD
fi
-# TODO check repository signature
+MODDIR="/usr/lib/multiconfig"
+# No modules given means to process all modules
+if [ -z "$MODS" ]; then
+ for M in $(find "$MODDIR" -executable); do
+ MODS="$MODS $M"
+ done
+else
+ # Go trough all given modules and check if we have such module
+ NMODS=""
+ for M in $MODS; do
+ if [ ! -x "$M" ]; then # Is not path directly to script
+ if [ ! -x "$MODDIR/$M" ]; then
+ echo "No such mode: $M"
+ exit 1
+ else
+ NMODS="$NMODS $MODDIR/$M"
+ fi
+ else
+ NMODS="$NMODS $M"
+ fi
+ done
+ MODS="$NMODS"
+fi
-CMD="./run.sh --key $PREFIX/key $ARGS"
-# Run command
-$CMD
+mkdir -p /var/log/multiconfig
+for M in $MODS; do
+ LOG="/var/log/multiconfig/$(basename "$M")"
+ "$M" | logger -s -t "multiconfig-$M" | tee "$LOG" || echo "TODO send email!"
+done