[Pkg-samba-maint] Bug#488275: Bug#488275: samba and winbind: initscript miss 'status' option

Christian Perrier bubulle at debian.org
Mon Jun 30 17:44:30 UTC 2008


> This is my addition to the initscript for samba:


I rewrote it to fit the indentation style we use. 

I have no deep advice here, except that:

- the "echo" stuff add extra noise and are not handled by the LSB init
functions. Not sure whether this is wanted. Actually, the important
stuff are return codes... I'd vote to remove these echo lines.

- I haven't even checked the resulting script..:-)


-------------- next part --------------
--- samba.init.old	2008-06-30 19:41:19.661090174 +0200
+++ samba.init	2008-06-30 19:44:20.237089746 +0200
@@ -98,8 +98,65 @@
 		sleep 1
 		$0 start
 		;;
+	status)
+		SMBRETURN=3
+		NMBRETURN=3
+		PIDS_SMBD=`pidof smbd > /dev/null; echo $?`
+		PIDS_NMBD=`pidof nmbd > /dev/null; echo $?`
+		if [ $PIDS_SMBD -gt 0 ]
+		then
+			if [ -f $SMBDPID ]
+			then
+				echo "smbd not running, pidfile exists!"
+				SMBRETURN=1
+			else
+				echo "smbd not running."
+			fi
+		else
+			if [ -f $SMBDPID ]
+			then
+				echo "smbd running"
+				SMBRETURN=0
+			else
+				echo "smbd running, but no pidfile exists!"
+				# No LSB defined return code for this :(
+				SMBRETURN=0
+			fi
+		fi
+		if [ $PIDS_NMBD -gt 0 ]
+		then
+			if [ -f $NMBDPID ]
+			then
+				echo "nmbd not running, pidfile exists!"
+				NMBRETURN=1
+			else
+				echo "nmbd not running."
+			fi
+		else
+			if [ -f $NMBDPID ]
+			then
+				echo "nmbd running"
+				NMBRETURN=0
+			else
+				echo "nmbd running, but no pidfile exists!"
+				# No LSB defined return code for this :(
+				NMBRETURN=0
+			fi
+		fi
+		if [ $SMBRETURN -eq 1 ] || [ $SMBRETURN -eq 1 ]
+		then
+			exit 1
+		elif [ $SMBRETURN -eq $NMBRETURN ]
+		then
+			exit $SMBRETURN
+		else
+			# Apparantly, we have an unknown state, or at least something
+			# that we can't fix easily
+			return 4
+		fi
+		;;
 	*)
-		echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload}"
+		echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload|status}"
 		exit 1
 		;;
 esac
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/pkg-samba-maint/attachments/20080630/491fe493/attachment.pgp 


More information about the Pkg-samba-maint mailing list