Date: Sat, 19 Oct 2002 21:04:13 +0200 From: Jens Rehsack <rehsack@liwing.de> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Jens Rehsack <rehsack@liwing.de> Subject: ports/44273: improved samba start script Message-ID: <3DB1ACAD.B1FFC5FB@liwing.de>
next in thread | raw e-mail | index | archive | help
>Number: 44273 >Category: ports >Synopsis: improved samba start script >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Oct 19 12:10:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jens Rehsack >Release: FreeBSD 4.7-STABLE i386 >Organization: LiWing IT-Services >Environment: System: FreeBSD webdev.muppets.liwing.de 4.7-STABLE FreeBSD 4.7-STABLE #3: Fri Oct 11 23:02:46 GMT 2002 root@webdev.muppets.liwing.de:/usr/obj/usr/src/sys/WEBDEV i386 >Description: It stressed me to much always restarting samba after portupgrade using /usr/local/etc/rc.d/samba.sh stop && /usr/local/etc/rc.d/samba.sh start So I borrowed the "reload" and the "restart" options from some linux distribution ;-) >How-To-Repeat: restart samba (or maybe another port of your choice) >Fix: --- samba.patch begins here --- --- samba.sh.orig Sat Oct 19 18:00:39 2002 +++ samba.sh Sat Oct 19 18:32:55 2002 @@ -4,19 +4,84 @@ smbd=/usr/local/sbin/smbd nmbd=/usr/local/sbin/nmbd -# start -if [ "x$1" = "x" -o "x$1" = "xstart" ]; then - if [ -f $smbd ]; then - if [ -d $smbspool ]; then - rm -f $smbspool/* - fi - echo -n ' Samba' - $smbd -D - $nmbd -D +check_running() +{ + pid=`cat $pidfiledir/$1.pid` + run=`ps ax|grep $pid|grep $1` + if [ -n "$run" ] + then + rc="yes" + else + rc="no" fi + echo $rc +} -# stop -elif [ "x$1" = "xstop" ]; then - kill `cat $pidfiledir/smbd.pid` - kill `cat $pidfiledir/nmbd.pid` +if [ -z "$1" ] +then + param="start" +else + param=$1 fi + +case "$param" in +start) + smbdrun=`check_running smbd` + nmbdrun=`check_running nmbd` + if [ "yes" = "$smbdrun" -a "yes" = "$nmbdrun" ] + then + echo "Samba is running already" + exit 1 + else + if [ -f $smbd ] + then + if [ -d $smbspool ] + then + rm -f $smbspool/* + fi + + if [ "no" = "$smbdrun" ]; then $smbd -D; fi + if [ "no" = "$nmbdrun" ]; then $nmbd -D; fi + + echo -n ' Samba' + fi + fi + ;; +stop) + smbdrun=`check_running smbd` + nmbdrun=`check_running nmbd` + if [ "no" = "$smbdrun" -a "no" = "$nmbdrun" ] + then + echo " Samba is not running" + exit 1 + else + if [ "yes" = "$smbdrun" ]; then kill `cat $pidfiledir/smbd.pid`; fi + if [ "yes" = "$smbdrun" ]; then kill `cat $pidfiledir/nmbd.pid`; fi + fi + ;; +reload) + smbdrun=`check_running smbd` + nmbdrun=`check_running nmbd` + if [ "no" = "$smbdrun" -a "no" = "$nmbdrun" ] + then + echo " Samba is not running" + exit 1 + else + if [ "yes" = "$smbdrun" ]; then kill -HUP `cat $pidfiledir/smbd.pid`; fi + if [ "yes" = "$smbdrun" ]; then kill -HUP `cat $pidfiledir/nmbd.pid`; fi + fi + ;; +restart) + smbdrun=`check_running smbd` + nmbdrun=`check_running nmbd` + if [ "yes" = "$smbdrun" -0 "yes" = "$nmbdrun" ] + then + $0 stop + fi + $0 start + ;; +*) + ;; +esac + +exit 0 --- samba.patch ends here --- --- samba.sh begins here --- #!/bin/sh smbspool=/var/spool/samba pidfiledir=/var/run smbd=/usr/local/sbin/smbd nmbd=/usr/local/sbin/nmbd check_running() { pid=`cat $pidfiledir/$1.pid` run=`ps ax|grep $pid|grep $1` if [ -n "$run" ] then rc="yes" else rc="no" fi echo $rc } if [ -z "$1" ] then param="start" else param=$1 fi case "$param" in start) smbdrun=`check_running smbd` nmbdrun=`check_running nmbd` if [ "yes" = "$smbdrun" -a "yes" = "$nmbdrun" ] then echo "Samba is running already" exit 1 else if [ -f $smbd ] then if [ -d $smbspool ] then rm -f $smbspool/* fi if [ "no" = "$smbdrun" ]; then $smbd -D; fi if [ "no" = "$nmbdrun" ]; then $nmbd -D; fi echo -n ' Samba' fi fi ;; stop) smbdrun=`check_running smbd` nmbdrun=`check_running nmbd` if [ "no" = "$smbdrun" -a "no" = "$nmbdrun" ] then echo " Samba is not running" exit 1 else if [ "yes" = "$smbdrun" ]; then kill `cat $pidfiledir/smbd.pid`; fi if [ "yes" = "$smbdrun" ]; then kill `cat $pidfiledir/nmbd.pid`; fi fi ;; reload) smbdrun=`check_running smbd` nmbdrun=`check_running nmbd` if [ "no" = "$smbdrun" -a "no" = "$nmbdrun" ] then echo " Samba is not running" exit 1 else if [ "yes" = "$smbdrun" ]; then kill -HUP `cat $pidfiledir/smbd.pid`; fi if [ "yes" = "$smbdrun" ]; then kill -HUP `cat $pidfiledir/nmbd.pid`; fi fi ;; restart) smbdrun=`check_running smbd` nmbdrun=`check_running nmbd` if [ "yes" = "$smbdrun" -0 "yes" = "$nmbdrun" ] then $0 stop fi $0 start ;; *) ;; esac exit 0 --- samba.sh ends here --- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DB1ACAD.B1FFC5FB>