#!/bin/bash # # Start/stop chttpd web server [ -f /usr/bin/chttpd ] || exit 0 pid=$(pidof -x chttpd 2> /dev/null) start() { if [ -z ${pid} ] ; then /usr/bin/chttpd 2> /dev/null else echo "chttpd is already started" fi } stop(){ if [ ! -z ${pid} ] ; then kill -9 $pid 2> /dev/null else echo "chttpd is not running" fi } restart() { stop sleep 1 start } case "$1" in 'start') start ;; 'stop') stop ;; 'restart') restart ;; *) echo "Usage $(basename $0): start|stop|restart" esac