1#!/bin/sh 2# 3# chkconfig: - 91 35 4# description: Starts and stops the Samba smbd and nmbd daemons \ 5# used to provide SMB network services. 6# 7# pidfile: /var/run/samba/smbd.pid 8# pidfile: /var/run/samba/nmbd.pid 9# config: /etc/samba/smb.conf 10 11 12# Source function library. 13if [ -f /etc/init.d/functions ] ; then 14 . /etc/init.d/functions 15elif [ -f /etc/rc.d/init.d/functions ] ; then 16 . /etc/rc.d/init.d/functions 17else 18 exit 0 19fi 20 21# Avoid using root's TMPDIR 22unset TMPDIR 23 24# Source networking configuration. 25. /etc/sysconfig/network 26 27if [ -f /etc/sysconfig/samba ]; then 28 . /etc/sysconfig/samba 29fi 30 31# Check that networking is up. 32[ ${NETWORKING} = "no" ] && exit 0 33 34# Check that smb.conf exists. 35[ -f /etc/samba/smb.conf ] || exit 0 36 37# Check that we can write to it... so non-root users stop here 38[ -w /etc/samba/smb.conf ] || exit 0 39 40 41RETVAL=0 42 43 44start() { 45 KIND="SMB" 46 echo -n $"Starting $KIND services: " 47 daemon smbd $SMBDOPTIONS 48 RETVAL=$? 49 echo 50 KIND="NMB" 51 echo -n $"Starting $KIND services: " 52 daemon nmbd $NMBDOPTIONS 53 RETVAL2=$? 54 echo 55 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \ 56 RETVAL=1 57 return $RETVAL 58} 59 60stop() { 61 KIND="SMB" 62 echo -n $"Shutting down $KIND services: " 63 killproc smbd -TERM 64 RETVAL=$? 65 [ $RETVAL -eq 0 ] && rm -f /var/run/smbd.pid 66 echo 67 KIND="NMB" 68 echo -n $"Shutting down $KIND services: " 69 killproc nmbd -TERM 70 RETVAL2=$? 71 [ $RETVAL2 -eq 0 ] && rm -f /var/run/nmbd.pid 72 [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb 73 echo "" 74 return $RETVAL 75} 76 77restart() { 78 stop 79 start 80} 81 82reload() { 83 echo -n $"Reloading smb.conf file: " 84 killproc smbd -HUP 85 RETVAL=$? 86 echo 87 return $RETVAL 88} 89 90rhstatus() { 91 status smbd 92 status nmbd 93} 94 95case "$1" in 96 start) 97 start 98 ;; 99 stop) 100 stop 101 ;; 102 restart) 103 restart 104 ;; 105 reload) 106 reload 107 ;; 108 status) 109 rhstatus 110 ;; 111 condrestart) 112 [ -f /var/lock/subsys/smb ] && restart || : 113 ;; 114 *) 115 echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}" 116 exit 1 117esac 118 119exit $? 120