summaryrefslogtreecommitdiff
path: root/net/samba35/files/samba.in
diff options
context:
space:
mode:
Diffstat (limited to 'net/samba35/files/samba.in')
-rw-r--r--net/samba35/files/samba.in120
1 files changed, 71 insertions, 49 deletions
diff --git a/net/samba35/files/samba.in b/net/samba35/files/samba.in
index b2a679c19f37..94f70ff13b39 100644
--- a/net/samba35/files/samba.in
+++ b/net/samba35/files/samba.in
@@ -14,9 +14,9 @@
# to enable this service:
#
#samba_enable="YES"
-# or, for fine grain control:
-#nmbd_enable="YES"
-#smbd_enable="YES"
+# You can disable/enable any of the Samba daemons by specifying:
+#nmbd_enable="NO"
+#smbd_enable="NO"
%%WINBIND%%# You need to enable winbindd separately, by adding:
%%WINBIND%%#winbindd_enable="YES"
#
@@ -28,43 +28,6 @@
name="samba"
rcvar=samba_enable
-
-# Defaults
-samba_enable=${samba_enable:=NO}
-samba_config_default="%%SAMBA_CONFDIR%%/%%SAMBA_CONFIG%%"
-samba_config=${samba_config="${samba_config_default}"}
-command_args=${samba_config:+-s "${samba_config}"}
-# Fetch parameters from configuration file
-testparm_command="%%PREFIX%%/bin/testparm"
-smbcontrol_command="%%PREFIX%%/bin/smbcontrol"
-samba_parm="${testparm_command} -s -v --parameter-name"
-samba_idmap=$(${samba_parm} 'idmap uid' "${samba_config}" 2>/dev/null)
-samba_lockdir=$(${samba_parm} 'lock directory' "${samba_config}" 2>/dev/null)
-# Load configuration
-load_rc_config "${name}"
-# Setup dependent variables
-if [ -n "${rcvar}" ] && checkyesno "${rcvar}"; then
- nmbd_enable=${nmbd_enable=YES}
- smbd_enable=${smbd_enable=YES}
-%%WINBIND%% # Check that winbindd is actually configured
-%%WINBIND%% if [ -n "${samba_idmap}" ]; then
-%%WINBIND%% winbindd_enable=${winbindd_enable=YES}
-%%WINBIND%% fi
-fi
-# XXX: Hack to enable check of the dependent variables
-eval real_${rcvar}="\${${rcvar}:=NO}" ${rcvar}=YES
-%%WINBIND%%# winbindd
-%%WINBIND%%rcvar=winbindd_enable
-%%WINBIND%%winbindd_enable=${winbindd_enable:=NO}
-%%WINBIND%%winbindd_flags=${winbindd_flags=''}
-# nmbd
-rcvar=nmbd_enable
-nmbd_enable=${nmbd_enable:=NO}
-nmbd_flags=${nmbd_flags="-D"}
-# smbd
-rcvar=smbd_enable
-smbd_enable=${smbd_enable:=NO}
-smbd_flags=${smbd_flags="-D"}
# Custom commands
extra_commands="reload status"
start_precmd="samba_start_precmd"
@@ -75,16 +38,19 @@ restart_precmd="samba_checkconfig"
reload_precmd="samba_checkconfig"
reload_cmd="samba_reload_cmd"
rcvar_cmd="samba_rcvar_cmd"
+# Defaults
+samba_config_default="%%SAMBA_CONFDIR%%/%%SAMBA_CONFIG%%"
+testparm_command="%%PREFIX%%/bin/testparm"
+smbcontrol_command="%%PREFIX%%/bin/smbcontrol"
+samba_parm="${testparm_command} -s -v --parameter-name"
+pid_extra=
#
samba_daemons="nmbd smbd"
%%WINBIND%%samba_daemons="${samba_daemons} winbindd"
-# Requirements
-required_files="${samba_config}"
-required_dirs="${samba_lockdir}"
samba_checkconfig() {
echo -n "Performing sanity check on Samba configuration: "
- if ${testparm_command} -s ${samba_config:+"${samba_config}"} >/dev/null 2>&1; then
+ if ${testparm_command} -s ${samba_config:+"${samba_config}"} >/dev/null 2>&1; then #"
echo "OK"
else
echo "FAILED"
@@ -94,6 +60,10 @@ samba_checkconfig() {
}
samba_start_precmd() {
+ # Make sure rundir exists
+ if [ ! -d "%%SAMBA_RUNDIR%%" -a ! -e "%%SAMBA_RUNDIR%%" ]; then
+ install -m 0755 -d "%%SAMBA_RUNDIR%%"
+ fi
# XXX: Never delete winbindd_idmap, winbindd_cache and group_mapping
if [ -n "${samba_lockdir}" -a -d "${samba_lockdir}" ]; then
echo -n "Removing stale Samba tdb files: "
@@ -108,13 +78,19 @@ samba_start_precmd() {
}
samba_rcvar_cmd() {
- local rcvar
+ local name rcvar
rcvar=${name}_enable
- eval ${rcvar}=\${real_${rcvar}}
# Prevent recursive calling
unset "${rc_arg}_cmd" "${rc_arg}_precmd" "${rc_arg}_postcmd"
# Check master variable
run_rc_command "${_rc_prefix}${rc_arg}" ${rc_extra_args}
+ # Check dependent variables
+ for name in ${samba_daemons}; do
+ # XXX
+ rcvars=''; v=''
+ rcvar=${name}_enable
+ run_rc_command "${_rc_prefix}${rc_arg}" ${rc_extra_args}
+ done
}
samba_reload_cmd() {
@@ -123,7 +99,7 @@ samba_reload_cmd() {
unset "${rc_arg}_cmd" "${rc_arg}_precmd" "${rc_arg}_postcmd"
# Apply to all daemons
for name in ${samba_daemons}; do
- rcvar=${name}_enable
+ rcvar=${name}_enable
command="%%PREFIX%%/sbin/${name}"
pidfile="%%SAMBA_RUNDIR%%/${name}${pid_extra}.pid"
# Daemon should be enabled and running
@@ -150,19 +126,65 @@ samba_cmd() {
result=0
# Apply to all daemons
for name in ${samba_daemons}; do
- rcvar=${name}_enable
# XXX
rcvars=''; v=''
+ rcvar=${name}_enable
command="%%PREFIX%%/sbin/${name}"
pidfile="%%SAMBA_RUNDIR%%/${name}${pid_extra}.pid"
# Daemon should be enabled and running
if [ -n "${rcvar}" ] && checkyesno "${rcvar}"; then
run_rc_command "${_rc_prefix}${rc_arg}" ${rc_extra_args}
- # If any of the of the commands failed, take it as a total result
+ # If any of the commands failed, take it as a global result
result=$((${result} || $?))
fi
done
return ${result}
}
+samba_config_init() {
+ local name
+ # Load configuration
+ load_rc_config "${name}"
+ for name in ${samba_daemons}; do
+ load_rc_config "${name}"
+ done
+ # Location of the config
+ samba_config=${samba_config="${samba_config_default}"} #"
+ # XXX: Hack to work around name change of pid file with non-default config
+ if [ -n "${samba_config}" -a "${samba_config}" != "${samba_config_default}" ]; then
+ pid_extra="-$(basename "${samba_config}")"
+ fi
+ # Setup dependent variables
+ if [ -n "${rcvar}" ] && checkyesno "${rcvar}"; then
+ nmbd_enable=${nmbd_enable=YES}
+ smbd_enable=${smbd_enable=YES}
+ fi
+ # Defaults
+ samba_enable=${samba_enable:=NO}
+ nmbd_enable=${nmbd_enable:=NO}
+ smbd_enable=${smbd_enable:=NO}
+%%WINBIND%% # Winbindd
+%%WINBIND%% if [ -z "${winbind_enable}" ]; then
+%%WINBIND%% samba_idmap=$(${samba_parm} 'idmap uid' "${samba_config}" 2>/dev/null)
+%%WINBIND%% # Check that winbindd is actually configured
+%%WINBIND%% if [ -n "${samba_idmap}" ]; then
+%%WINBIND%% winbindd_enable="YES"
+%%WINBIND%% fi
+%%WINBIND%% winbindd_enable=${winbindd_enable:=NO}
+%%WINBIND%% fi
+}
+
+# Load configuration variables
+samba_config_init
+# Where is the lockdir
+samba_lockdir=$(${samba_parm} 'lock directory' "${samba_config}" 2>/dev/null)
+# Common flags
+command_args=${samba_config:+-s "${samba_config}"} #"
+nmbd_flags=${nmbd_flags="-D"}
+smbd_flags=${smbd_flags="-D"}
+%%WINBIND%%winbindd_flags=${winbindd_flags=''}
+# Requirements
+required_files="${samba_config}"
+required_dirs="${samba_lockdir}"
+
run_rc_command "$1"