#!/bin/sh set -e MODDIR="/usr/lib/multiconfig" 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 ;; *) if [ -x "$1" ]; then MODS="$MODS $(pwd)/$1" elif [ -x "$MODDIR/$1" ]; then MODS="$MODS $MODDIR/$1" else echo "Requested unknown mod: $1" exit 1 fi ;; 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" # Ensure that we have correct access rights on private key chmod 600 ssh_key # Update git repository git fetch git reset --hard origin/master git clean -xdf # Verify trunk # TODO gpg home? #git verify-commit HEAD fi # No modules given means to process all modules if [ -z "$MODS" ]; then for M in $(find "$MODDIR" -executable); do MODS="$MODS $MODDIR/$M" done fi [ -n "$MODS" ] || exit 0 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