[commit] r2299 - in trunk/vendors/Nintendo/common: . rc.d

dslinux_sonny_jim at dslinux.in-berlin.de dslinux_sonny_jim at dslinux.in-berlin.de
Wed Jul 23 22:18:53 CEST 2008


Author: dslinux_sonny_jim
Date: Wed Jul 23 22:18:53 2008
New Revision: 2299

Log:
fix rc.d scripts to start/restart properly

Modified:
   trunk/vendors/Nintendo/common/rc.d/boa
   trunk/vendors/Nintendo/common/rc.d/esd
   trunk/vendors/Nintendo/common/rc.d/inadyn
   trunk/vendors/Nintendo/common/rc.d/inetd
   trunk/vendors/Nintendo/common/rc.d/openvpn
   trunk/vendors/Nintendo/common/rc.d/skel
   trunk/vendors/Nintendo/common/rc.d/syslogd
   trunk/vendors/Nintendo/common/rc.defaults

Modified: trunk/vendors/Nintendo/common/rc.d/boa
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/boa	(original)
+++ trunk/vendors/Nintendo/common/rc.d/boa	Wed Jul 23 22:18:53 2008
@@ -4,23 +4,91 @@
 [ -e /etc/rc.conf ] && . /etc/rc.conf
 
 DAEMON=boa
-OPTIONS="-d -c /var/www"
+DEFAULTOPTS="-d -c /var/www"
+
 case "$1" in
 	start)
-		echo "Starting $DAEMON"
-		$DAEMON $OPTIONS &
-	;;
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			# Set default options if none set in rc.conf
+			if [ $boa_options="" ]
+			then
+				echo "No options set in rc.conf for $DAEMON, using defaults"
+				boa_options=$DEFAULTOPTS
+			fi
+			# Start Daemon
+			echo "Starting $DAEMON"
+			$DAEMON $boa_options &
+			# Get Daemon pid
+			# Strip script PID from pidof output
+			DAEMONPID=`pidof $DAEMON|sed s/$$//`
+			# Write pid to file
+			echo $DAEMONPID > /var/run/$DAEMON.pid
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			echo "already running"
+			$0 status
+			exit 1
+		fi
+		;;
 	stop)
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
 		echo "Stopping $DAEMON"
-		kill -9 `pidof $DAEMON`
-	;;	
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid file
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
 	restart)
-		$0 stop
-		$0 start
-	;;
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
+
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			kill `cat /var/run/$DAEMON.pid`
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
+
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
+		fi
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
-
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.d/esd
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/esd	(original)
+++ trunk/vendors/Nintendo/common/rc.d/esd	Wed Jul 23 22:18:53 2008
@@ -3,26 +3,94 @@
 [ -e /etc/rc.defaults ] && . /etc/rc.defaults
 [ -e /etc/rc.conf ] && . /etc/rc.conf
 
+# Get ip address of nds interface
 getip | read IP
 
 DAEMON=esd
-OPTIONS="-nobeeps -r 32768 -bind $IP -tcp -promiscuous"
+DEFAULTOPTS="-nobeeps -r 32768 -bind $IP -tcp -promiscuous"
+
 case "$1" in
 	start)
-		echo "Starting $DAEMON"
-		$DAEMON $OPTIONS &
-	;;
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			# Set default options if none set in rc.conf
+			if [ $esd_options="" ]
+			then
+				echo "No options set in rc.conf for $DAEMON, using defaults"
+				esd_options=$DEFAULTOPTS
+			fi
+			# Start Daemon
+			echo "Starting $DAEMON"
+			$DAEMON $esd_options &
+			# Get Daemon pid
+			# Strip script PID from pidof output
+			DAEMONPID=`pidof $DAEMON|sed s/$$//`
+			# Write pid to file
+			echo $DAEMONPID > /var/run/$DAEMON.pid
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			$0 status
+			exit 1
+		fi
+		;;
 	stop)
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
 		echo "Stopping $DAEMON"
-		kill -9 `pidof $DAEMON`
-	;;	
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid file
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
 	restart)
-		$0 stop
-		$0 start
-	;;
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
+
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			kill `cat /var/run/$DAEMON.pid`
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
+
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
+		fi
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
-
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.d/inadyn
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/inadyn	(original)
+++ trunk/vendors/Nintendo/common/rc.d/inadyn	Wed Jul 23 22:18:53 2008
@@ -3,32 +3,99 @@
 [ -e /etc/rc.defaults ] && . /etc/rc.defaults
 [ -e /etc/rc.conf ] && . /etc/rc.conf
 
-CONFIG=/etc/inadyn.conf
-
+DAEMON=inadyn
+DEFAULTOPTS="/etc/inadyn.conf"
 
 case "$1" in
 	start)
-		if [ ! -f $CONFIG ]
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
 		then
-			echo "Error: Configuration file $CONFIG not found!"
-			echo "Please read /etc/inadyn.conf.example"
-			echo "Copy and edit it to /etc/inadyn.conf"
+			
+			# Set default options if none set in rc.conf
+			if [ $inadyn_config="" ]
+			then
+				echo "No options set in rc.conf for $DAEMON, using defaults"
+				inadyn_config=$DEFAULTOPTS
+			fi
+			#Check for existence of config file
+			if [ ! -f $inadyn_config ]
+				echo "Error: Configuration file $inadyn_config not found!"
+				echo "Please read /etc/inadyn.conf.example"
+				exit 1
+			fi
+			# Start Daemon
+			echo "Starting $DAEMON"
+			$DAEMON --input_file $inadyn_config >> /var/log/inadyn.log &
+			# Get Daemon pid
+			# Strip script PID from pidof output
+			DAEMONPID=`pidof $DAEMON|sed s/$$//`
+			# Write pid to file
+			echo $DAEMONPID > /var/run/$DAEMON.pid
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			echo "already running"
+			$0 status
 			exit 1
 		fi
-
-		echo "Starting inadyn"
-		inadyn --input_file $CONFIG >> /var/log/inadyn.log&
-	;;
+		;;
 	stop)
-		echo "Stopping inadyn"
-		killall inadyn
-	;;	
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
+		echo "Stopping $DAEMON"
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid file
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
 	restart)
-		$0 stop
-		$0 start
-	;;
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
+
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			kill `cat /var/run/$DAEMON.pid`
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
+
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
+		fi
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.d/inetd
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/inetd	(original)
+++ trunk/vendors/Nintendo/common/rc.d/inetd	Wed Jul 23 22:18:53 2008
@@ -4,55 +4,127 @@
 [ -e /etc/rc.conf ] && . /etc/rc.conf
 
 DAEMON=inetd
-INETD_CONF=/etc/inetd.conf
-SSH_HOST_KEY=/etc/dropbear_rsa_host_key
+default_inetd_config=/etc/inetd.conf
+default_ssh_host_key=/etc/dropbear_rsa_host_key
 
 case "$1" in
 	start)
-		echo "Starting $DAEMON"
-		
-		# Check for existence of config file
-		if [ ! -f $INETD_CONF ]
+		if [ ! -f "/var/run/$DAEMON.pid" ]
 		then
-			echo "$INETD_CONF not found!"
-			echo "Please read /etc/inetd.conf.example"
+			echo "Starting $DAEMON"
+			# Set defaults if none specified in /etc/rc.conf
+			if [ $inetd_config="" ]
+			then
+				echo "No inetd.conf specified in rc.conf, using default location"
+				INETD_CONF=$default_inetd_config
+			else
+				INETD_CONF=$inetd_config
+			fi
+
+			if [ $ssh_host_key="" ]
+			then
+				echo "No ssh hostkey specified in rc.conf, using default location"
+				SSH_HOST_KEY=$default_ssh_host_key
+			else
+				SSH_HOST_KEY=$ssh_host_key
+			fi
+
+			# Check for existence of config file
+			if [ ! -f $INETD_CONF ]
+			then
+				echo "$INETD_CONF not found!"
+				echo "Please read /etc/inetd.conf.example"
+				exit 1
+			fi
+	
+			# Check for existence of dropbear key
+			# Generate if not found and sshd enabled
+	
+			if grep ssh $INETD_CONF | grep -v "^#" >/dev/null \
+				&& [ ! -e $SSH_HOST_KEY ]
+			then
+				echo "You have enabled dropbear in $INETD_CONF"
+				echo "but there is no SSH host key yet."
+				/usr/bin/dropbearkey -t rsa -f $SSH_HOST_KEY
+			fi		
+			# Check for existence of samba password
+			# Generate if not found and smbd enabled
+
+			if grep netbios-ssn $INETD_CONF | grep -v "^#" >/dev/null \
+				&& [ ! -e /etc/smbpasswd ]
+			then
+				echo "Generating default smbpasswd"
+				echo "You are advised to change this with smbpasswd"
+				(echo uClinux ; echo uClinux) | /usr/bin/smbpasswd -a root -s
+			fi
+			# Start Daemon
+			$DAEMON $INETD_CONF &
+			# Don't need to create pid as inetd does this for us
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			$0 status
 			exit 1
 		fi
+		;;
+	stop)
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
+		echo "Stopping $DAEMON"
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
+	restart)
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
 
-		# Check for existence of dropbear key
-		# Generate if not found and sshd enabled
-
-		if grep ssh $INETD_CONF | grep -v "^#" >/dev/null \
-			&& [ ! -e $SSH_HOST_KEY ]
+		if [ ! -f "/var/run/$DAEMON.pid" ]
 		then
-			echo "You have enabled dropbear in $INETD_CONF"
-			echo "but there is no SSH host key yet."
-			/usr/bin/dropbearkey -t rsa -f $SSH_HOST_KEY
-		fi		
-		
-		# Check for existence of samba password
-		# Generate if not found and smbd enabled
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			# kill daemon
+			kill `cat /var/run/$DAEMON.pid`
+			# Remove pid
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
 
-		if grep netbios-ssn $INETD_CONF | grep -v "^#" >/dev/null \
-			&& [ ! -e /etc/smbpasswd ]
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
 		then
-			echo "Generating default smbpasswd"
-			echo "You are advised to change this with smbpasswd"
-			(echo uClinux ; echo uClinux) | /usr/bin/smbpasswd -a root -s
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
 		fi
-		$DAEMON &
-	;;
-	stop)
-		echo "Stopping $DAEMON"
-		kill -9 `pidof $DAEMON`
-	;;	
-	restart)
-		$0 stop
-		$0 start
-	;;
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
-
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.d/openvpn
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/openvpn	(original)
+++ trunk/vendors/Nintendo/common/rc.d/openvpn	Wed Jul 23 22:18:53 2008
@@ -1,26 +1,100 @@
 #!/bin/sh
+# This can be used as a 'skeleton' script to build new rc.d scripts around
 
 [ -e /etc/rc.defaults ] && . /etc/rc.defaults
 [ -e /etc/rc.conf ] && . /etc/rc.conf
 
 DAEMON=openvpn
-CONFIG=/etc/openvpn.conf
+
+DEFAULTCONFIG="/etc/openvpn.conf"
+
 case "$1" in
 	start)
-		echo "Starting $DAEMON"
-		$DAEMON --config $CONFIG --writepid /var/run/openvpn.pid&
-	;;
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			# Set default options if none set in rc.conf
+			if [ $openvpn_config="" ]
+			then
+				echo "No options set in rc.conf for $DAEMON, using defaults"
+				CONFIG=$DEFAULTCONFIG
+			else
+				CONFIG=openvpn_config	
+			fi
+			# Check for config file existence
+			if [ ! -f $CONFIG ]
+			then
+				echo "Error configuration file $CONFIG not found!"
+				echo "Please read /etc/openvpn.conf.example"
+				exit 1
+			fi
+			# Start Daemon
+			echo "Starting $DAEMON"
+			$DAEMON --config $CONFIG --writepid /var/run/openvpn.pid&
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			echo "already running"
+			$0 status
+			exit 1
+		fi
+		;;
 	stop)
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
 		echo "Stopping $DAEMON"
-		kill -9 `pidof $DAEMON`
-	;;	
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid file
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
 	restart)
-		$0 stop
-		$0 start
-	;;
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
+
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			kill `cat /var/run/$DAEMON.pid`
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
+
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
+		fi
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
-
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.d/skel
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/skel	(original)
+++ trunk/vendors/Nintendo/common/rc.d/skel	Wed Jul 23 22:18:53 2008
@@ -1,28 +1,95 @@
 #!/bin/sh
-# this init script can be used as a skeleton for other init scripts.
+# This can be used as a 'skeleton' script to build new rc.d scripts around
 
 [ -e /etc/rc.defaults ] && . /etc/rc.defaults
 [ -e /etc/rc.conf ] && . /etc/rc.conf
 
 DAEMON=daemon
+DEFAULTOPTS=""
 
 case "$1" in
 	start)
-		echo "Starting $DAEMON"
-		$DAEMON &
-	;;
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			# Set default options if none set in rc.conf
+			if [ $daemon_options="" ]
+			then
+				echo "No options set in rc.conf for $DAEMON, using defaults"
+				daemon_options=$DEFAULTOPTS
+			fi
+			# Start Daemon
+			echo "Starting $DAEMON"
+			$DAEMON $daemon_options &
+			# Get Daemon pid
+			# Strip script PID from pidof output
+			DAEMONPID=`pidof $DAEMON|sed s/$$//`
+			# Write pid to file
+			echo $DAEMONPID > /var/run/$DAEMON.pid
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			echo "already running"
+			$0 status
+			exit 1
+		fi
+		;;
 	stop)
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
 		echo "Stopping $DAEMON"
-		kill `pidof $DEAMON`
-	;;	
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid file
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
 	restart)
-		# no need to change this
-		$0 stop
-		$0 start
-	;;
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
+
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			kill `cat /var/run/$DAEMON.pid`
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
+
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
+		fi
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
-
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.d/syslogd
==============================================================================
--- trunk/vendors/Nintendo/common/rc.d/syslogd	(original)
+++ trunk/vendors/Nintendo/common/rc.d/syslogd	Wed Jul 23 22:18:53 2008
@@ -7,20 +7,81 @@
 
 case "$1" in
 	start)
-		echo "Starting $DAEMON"
-		$DAEMON &
-	;;
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			# Start Daemon
+			echo "Starting $DAEMON"
+			$DAEMON &
+			# Get Daemon pid
+			# Strip script PID from pidof output
+			DAEMONPID=`pidof $DAEMON|sed s/$$//`
+			# Write pid to file
+			echo $DAEMONPID > /var/run/$DAEMON.pid
+			# Check Daemon launched OK
+			if ps -fp$! > /dev/null 2>&1
+			then
+				echo "  >> OK"
+			else
+				echo "  ** FAILED"
+			fi
+		else
+			# Daemon already running, show status
+			echo "already running"
+			$0 status
+			exit 1
+		fi
+		;;
 	stop)
+		# Make sure we don't nuke this script 
+		# in the process of stopping daemon.
+		# killall will kill this script as well
+		# as it shares the same ps name
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+                then                                   
+			# Daemon not running, show status
+                        $0 status
+			exit 1
+		fi
 		echo "Stopping $DAEMON"
-		kill -9 `pidof $DAEMON`
-	;;	
+		# kill daemon
+		kill `cat /var/run/$DAEMON.pid`
+		# Remove pid file
+		rm /var/run/$DAEMON.pid
+		echo "  >> OK"
+		;;
 	restart)
-		$0 stop
-		$0 start
-	;;
+		# If daemon not running, start
+		# Otherwise start and stop daemon
+		# Ugly hack as ps id's change when using
+		# $0 start and $0 stop
+
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON not running, starting"
+			exec /etc/rc.d/$DAEMON start
+		else
+			echo "Stopping $DAEMON"
+			kill `cat /var/run/$DAEMON.pid`
+			rm /var/run/$DAEMON.pid
+			echo "  >> OK"
+			exec /etc/rc.d/$DAEMON start
+		fi
+		;;
+
+	status)
+		
+		if [ ! -f "/var/run/$DAEMON.pid" ]
+		then
+			echo "$DAEMON is not running or pidfile does not exist"
+		else
+			DAEMONPID=`cat /var/run/$DAEMON.pid`
+			echo "$DAEMON is running with pid $DAEMONPID"
+		fi
+		;;
 	*)
-		echo "Usage: $0 <start|stop|restart>"
+		echo "Usage: $0 <start|stop|restart|status>"
 		exit 1
-	;;
+		;;
 esac
-
+# vim:ts=4:sw=4:ic:ai:nows:

Modified: trunk/vendors/Nintendo/common/rc.defaults
==============================================================================
--- trunk/vendors/Nintendo/common/rc.defaults	(original)
+++ trunk/vendors/Nintendo/common/rc.defaults	Wed Jul 23 22:18:53 2008
@@ -108,11 +108,17 @@
 dns2=""
 
 # If you want to start inetd on boot, say "YES" here
-# Don't forget to edit /etc/inetd.conf!
+# Don't forget to create /etc/inetd.conf!
+# To override the default options use:
+# inetd_config="/path/to/inetd.conf"
+# ssh_host_key="/path/to/ssh.key"
 start_inetd="NO"
 
 # To start openvpn on boot say "YES" here
 # Please read /etc/openvpn.conf.example
+# Check /var/log/openvpn.log for error messages
+# to override the default config file location use:
+# openvpn_config="/path/to/openvpn.conf"
 start_openvpn="NO"
 
 # If you want to see your DS firmware version on boot,
@@ -128,17 +134,24 @@
 
 # To start the boa webserver on boot, set this to "YES"
 # NOTE: The default website is /var/www
+# To override the default docroot, use:
+# boa_options="-d -c /var/www"
 start_boa="NO"
 
 # To start the inadyn DynDns.org client, set to "YES"
-# NOTE: Please edit /etc/inadyn.conf.example
-# and copy to /etc/inadyn.conf
+# Please read /etc/inadyn.conf.example
+# Check /var/log/inadyn.log for error messages
+# To override the default config file location use:
+# inadyn_config="/path/to/inadyn.conf"
 start_inadyn="NO"
 
 # To start the syslog daemon, set to "YES"
+# This will create logs in /var/log
 start_syslogd="NO"
 
 # To start the Enlightenment Sound Daemon, set to "YES"
+# To override default esd options use:
+# esd_options="-nobeeps -r 32768 -bind ipaddressofnds -tcp -promiscuous"
 start_esd="NO"
 
 # If you use a proxy server in your environment, specify it here


More information about the dslinux-commit mailing list