#!/bin/bash # Copyright (C) 2009 Andy Spencer # See ../COPYING for terms function usage { cat - < [start-|stop-] Action: -u,--is-up Test is service is running -d,--is-down Test is service is stopped -U,--set-up Set service to running -D,--set-down Set service to stopped -q,--query Print the state of a service EOF exit } # Main STATE=/lib/mkinit/state action="$1" service="${2/-*}" [ "$action" -a "$service" ] || usage # echo "$0 $@" case "$1" in -u|--is-up ) test -e "$STATE/$service" ;; -d|--is-down ) test ! -e "$STATE/$service" ;; -U|--set-up ) touch "$STATE/$service" ;; -D|--set-down ) rm "$STATE/$service" ;; -q|--query ) echo -n "Service \`$service' is " test -e "$STATE/$service" \ && echo running \ || echo stopped ;; * ) usage ;; esac