From 72cc0c82c415c872e270d924c795d6ac907a32fb Mon Sep 17 00:00:00 2001 From: Eloy Paris Date: Sun, 1 Jun 2003 04:30:13 +0000 Subject: Bringing packaging/Debian/ up to date with the current Samba package in Debian unstable. The stuff here was ages old... (This used to be commit 5646df8bfb327d74f9c07fc219023a5aecdbc70d) --- packaging/Debian/debian/samba.prerm | 93 ++++++++++--------------------------- 1 file changed, 24 insertions(+), 69 deletions(-) (limited to 'packaging/Debian/debian/samba.prerm') diff --git a/packaging/Debian/debian/samba.prerm b/packaging/Debian/debian/samba.prerm index acd6d087b5..6a4a8a4b4b 100644 --- a/packaging/Debian/debian/samba.prerm +++ b/packaging/Debian/debian/samba.prerm @@ -1,74 +1,29 @@ -#!/bin/sh -# -# Pre-removal script for the Samba package for Debian GNU/Linux. -# -# Written by Eloy A. Paris for the Debian project. -# - -DEBIAN_CONFIG=/etc/samba/debian_config - -NMBDPID=/var/state/samba/nmbd.pid -SMBDPID=/var/state/samba/smbd.pid - -# The most important thing the prerm script must do is to stop the Samba -# daemons (nmbd and smbd). Note that this can be tricky since Samba -# can be running from the inetd meta-daemon or as daemons (it's a -# user choice). - -# Before we stop Samba we need to know how it is running (from inetd -# or as daemons). We could source in the debian_config file but it -# is safer to grep /etc/inetd.conf. -if grep -q '^netbios-ns' /etc/inetd.conf; then - # Samba is running from inetd. We need to disable the Samba daemons - # in /etc/inetd.conf before we stop the daemons. Otherwise traffic - # in the NetBIOS ports will make inetd start them again. - # - # Note: user preferences regarding the mode he/she wants Samba to - # be run (inetd or daemons) will be lost next. In the postinst - # we depend on the information present in the debian_config - # file to restore everything back to the way it was. - update-inetd --disable netbios-ssn - update-inetd --disable netbios-ns - - # Now it is safe to stop the daemons... - - # I have just recalled that old versions of nmbd and smbd did not store - # their PID's in /var/samba/state/ (or whatever directory - # was used for this purpose in configure), so I can't use - # --pidfile in start-stop-daemon to stop nmbd or smbd. I - # will handle this by testing first whether the PID file exists. - if [ -f $NMBDPID ]; then - start-stop-daemon --stop --oknodo --user root --name nmbd --quiet --pidfile $NMBDPID - else - start-stop-daemon --stop --oknodo --user root --name nmbd --quiet - fi - - # nmbd must be dead by now, now it's smbd's turn - if [ -f $SMBDPID ]; then - start-stop-daemon --stop --oknodo --user root --name smbd --quiet --pidfile $SMBDPID - else - start-stop-daemon --stop --oknodo --user root --name smbd --quiet +#!/bin/sh -e + +# Clean up any such stale file. +rm -f /tmp/samba-was-not-running + +# The smbd pid file is missing, or points to a dead process +if [ ! -f /var/run/samba/smbd.pid ] || \ + ! ps h `cat /var/run/samba/smbd.pid` > /dev/null +then + # The nmbd pid file is missing, or points to a dead process + if [ -f /var/run/samba/nmbd.pid ] || \ + ! ps h `cat /var/run/samba/nmbd.pid` > /dev/null + then + # let the postinst know not to start samba. + [ "$1" = "upgrade" ] && touch /tmp/samba-was-not-running fi -elif [ -x /etc/init.d/samba ]; then # Old Samba packages didn't have a - # /etc/init.d/samba so we better - # check first. - # Samba is running as daemons. No problem here, just stop Samba... - /etc/init.d/samba stop fi -if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/samba ]; then - rm -f /usr/doc/samba -fi +# We call the init script to stop Samba, even if it only affects nmbd. +[ -x /etc/init.d/samba ] && /etc/init.d/samba stop -# Make sure there are no nmbd or smbd daemons running (security check) -# (as you see this code is commented out - so far I haven't had the need -# to do this sanity check - peloy, Aug. 23, 1998) -#ps -ax | grep nmbd -#if [ $? ... ]; then -# killall -9 nmbd -#fi +if [ "$1" = upgrade -a -n "$2" ] && dpkg --compare-versions "$2" lt 2.99 \ + && [ -e /var/lib/samba/passdb.tdb -a ! -e /etc/samba/smbpasswd ] +then + pdbedit -i tdbsam -e smbpasswd + rm -f /var/lib/samba/passdb.tdb +fi -#ps -ax | grep smbd -#if [ $? ... ]; then -# killall -9 smbd -#fi +#DEBHELPER# -- cgit