#!/bin/sh set -e MODS="" LOCAL=false # TODO email notifications # TODO version verification while [ $# -gt 0 ]; do case "$1" in -h|--help) echo "Multiconfig system script" echo "Usage: multiconfig.sh [OPTION]... [MODULE]..." echo echo "Options:" echo "--local - use current working directory as source for files" exit 0 ;; --local) LOCAL=true ;; *) MODS="$MODS $1" ;; esac shift done [ "$(id -u)" == 0 ] || { echo "Please run this script only as root." exit 1 } if ! $LOCAL; then if [ ! -d "/root/.multiconfig" ]; then echo "No files directory. Please setup it first." exit 1 fi 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 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 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