#!/bin/sh
#  script for qtsmbstatusd
#

# For LSB
### BEGIN INIT INFO
# Provides:          qtsmbstatusd
# Required-Start:    $samba
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: start qtsmbstatusd server at boot time
# Description:       QtSmbstatus is a graphical user interface for smbstatus
### END INIT INFO

# For Mandrake/Mandriva/Fedora:
# chkconfig: 35 99 20
# description: qtsmbstatusd server (QtSmbstatus is a graphical user interface for smbstatus)


NAME=qtsmbstatusd

# see if qtsmbstatusd is running
pid=`ps ax | awk '{print $1,$5}' | grep $NAME | awk '{print $1}' | awk '{print $1}'`

# Start or stop the qtsmbstatusd server
case $1 in
	start | restart | reload | force-reload)
                if test "$pid" != ""; then
                        kill $pid
			if /usr/bin/qtsmbstatusd -d; then
		  	echo "qtsmbstatusd server restarted."
			fi
                else
                  	if /usr/bin/qtsmbstatusd -d; then
		  	echo "qtsmbstatusd server started."
			fi
                fi
                ;;
	stop)
		if test "$pid" != ""; then
		  kill -3 $pid
		fi
		echo "qtsmbstatusd server stopped"
		;;

	status)
		if test "$pid" != ""; then
			echo "qtsmbstatusd : server is running."
		else
			echo "qtsmbstatusd : server is not running."
		fi
		;;

	*)
		echo "Usage: qtsmbstatusd {start|stop|reload|restart|status|force-reload}"
		exit 1
		;;
esac

exit 0
