diff options
Diffstat (limited to 'net/samba-devel/files/samba.sh.sample')
-rw-r--r-- | net/samba-devel/files/samba.sh.sample | 126 |
1 files changed, 94 insertions, 32 deletions
diff --git a/net/samba-devel/files/samba.sh.sample b/net/samba-devel/files/samba.sh.sample index d0a46a32d30e..0221db03567c 100644 --- a/net/samba-devel/files/samba.sh.sample +++ b/net/samba-devel/files/samba.sh.sample @@ -1,61 +1,123 @@ #!/bin/sh # +# $FreeBSD$ +# -# PROVIDE: samba -# REQUIRE: DAEMON -# BEFORE: LOGIN +# PROVIDE: nmbd smbd +%%WINBIND%%# PROVIDE: winbindd +# REQUIRE: NETWORKING SERVERS named %%CUPS%% +# BEFORE: DAEMON # KEYWORD: FreeBSD shutdown # # Add the following lines to /etc/rc.conf to enable samba: # -#smbd_enable="YES" -#smbd_flags="-D" - optional because "-D" is the default flag +#samba_enable="YES" # -#nmbd_enable="YES" -#nmbd_flags="-D" - optional because "-D" is the default flag +# or, for fine grain control # -#winbindd_enable="YES" -#winbindd_flags="" - optional +#nmbd_enable="YES" +#smbd_enable="YES" +%%WINBIND%%#winbindd_enable="YES" # . %%RC_SUBR%% -name=smbd +name=samba rcvar=`set_rcvar` -command=%%PREFIX%%/sbin/smbd -required_files=%%SAMBA_CONFDIR%%/smb.conf -pidfile=/var/run/smbd.pid - -# set defaults -smbd_enable=${smbd_enable:-"NO"} -smbd_flags=${smbd_flags:-"-D"} load_rc_config $name -run_rc_command "$1" +# Set defaults +samba_config=${samba_config:-"%%SAMBA_CONFIG%%"} +# Config file is required +if [ ! -r ${samba_config} ]; then + warn "${samba_config} is not readable." + case $1 in + force*) : ;; + *) exit 1 ;; + esac +fi -name=nmbd -rcvar=`set_rcvar` -command=%%PREFIX%%/sbin/nmbd -required_files=%%SAMBA_CONFDIR%%/smb.conf -pidfile=/var/run/nmbd.pid +if checkyesno samba_enable; then + nmbd_enable=${nmbd_enable:-"YES"} + smbd_enable=${smbd_enable:-"YES"} +%%WINBIND%% winbindd_enable=${winbindd_enable:-"YES"} +%%WINBIND%% # Check, that winbind is actally configured +%%WINBIND%% if [ ! "`egrep -i '(idmap.*uid|winbind.*uid)' ${samba_config} 2>/dev/null | egrep -v [\#\;]`" ]; then +%%WINBIND%% #warn "Winbind support is not configured" +%%WINBIND%% winbindd_enable="NO" +%%WINBIND%% fi +fi + +# Hack until run_rc_command() get rid of exit() +samba_stop() { + pid=$(check_pidfile ${pidfile} ${command}) + if [ -z ${pid} ]; then + echo "${name} not running? (check ${pidfile})." + return 1 + fi + echo "Stopping ${command}." + kill -${sig_stop:-TERM} ${pid} + [ $? -ne 0 ] && [ -z "$rc_force" ] && return 1 + wait_for_pids ${pid} +} -# set defaults +nmbd_precmd() { + # XXX: Never delete winbindd_idmap.tdb and winbindd_cache.tdb + if [ -d "%%SAMBA_SPOOL%%" ]; then + echo "Starting SAMBA: removing stale tdbs :" + for file in connections.tdb locking.tdb messages.tdb \ + sessionid.tdb unexpected.tdb brlock.tdb \ + namelist.debug + do + rm -vf "%%SAMBA_SPOOL%%/$file" + done + fi +} +# nmbd +name=nmbd +rcvar=`set_rcvar` +command="%%PREFIX%%/sbin/${name}" +required_dirs="%%SAMBA_SPOOL%%" +pidfile=%%SAMBA_RUNDIR%%/${name}.pid +start_precmd="nmbd_precmd" +stop_cmd="samba_stop" +# Defaults nmbd_enable=${nmbd_enable:-"NO"} nmbd_flags=${nmbd_flags:-"-D"} +command_args="${nmbd_flags} -s ${samba_config}" + load_rc_config $name run_rc_command "$1" -name=winbindd +# smbd +name=smbd rcvar=`set_rcvar` -command=%%PREFIX%%/sbin/winbindd -required_files=%%SAMBA_CONFDIR%%/smb.conf -pidfile=/var/run/winbindd.pid - -# set defaults +command="%%PREFIX%%/sbin/${name}" +pidfile=%%SAMBA_RUNDIR%%/${name}.pid +start_precmd=":" +stop_cmd="samba_stop" +# Defaults +smbd_enable=${smbd_enable:-"NO"} +smbd_flags=${smbd_flags:-"-D"} +command_args="${smbd_flags} -s ${samba_config}" -winbindd_enable=${winbindd_enable:-"NO"} -winbindd_flags=${winbindd_flags:-""} load_rc_config $name run_rc_command "$1" +%%WINBIND%% +%%WINBIND%%# winbindd +%%WINBIND%%name=winbindd +%%WINBIND%%rcvar=`set_rcvar` +%%WINBIND%%command="%%PREFIX%%/sbin/${name}" +%%WINBIND%%required_dirs="%%SAMBA_SPOOL%%" +%%WINBIND%%pidfile=%%SAMBA_RUNDIR%%/${name}.pid +%%WINBIND%%start_precmd=":" +%%WINBIND%%stop_cmd="samba_stop" +%%WINBIND%%# Defaults +%%WINBIND%%winbindd_enable=${winbindd_enable:-"NO"} +%%WINBIND%%winbindd_flags=${winbindd_flags:-""} +%%WINBIND%%command_args="${winbindd_flags} -s ${samba_config}" +%%WINBIND%% +%%WINBIND%%load_rc_config $name +%%WINBIND%%run_rc_command "$1" |