freebsd-ports/net/samba4/files/samba4.in
2013-07-09 15:30:00 +00:00

71 lines
1.9 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: samba4
# REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv ntpd
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
#samba4_enable="YES"
#
# Configuration file can be set with:
#samba4_config="%%SAMBA4_CONFDIR%%/%%SAMBA4_CONFIG%%"
#
. /etc/rc.subr
name="samba4"
rcvar=${name}_enable
load_rc_config "${name}"
# Defaults
samba4_enable=${samba4_enable:=NO}
samba4_flags=${samba4_flags=--daemon}
samba4_config_default="%%SAMBA4_CONFDIR%%/%%SAMBA4_CONFIG%%"
samba4_config=${samba4_config=${samba4_config_default}}
samba4_configfile_arg=${samba4_config:+--configfile="${samba4_config}"} #"
testparm_command="%%PREFIX%%/bin/samba-tool testparm --suppress-prompt --verbose ${samba4_configfile_arg}"
# Fetch parameters from configuration file
samba4_role=$(${testparm_command} --parameter-name='server role' 2>/dev/null)
samba4_lockdir=$(${testparm_command} --parameter-name='lock directory' 2>/dev/null)
samba4_piddir=$(${testparm_command} --parameter-name='pid directory' 2>/dev/null)
# Runtime options
start_precmd="samba4_prestart"
restart_precmd="samba4_checkconfig"
command_name="samba"
command="%%PREFIX%%/sbin/${command_name}"
command_args=${samba4_configfile_arg}
pidfile="%%SAMBA4_RUNDIR%%/${command_name}.pid"
# Requirements
required_files="${samba4_config}"
required_dirs="${samba4_lockdir}"
samba4_checkconfig() {
echo -n "Performing sanity check on Samba configuration: "
if ${testparm_command} >/dev/null 2>&1; then
echo "OK"
else
echo "FAILED"
return 1
fi
}
samba4_prestart() {
# Make sure we have our RUNDIR, even if it's on a tmpfs
if [ ! -d "${samba4_piddir}" -a ! -e "${samba4_piddir}" ]; then
install -m 0755 -d "${samba4_piddir}"
fi
# Remove smbd.pid before starting up samba(needed for s3fs)
if [ -e "${samba4_piddir}/smbd.pid" ] ; then
rm -f "${samba4_piddir}/smbd.pid"
fi
}
run_rc_command "$1"