#!/bin/bash # THIS IS A DRAFT # http://refspecs.linux-foundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html function usage { echo "${0##*/} " exit 1 } [[ -z $2 ]] && usage conf=$1 action=$2 [[ ! -f $conf ]] && echo could not find $conf && exit 1 if [[ $action = start ]]; then # returns 0 if up pidof thttpd >/dev/null 2>&1 && exit 0 echo -n starting thttpd... thttpd -C $conf && echo done elif [[ $action = monitor ]]; then pidof thttpd >/dev/null 2>&1 elif [[ $action = stop ]]; then # returns 0 if down pidof thttpd >/dev/null 2>&1 || exit 0 echo -n shutting down thttpd... pkill thttpd >/dev/null 2>&1 && echo done # returns 1 if up #pidof thttpd >/dev/null 2>&1 && exit 1 else usage fi