#!/bin/sh SERVICE=messagebus LEVELS="0 1 2 3 4 5 6" declare -a STATE for LEVEL in $LEVELS; do /sbin/chkconfig --level $LEVEL $SERVICE STATE[$LEVEL]=$? done /sbin/chkconfig $SERVICE reset for LEVEL in $LEVELS; do LEVEL_STATE=${STATE[$LEVEL]} if [ $LEVEL_STATE == 0 ]; then /sbin/chkconfig --level $LEVEL $SERVICE on elif [ $LEVEL_STATE == 1 ]; then /sbin/chkconfig --level $LEVEL $SERVICE off fi done