#!/bin/bash SERVICEDIR=/etc/rc.d SERVICE=$1 COMMAND=$2 SUPPORTED= usage() { echo "Usage: $( basename $0 ) " } if [ $# -eq 0 ]; then usage exit 1 elif [ $# -ne 2 ]; then echo "Error: Wrong number of parameters" >&2 usage exit 2 fi if [ ! -x "${SERVICEDIR}/${SERVICE}" ]; then echo "Error: Service ${SERVICE} not recognized" >&2 exit 3 fi for action in $( sed -ne "y/|/ /; s/^.*usage.*{\(.*\)}.*$/\1/p" ${SERVICEDIR}/${SERVICE} ); do if [ "${COMMAND}" = "${action}" ]; then SUPPORTED=y fi done if [ "${SUPPORTED}" != "y" ]; then echo "Error: Command ${COMMAND} is not supported by service ${SERVICE}" >&2 exit 4 fi env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" \ "${SERVICEDIR}/${SERVICE}" "${COMMAND}" # vim: set ts=2 sw=2 noet: