[Samba] ctdb event script 50.samba does not start smbd
Davor Vusir
davortvusir at gmail.com
Fri Aug 15 12:29:42 MDT 2014
** Skickat från mobilusken! **
Den 15 aug 2014 16:58 skrev "steve" <steve at steve-ss.com>:
>
> On Fri, 2014-08-15 at 14:51 +0200, Davor Vusir wrote:
> > 2014-08-15 14:33 GMT+02:00 steve <steve at steve-ss.com>:
> > > On Fri, 2014-08-15 at 14:18 +0200, Davor Vusir wrote:
> > >> 2014-08-15 12:40 GMT+02:00 steve <steve at steve-ss.com>:
> > >> > Ubuntu 14.04. 2 node ctdb in an 4.1.11 AD domain with 4.1.11 member
> > >> > servers on each node. winbindd is present but nss and pam are
controlled
> > >> > by sssd. All OK, except that the event script which starts samba
is not
> > >> > working.
> > >> >
> > >> > smb.conf
> > >> > [global]
> > >> > workgroup = ALTEA
> > >> > realm = ALTEA.SITE
> > >> > security = ADS
> > >> > kerberos method = secrets and keytab
> > >> > netbios name = SMBCLUSTER
> > >> > clustering = Yes
> > >> > ctdbd socket = /usr/local/var/run/ctdb/ctdbd.socket
> > >>
> > >> 3. Add disable netbios = Yes
> > >>
> > >> > [users]
> > >> > path = /cluster/users
> > >> > read only = No
> > >> >
> > >> > starting ctdbd
> > >> > sudo ctdbd --dbdir=/usr/local/var/lib/ctdb
> > >> > --dbdir-persistent=/usr/local/var/lib/ctdb/persistent
> > >> > --event-script-dir=/usr/local/etc/ctdb/events.d
> > >> > --public-addresses=/usr/local/etc/ctdb/public_addresses
> > >> > --socket=/usr/local/var/run/ctdb/ctdbd.socket
--logfile=/var/log/syslog
> > >> >
> > >> > Here is the service script copied from the samba wiki. It is
installed
> > >> > chmod + x'd at /etc/init.d/smbd. It works fine manually:
> > >> >
> > >> > #!/bin/sh
> > >> > RUN_MODE="daemons"
> > >> > [ -r /etc/default/samba ] && . /etc/default/samba
> > >> > PIDDIR=/usr/local/samba/var/run
> > >> > NMBDPID=$PIDDIR/nmbd.pid
> > >> > SMBDPID=$PIDDIR/smbd.pid
> > >> > unset TMPDIR
> > >> > test -x /usr/local/samba/sbin/nmbd -a -x
/usr/local/samba/sbin/smbd ||
> > >> > exit
> > >> > . /lib/lsb/init-functions
> > >> > case "$1" in
> > >> > start)
> > >> > log_daemon_msg "Starting Samba daemons"
> > >> > install -o root -g root -m 755 -d $PIDDIR
> > >> > NMBD_DISABLED=`testparm -s
--parameter-name='disable
> > >> > netbios' 2>/dev/null`
> > >>
> > >> 3. Add disable netbios = Yes to smb.conf
> > >>
> > >> > if [ "$NMBD_DISABLED" != 'Yes' ]; then
> > >> > log_progress_msg "nmbd"
> > >> > if ! start-stop-daemon --start --quiet
--oknodo
> > >> > --exec /usr/local/samba/sbin/nmbd -- -D
> > >> > then
> > >> > log_end_msg 1
> > >> > exit 1
> > >> > fi
> > >> > fi
> > >> >
> > >> > if [ "$RUN_MODE" != "inetd" ]; then
> > >> > log_progress_msg "smbd"
> > >> > if ! start-stop-daemon --start --quiet
--oknodo
> > >> > --exec /usr/local/samba/sbin/smbd -- -D
> > >> > then
> > >> > log_end_msg 1
> > >> > exit 1
> > >> > fi
> > >> > fi
> > >> >
> > >> > log_end_msg 0
> > >> > ;;
> > >> > stop)
> > >> > log_daemon_msg "Stopping Samba daemons"
> > >> > log_progress_msg "nmbd"
> > >> >
> > >> > start-stop-daemon --stop --quiet --pidfile $NMBDPID
> > >> > sleep 1
> > >> > if [ -f $NMBDPID ] && ! ps h `cat $NMBDPID` >
/dev/null
> > >> > then
> > >> > rm -f $NMBDPID
> > >> > fi
> > >> >
> > >> > if [ "$RUN_MODE" != "inetd" ]; then
> > >> > log_progress_msg "smbd"
> > >> > start-stop-daemon --stop --quiet --pidfile
> > >> > $SMBDPID
> > >> > sleep 1
> > >> > if [ -f $SMBDPID ] && ! ps h `cat $SMBDPID`
> > >> >>/dev/null
> > >> > then
> > >> > rm -f $SMBDPID
> > >> > fi
> > >> > fi
> > >> >
> > >> > log_end_msg 0
> > >> >
> > >> > ;;
> > >> >
> > >> > reload)
> > >> > log_daemon_msg "Reloading
/usr/local/samba/etc/smb.conf"
> > >> > "smbd only"
> > >> >
> > >> > start-stop-daemon --stop --signal HUP --pidfile
$SMBDPID
> > >> >
> > >> > log_end_msg 0
> > >> > ;;
> > >> > restart|force-reload)
> > >> > $0 stop
> > >> > sleep 1
> > >> > $0 start
> > >> > ;;
> > >> > status)
> > >> > status="0"
> > >> > NMBD_DISABLED=`testparm -s
--parameter-name='disable
> > >> > netbios' 2>/dev/null`
> > >> > if [ "$NMBD_DISABLED" != "Yes" ]; then
> > >> > status_of_proc -p $NMBDPID
> > >> > /usr/local/samba/sbin/nmbd nmbd || status=$?
> > >> > fi
> > >> > if [ "$RUN_MODE" != "inetd" ]; then
> > >> > status_of_proc -p $SMBDPID
> > >> > /usr/local/samba/sbin/smbd smbd || status=$?
> > >> > fi
> > >> > if [ "$NMBD_DISABLED" = "Yes" -a "$RUN_MODE" =
"inetd"
> > >> > ];
> > >> > then
> > >> > status="4"
> > >> > fi
> > >> > exit $status
> > >> > ;;
> > >> > *)
> > >> > echo "Usage:
/etc/init.d/smbd{start|stop|reload|restart|
> > >> > force-reload|status}"
> > >> > exit 1
> > >> > ;;
> > >> > esac
> > >> > exit 0
> > >> >
> > >> > Here is the event script. We got as far as changing samba to smbd
for
> > >> > debian as we're on Ubuntu.
> > >> >
> > >> > /usr/local/etc/ctdb/events.d/50.samba (marked executable)
> > >> >
> > >> > #!/bin/sh
> > >> > # ctdb event script for Samba
> > >> >
> > >> > [ -n "$CTDB_BASE" ] || \
> > >> > export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
> > >> >
> > >> > . $CTDB_BASE/functions
> > >> >
> > >> > 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}
##changed to smbd here
> > >> >
What does CTDB_SERVICE_SMB expand to?
#CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
> > >> > ;;
> > >> > *)
> > >> > # Use redhat style as default:
> > >> > CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
> > >> > CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
> > >> > ;;
> > >> > esac
> > >> >
> > >> > service_name="samba"
> > >> >
Should this be renamed to smbd?
> > >> > loadconfig
> > >> >
> > >> > ctdb_setup_service_state_dir
> > >> >
> > >> > service_start ()
> > >> > {
> > >> > # make sure samba is not already started
> > >> > service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
> > >>
> > >> Is /etc/init.d/smbd a service start script?
> > > Yes.
> > >
> > It should be a link to /lib/init/upstart-job to be able to start by
> > typing 'service smbd start'. Not a regular file.
> Hi.
> I don't think that's it.
> /lib/init/upstart-job
> is a file which refers to /etc/default/upstart-job The latter does not
> exist.
>
> I just copied the init script from the samba wiki and made it
> executable:
> sudo service smbd <whatever>
> works fine.
>
> Any ideas?
> >
> > >
> > >>
> > >> > 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
> > >> > }
> > >>
> > >> --- comment this block ---
> > >> > 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
> > >> > net serverid wipe
> > >> >
> > >> > 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"
> > >> > }
> > >> >
> > >> > service_stop ()
> > >> > {
> > >> > service "$CTDB_SERVICE_SMB" stop
> > >> > if [ -n "$CTDB_SERVICE_NMB" ] ; then
> > >> > service "$CTDB_SERVICE_NMB" stop
> > >> > fi
> > >> > }
> > >> >
> > >> >
######################################################################
> > >> > # Show the testparm output using a cached smb.conf to avoid delays
due
> > >> > # to registry access.
> > >> >
> > >> > smbconf_cache="$service_state_dir/smb.conf.cache"
> > >> >
> > >> > testparm_foreground_update ()
> > >> > {
> > >> > _timeout="$1"
> > >> >
> > >> > if ! _out=$(timeout $_timeout testparm -v -s 2>/dev/null) ;
then
> > >> > if [ -f "$smbconf_cache" ] ; then
> > >> > echo "WARNING: smb.conf cache update failed - using
old cache file"
> > >> > return 1
> > >> > else
> > >> > die "ERROR: smb.conf cache create failed"
> > >> > fi
> > >> > fi
> > >> >
> > >> > _tmpfile="${smbconf_cache}.$$"
> > >> > # Patterns to exclude...
> > >> > pat='^[[:space:]]+(registry[[:space:]]+shares|include|copy|
> > >> > winbind[[:space:]]+separator)[[:space:]]+='
> > >> > echo "$_out" | grep -Ev "$pat" >"$_tmpfile"
> > >> > mv "$_tmpfile" "$smbconf_cache" # atomic
> > >> >
> > >> > return 0
> > >> > }
> > >> >
> > >> > testparm_background_update ()
> > >> > {
> > >> > _timeout="$1"
> > >> >
> > >> > testparm_foreground_update $_timeout >/dev/null 2>&1
</dev/null &
> > >> > }
> > >> >
> > >> > testparm_cat ()
> > >> > {
> > >> > testparm -s "$smbconf_cache" "$@" 2>/dev/null
> > >> > }
> > >> >
> > >> > list_samba_shares ()
> > >> > {
> > >> > testparm_cat |
> > >> > sed -n -e 's@^[[:space:]]*path[[:space:]]*=[[:space:]]@@p' |
> > >> > sed -e 's/"//g'
> > >> > }
> > >> >
> > >> > list_samba_ports ()
> > >> > {
> > >> > testparm_cat --parameter-name="smb ports" |
> > >> > sed -e 's@,@ @g'
> > >> > }
> > >> >
> > >> > ###########################
> > >> >
> > >> > ctdb_start_stop_service
> > >> >
> > >> > is_ctdb_managed_service || exit 0
> > >> >
> > >> > ###########################
> > >> >
> > >> > case "$1" in
> > >> > startup)
> > >> > ctdb_service_start
> > >> > ;;
> > >> >
> > >> > shutdown)
> > >> > ctdb_service_stop
> > >> > ;;
> > >> >
> > >> > monitor)
> > >> > testparm_foreground_update 10
> > >> > ret=$?
> > >> >
> > >> > smb_ports="$CTDB_SAMBA_CHECK_PORTS"
> > >> > if [ -z "$smb_ports" ] ; then
> > >> > smb_ports=$(list_samba_ports)
> > >> > [ -n "$smb_ports" ] || die "Failed to set smb ports"
> > >> > fi
> > >> > ctdb_check_tcp_ports $smb_ports || exit $?
> > >> >
> > >> > if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ] ; then
> > >> > list_samba_shares | ctdb_check_directories || exit $?
> > >> > fi
> > >> >
> > >> > if [ $ret -ne 0 ] ; then
> > >> > testparm_background_update 10
> > >> > fi
> > >> > ;;
> > >> >
> > >> > *)
> > >> > ctdb_standard_event_handler "$@"
> > >> > ;;
> > >> > esac
> > >> > exit 0
> > >> >
> > >> > We got as far as changing samba to smbd.
> > >> >
> > >> > 1. smbd is not started on calling ctdbd
> > >> > 2. What is supposed to happen to smbd when we start ctdb
> > >> > 3. What's the best way to stop nmbd starting? (we're in AD)
> > >>
> > >> 3. Add disable netbios = Yes to smb.conf
> > >
> > > OK, thanks. That's stopped nmbd. Any ideas on 1 and 2?
> >
> > 1) demands an upstart-job. When in place 2) should "just work".
> >
> > > Cheers,
> > > Steve
> > >
> > >
> > > --
> > > To unsubscribe from this list go to the following URL and read the
> > > instructions: https://lists.samba.org/mailman/options/samba
>
>
> --
> To unsubscribe from this list go to the following URL and read the
> instructions: https://lists.samba.org/mailman/options/samba
More information about the samba
mailing list