#!/bin/sh set -e MODDIR="/usr/lib/multiconfig" MODS="" # TODO email notifications EXPANDED_ARGS=false for ARG in "$@"; do $EXPANDED_ARGS || { shift $# EXPANDED_ARGS=true } case "$ARG" in -h|--help) echo "Usage: multiconfig [OPTION]... [MODULE]..." echo "Multiconfig system launching script" echo echo "Options:" echo " -h, --help" echo " Print this help text." echo " -l, --list" echo " List all available mods and exit." exit 0 ;; -l|--list) cd "$MODDIR" for MOD in $(find -maxdepth 1 -executable -type f); do echo "${MOD#./}: $($MOD --description)" done exit ;; *) if [ \! -x "$ARG" ]; then echo "Requested unknown mod: $1" exit 1 fi set "$@" "$ARG" ;; esac done [ "$(id -u)" == 0 ] || { echo "Please run this script only as root." exit 1 } cd "$MODDIR" # No modules given means to process all modules if [ $# -eq 0 ]; then for M in $(find -maxdepth 1 -executable); do set "$@" "$M" done fi while [ $# -gt 0 ]; do M="$1" "$M" 2>&1 | logger -s -t "multiconfig-$M" || { echo "TODO send email!" } done