#!/bin/sh DAEMON=ndyndns CONF_NAME=ndyndns PID_FILE=/var/run/$DAEMON.pid start() { echo -n "Starting $DAEMON..." if [ ! -z "$(pidof $DAEMON)" ]; then echo 'already running.' exit 0 fi $DAEMON -r -x -d -f /tmp/flash/mod/$CONF_NAME.conf exitval=$? pidof $DAEMON > $PID_FILE if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } case $1 in start) if [ -s /tmp/flash/mod/$CONF_NAME.conf ] && \ [ -z "$(pidof $DAEMON)" ]; then start else echo 'there is no configuration file.' fi ;; start_nodaemon) if [ -z "$(pidof $DAEMON)" ]; then start sleep 15 kill "$(pidof $DAEMON)" rm -f $PID_FILE fi ;; stop) if [ ! -z "$(pidof $DAEMON)" ]; then kill "$(pidof $DAEMON)" rm -f $PID_FILE else echo '... already stopped. ndyndns is running in nodaemon mode.' fi ;; restart) if [ ! -z "$(pidof $DAEMON)" ]; then kill "$(pidof $DAEMON)" rm -f $PID_FILE sleep 1 start else start fi ;; status) if [ ! -z "$(pidof $DAEMON)" ]; then echo 'running' else echo 'nodaemon' fi ;; *) echo "Usage: $0 [start|start_nodaemon|stop|restart|status]" 1>&2 exit 1 ;; esac exit $?