2010-05-13 01:00:01 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Start/stop/restart the hiawatha web server
|
|
|
|
# Copyright (c) 2009 Antonio Hernández Blas <hba.nihilismus@gmail.com>
|
|
|
|
|
|
|
|
CONF='/etc/hiawatha'
|
|
|
|
CMMD="/usr/sbin/hiawatha -c $CONF"
|
|
|
|
|
|
|
|
hiawatha_start() {
|
|
|
|
if [ -x /usr/sbin/hiawatha ]; then
|
|
|
|
if [ -d $CONF ]; then
|
|
|
|
PIDOF=$(pgrep -f "$CMMD")
|
|
|
|
if [ ! -z "$PIDOF" ]; then
|
|
|
|
echo "Error, hiawatha is already running."
|
|
|
|
else
|
|
|
|
echo "Starting hiawatha: $CMMD"
|
|
|
|
$CMMD
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Error, directory $CONF does not exist."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
hiawatha_stop() {
|
|
|
|
PIDOF=$(pgrep -f "$CMMD")
|
|
|
|
if [ -z "$PIDOF" ]; then
|
|
|
|
echo "Error, hiawatha is not running."
|
|
|
|
else
|
2010-05-11 03:01:24 +02:00
|
|
|
echo "Stoping hiawatha: /bin/kill -s TERM $PIDOF"
|
|
|
|
/bin/kill -s TERM $PIDOF
|
2010-05-13 01:00:01 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
hiawatha_status() {
|
|
|
|
PIDOF=$(pgrep -f "$CMMD")
|
|
|
|
if [ ! -z "$PIDOF" ]; then
|
|
|
|
echo "hiawatha is running."
|
|
|
|
else
|
|
|
|
echo "hiawatha is not running."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
start)
|
|
|
|
hiawatha_start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
hiawatha_stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
hiawatha_stop
|
2010-05-11 03:01:24 +02:00
|
|
|
sleep 3
|
2010-05-13 01:00:01 +02:00
|
|
|
hiawatha_start
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
hiawatha_status
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage $0 {start|stop|restart|status}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|