#!/bin/sh
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
DEBIAN_CONFIG=/etc/samba/debian_config
NMBDPID=/var/state/samba/nmbd.pid
SMBDPID=/var/state/samba/smbd.pid
if [ ! -f $DEBIAN_CONFIG ]; then
echo "The file $DEBIAN_CONFIG does not exist! There is something wrong"
echo "with the installation of Samba on this system. Please re-install"
echo "Samba."
exit 1
fi
. $DEBIAN_CONFIG
reload=1
while [ $do
case "$1" in
--run-from-inetd)
run_from_inetd=1
shift
;;
--run-as-daemons)
run_from_inetd=0
shift
;;
--no-reload)
reload=0
shift
;;
*)
echo "Usage: $0 [--run-from-inetd|--run-as-daemons] [no-reload]" >&2
exit 1
;;
esac
done
if [ "$run_mode" = "from_inetd" ]; then
update-inetd --disable netbios-ssn
update-inetd --disable netbios-ns
start-stop-daemon --stop --oknodo --user root --name nmbd --quiet --pidfile $NMBDPID
start-stop-daemon --stop --oknodo --user root --name smbd --quiet --pidfile $SMBDPID
else
/etc/init.d/samba stop
fi
if [ "x$run_from_inetd" = "x" ]
then
echo "Run Samba as daemons or from inetd?"
echo -n "Press 'D' for to run as daemons or 'I' to run from inetd: [I] "
read mode
test -n "$mode" || mode="I"
case "$mode" in
[Dd]*)
run_from_inetd=0
;;
*)
run_from_inetd=1
;;
esac
fi
if [ "$run_from_inetd" = 1 ]; then
echo "Samba will run from inetd. Run sambaconfig to reconfigure."
echo ""
update-inetd --enable netbios-ssn
update-inetd --enable netbios-ns
run_mode="from_inetd"
else
echo "Samba will run as daemons. Run sambaconfig to reconfigure."
echo ""
update-inetd --disable netbios-ssn
update-inetd --disable netbios-ns
run_mode="as_daemons"
fi
echo "config_version=$config_version" > $DEBIAN_CONFIG
echo "run_mode=$run_mode" >> $DEBIAN_CONFIG
echo "smbpasswd_created=$smbpasswd_created" >> $DEBIAN_CONFIG
if [ "$reload" = 0 ]; then
echo "Samba will not start (--no-reload parameter provided). Please note"
echo "that if you configured Samba to run from inetd, the Samba daemons"
echo "will start automatically when there is traffic in the NetBIOS ports"
elif [ "$run_from_inetd" = 1 ]; then
echo "The --no-reload parameter was not provided so I assume you want"
echo "to have the Samba daemons started. Since you are running from inetd"
echo "the Samba daemosn will start automatically when there is traffic"
echo "in the NetBIOS ports."
else
echo -n "The --no-reload parameter was not provided, start Samba now? [Y/n] "
read yn
test -n "$yn" || yn="Y"
case "$yn" in
[Nn]*)
echo "Not started; to start later, do: /etc/init.d/samba start"
echo -n "Press [ENTER] "
read line
;;
*)
/etc/init.d/samba start
;;
esac
fi