#!/bin/sh . /etc/init.d/globals SERVICE="$1" ACTION="$2" shift 2 OPTIONS="$*" usage() { echo "usage: service " echo " start or stop a given service (init script)" echo " action depends on the init script" echo exit 1 } get_services() { for i in /etc/init.d/[^SK]* /var/etc/init.d/[^SK]*; do echo "${i##*/}" done | sort -u | grep -v '^\(functions\|globals\|rc\|rcK\|rcS\|start_neutrino\|\[\^SK\]\*\)$' } test -z "$ACTION" && usage; for i in /etc/init.d/$SERVICE /var/etc/init.d/$SERVICE; do if [ -x "$i" ]; then LOGINFO "running $i $ACTION $OPTIONS" "$i" "$ACTION" "$OPTIONS" exit $? fi done echo "$SERVICE not found in /etc/init.d/ and /var/etc/init.d/" echo "available services:" echo $(get_services) | xargs -n 1 echo " " exit 1