#!/bin/bash #set -x # check if everything is correct function check() { if [ -x "$RCDIR/$SERVICE" ]; then if [ $SERVICE = "openldap" ]; then SERVICE="ldap" fi case $PARAM in start|START) PARAM="start" && rcrun;; stop|STOP) PARAM="stop" && rcrun;; restart|RESTART) PARAM="restart" && rcrun;; reload|RELOAD) PARAM="reload" && rcrun;; status|STATUS) PARAM="status" && rcrun;; *) echo "ERROR: Parameter $PARAM not supported!" esac else echo "ERROR $RCDIR/$SERVICE NOT found - abort" fi } # starts/stops/restarts... the service function rcrun() { $RCDIR/$SERVICE $PARAM retc=$? if [ $retc -ne 0 ] && [ $retc -ne 3 ]; then echo "ERROR: $RCDIR/$SERVICE $PARAM failed" fi } # variables RC=$1 case $RC in rc) ;; # okay *) echo "ERROR: $1 not supported";; esac if [[ "$2" == "all" ]]; then SERVICES="ldap saslauthd spamd amavis apache2 clamd cyrus postfix" SERVICES="$SERVICES kolab" else SERVICES=$2 fi PARAM=$3 #RCDIR=@rc_dir@ RCDIR=/etc/init.d for SERVICE in $SERVICES; do check $SERVICE done