#!/bin/bash # corz simple slackware service control script v0.2 # usage example: service samba restart # # (c) cor @ corz.org 2005 ;o) # SERVICE=$1 COMMAND=$2 # list services.. service_list() { echo echo " currently available services.." echo for LNAME in /etc/rc.d/rc.* ; do if [ -x $LNAME ]; then NAME=`basename $LNAME` #foreach SLACK ($NOLIST) # hey! it's not csh! if [ $NAME != 'rc.0' ] && [ $NAME != 'rc.4' ] && [ $NAME != 'rc.6' ] && [ $NAME != 'rc.M' ] && [ $NAME != 'rc.S' ] && [ $NAME != 'rc.K' ] && [ $NAME != 'rc.inet1' ] && [ $NAME != 'rc.inet2' ] && [ $NAME != 'rc.local' ] && [ $NAME != 'rc.sysvinit' ] && [ $NAME != 'rc.font' ]; then echo " ${NAME##rc.}" fi fi done echo exit 0 } #oops! do_info() { echo echo " simple slackware service control.." echo echo " usage: service " echo " for example.." echo echo " service sshd restart " echo echo " you can also do service  to get a list of executables in /etc/rc.d" echo exit 0 } # the meat.. service_control() { if [ -f /etc/rc.d/rc.${SERVICE} ]; then /etc/rc.d/rc.${SERVICE} ${COMMAND} # pass-thru and let the service script deal with it exit 0 else echo echo " error: can't ${COMMAND} ${SERVICE}! that service does not exist!" echo exit 1 fi } case "$1" in '') do_info exit 0 ;; l|list) service_list exit 0 ;; *) service_control esac # that's it! life is easier now. # There are two ways of disliking art. # One is to dislike it. # The other is to like it rationally. # -- Oscar Wilde