#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/mod/sbin:/mod/bin:/mod/usr/sbin:/mod/usr/bin export LD_LIBRARY_PATH=/mod/lib DAEMON=inetd case "$1" in ""|load|start|restart|reload) if [ ! -r "/mod/etc/conf/inetd.cfg" ]; then echo "Error[$DAEMON]: not configured" 1>&2 exit 1 fi . /mod/etc/conf/inetd.cfg ;; esac config() { [ -e "/tmp/flash/inetd.conf" ] || { echo -n "Creating inetd.conf " cp /mod/etc/default.inetd/inetd.conf /tmp/flash/inetd.conf echo "ok." } /usr/bin/modinetd } start() { echo -n 'Starting inetd...' if [ -s "/var/run/$DAEMON.pid" ]; then echo 'already running.' exit 0 fi $DAEMON $INETD_OPTIONS exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } stop() { echo -n 'Stopping inetd...' kill $(cat /var/run/$DAEMON.pid) > /dev/null 2>&1 exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } reload() { echo -n 'Reloading inetd configuration...' if [ -r "/var/run/$DAEMON.pid" ]; then kill -HUP `cat /var/run/$DAEMON.pid` fi exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi } case "$1" in ""|load) config modreg cgi 'inetd' 'Inetd' deffile='/mod/etc/default.inetd/inetd_conf.def' [ -r "/tmp/flash/inetd_conf.def" ] && deffile='/tmp/flash/inetd_conf.def' modreg file 'inetd_conf' 'Inetd config' 0 "$deffile" if [ "$INETD_ENABLED" != "yes" ]; then echo "$DAEMON is disabled" 1>&2 exit 1 fi start ;; unload) stop modunreg cgi 'inetd' modunreg file 'inetd_conf' ;; start) start ;; stop) stop ;; reload) reload ;; restart) stop sleep 1 start ;; status) if [ -s "/var/run/$DAEMON.pid" ]; then echo 'running' else echo 'stopped' fi ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0