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 ;-) Fix: #!/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 -----F6QAkJCObJeIs2Rg3MW8jkeJQ2nCu16THhJNJeGhC98pddzZ Content-Type: text/plain; name="samba.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="samba.patch" --- 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 How-To-Repeat: restart samba (or maybe another port of your choice)
Responsible Changed From-To: freebsd-ports->dwcjr Over to maintainer.
Fixed reboot stability and typo: --- samba.sh.patch (against last patched one) begins here --- --- samba.sh.orig Sat Oct 19 18:32:54 2002 +++ samba.sh Sat Oct 19 19:02:51 2002 @@ -6,11 +6,16 @@ check_running() { - pid=`cat $pidfiledir/$1.pid` - run=`ps ax|grep $pid|grep $1` - if [ -n "$run" ] + if [ -r "$pidfiledir/$1.pid" ] then - rc="yes" + pid=`cat $pidfiledir/$1.pid` + run=`ps ax|grep $pid|grep $1` + if [ -n "$run" ] + then + rc="yes" + else + rc="no" + fi else rc="no" fi @@ -74,7 +79,7 @@ restart) smbdrun=`check_running smbd` nmbdrun=`check_running nmbd` - if [ "yes" = "$smbdrun" -0 "yes" = "$nmbdrun" ] + if [ "yes" = "$smbdrun" -o "yes" = "$nmbdrun" ] then $0 stop fi --- samba.sh.patch begins 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() { if [ -r "$pidfiledir/$1.pid" ] then pid=`cat $pidfiledir/$1.pid` run=`ps ax|grep $pid|grep $1` if [ -n "$run" ] then rc="yes" else rc="no" fi 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" -o "yes" = "$nmbdrun" ] then $0 stop fi $0 start ;; *) ;; esac exit 0 --- samba.sh begins here --- -- L i W W W i Jens Rehsack L W W W L i W W W W i nnn gggg LiWing IT-Services L i W W W W i n n g g LLLL i W W i n n g g Friesenstraße 2 gggg 06112 Halle g g g Tel.: +49 - 3 45 - 5 17 05 91 ggg e-Mail: <rehsack@liwing.de> Fax: +49 - 3 45 - 5 17 05 92 http://www.liwing.de/
Responsible Changed From-To: dwcjr->freebsd-ports-bugs samba* maintainership was reset to ports@ by marcus on 03/04/2004, so return this PR to the pool.
State Changed From-To: open->closed Committed with upgrade submitted by new maintainer.