#!/bin/sh
# updated by Matthew Stephen Hartmann (***@***.***)
# 04/04/2008
E_BADARGS=100
E_GOOD_DAY=101
set -e
if [ $# -eq 0 ]
then
echo "Usage: `basename $0` [option] service-name [instruction]"
echo "Use '-h' or '--help', for help"
exit $E_BADARGS
fi
while [ $# -gt 0 ]; do
case "$1" in
-l|--list)
shift
ls /etc/init.d/
exit $E_GOOD_DAY
;;
-s|--service)
shift
/etc/init.d/$1 $2 $3
exit $E_GOOD_DAY
;;
-h|--help)
echo "Usage: `basename $0` [option] service-name [instruction]"
echo ""
echo "-s | --service option executes the instruction"
echo "i.e.: service -s samba restart"
echo ""
echo "-l | --list option lists services available"
echo "i.e.: service -l"
echo ""
exit $E_GOOD_DAY
;;
* )
echo "Usage: `basename $0` [option] service-name [instruction]"
echo "Use '-h' or '--help', for help"
echo "** invalid argument given **"
exit $E_BADARGS
;;
esac
shift
done
needless to say, it makes having to "ls /etc/init.d/" easier; simply type "service -l" and you're done. to run a service you type "service -s samba restart". cheers!