1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

ctdb-scripts: add new 48.netbios script for starting nmbd

This change basically moves out nmbd references from 50.samba script to
a new 48.netbios script. Accordingly ctdb test scripts are tweaked to
cope with newly added script.

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Günther Deschner 2020-02-25 15:04:41 +01:00 committed by Martin Schwenke
parent f7fe6fa550
commit 26e1556819
9 changed files with 117 additions and 24 deletions

View File

@ -0,0 +1,64 @@
#!/bin/sh
# ctdb event script for Netbios Name Services
[ -n "$CTDB_BASE" ] || \
CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
. "${CTDB_BASE}/functions"
detect_init_style
case $CTDB_INIT_STYLE in
suse)
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
;;
debian)
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmbd}
;;
*)
# Use redhat style as default:
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
;;
esac
service_name="netbios"
load_script_options
ctdb_setup_state_dir "service" "$service_name"
service_start ()
{
# make sure nmbd is not already started
service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
killall -0 -q nmbd && {
sleep 1
# make absolutely sure nmbd is dead
killall -q -9 nmbd
}
# start Samba nmbd service. Start it reniced, as under very heavy load
# the number of smbd processes will mean that it leaves few cycles
# for anything else
nice_service "$CTDB_SERVICE_NMB" start || die "Failed to start nmbd"
}
service_stop ()
{
service "$CTDB_SERVICE_NMB" stop
}
###########################
case "$1" in
startup)
service_start
;;
shutdown)
service_stop
;;
esac
exit 0

View File

@ -11,16 +11,13 @@ detect_init_style
case $CTDB_INIT_STYLE in
suse)
CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmb}
;;
debian)
CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smbd}
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-nmbd}
;;
*)
# Use redhat style as default:
CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
;;
esac
@ -34,27 +31,14 @@ service_start ()
{
# make sure samba is not already started
service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
if [ -n "$CTDB_SERVICE_NMB" ] ; then
service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
fi
killall -0 -q smbd && {
sleep 1
# make absolutely sure samba is dead
killall -q -9 smbd
}
killall -0 -q nmbd && {
sleep 1
# make absolutely sure samba is dead
killall -q -9 nmbd
}
# start Samba service. Start it reniced, as under very heavy load
# the number of smbd processes will mean that it leaves few cycles
# for anything else
if [ -n "$CTDB_SERVICE_NMB" ] ; then
nice_service "$CTDB_SERVICE_NMB" start || die "Failed to start nmbd"
fi
nice_service "$CTDB_SERVICE_SMB" start || die "Failed to start samba"
}
@ -62,9 +46,6 @@ service_stop ()
{
service "$CTDB_SERVICE_SMB" stop
program_stack_traces "smbd" 5
if [ -n "$CTDB_SERVICE_NMB" ] ; then
service "$CTDB_SERVICE_NMB" stop
fi
}
######################################################################

View File

@ -241,12 +241,13 @@ CTDB_LVS_PUBLIC_IP
CTDB_MONITOR_MPDEVICES
# 31.clamd
CTDB_CLAMD_SOCKET
# 48.netbios
CTDB_SERVICE_NMB
# 49.winbind
CTDB_SERVICE_WINBIND
# 50.samba
CTDB_SAMBA_CHECK_PORTS
CTDB_SAMBA_SKIP_SHARE_CHECK
CTDB_SERVICE_NMB
CTDB_SERVICE_SMB
# 60.nfs
CTDB_NFS_CALLOUT

View File

@ -0,0 +1,14 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "shutdown, Debian init style"
setup
export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
ok <<EOF
Stopping nmbd: OK
EOF
simple_test

View File

@ -0,0 +1,14 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "shutdown, Debian init style"
setup
export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
ok <<EOF
Starting nmbd: OK
EOF
simple_test

View File

@ -10,6 +10,5 @@ export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
ok <<EOF
Stopping smbd: OK
Stopping nmbd: OK
EOF
simple_test

View File

@ -9,7 +9,6 @@ setup
export EVENTSCRIPT_TESTS_INIT_STYLE="debian"
ok <<EOF
Starting nmbd: OK
Starting smbd: OK
EOF
simple_test

View File

@ -0,0 +1,21 @@
setup ()
{
service_name="netbios"
if [ "$1" != "down" ] ; then
debug "Marking Netbios name services as up, listening and managed by CTDB"
# All possible service names for all known distros.
for i in "nmb" "nmbd" ; do
service "$i" force-started
done
else
debug "Marking Netbios name services as down, not listening and not managed by CTDB"
# All possible service names for all known distros.
for i in "nmb" "nmbd" ; do
service "$i" force-stopped
done
fi
}

View File

@ -7,7 +7,7 @@ setup ()
debug "Marking Samba services as up, listening and managed by CTDB"
# All possible service names for all known distros.
for i in "smb" "nmb" "samba" "smbd" "nmbd" ; do
for i in "smb" "samba" "smbd" ; do
service "$i" force-started
done
@ -21,7 +21,7 @@ setup ()
debug "Marking Samba services as down, not listening and not managed by CTDB"
# All possible service names for all known distros.
for i in "smb" "nmb" "samba" "smbd" "nmbd" ; do
for i in "smb" "samba" "smbd" ; do
service "$i" force-stopped
done