3 # Written by Eloy A. Paris <peloy@debian.org> for Debian GNU/Linux.
6 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
7 DEBIAN_CONFIG=/etc/samba/debian_config
9 NMBDPID=/var/state/samba/nmbd.pid
10 SMBDPID=/var/state/samba/smbd.pid
12 if [ ! -f $DEBIAN_CONFIG ]; then
13 echo "The file $DEBIAN_CONFIG does not exist! There is something wrong"
14 echo "with the installation of Samba on this system. Please re-install"
19 # Read current Samba configuration
42 echo "Usage: $0 [--run-from-inetd|--run-as-daemons] [no-reload]" >&2
48 # Make sure there are no Samba daemons (nmbd or smbd) running
51 if [ "$run_mode" = "from_inetd" ]; then
52 # Samba is running from inetd - need to disable inetd before
53 # killing the daemons.
54 update-inetd --disable netbios-ssn
55 update-inetd --disable netbios-ns
56 start-stop-daemon --stop --oknodo --user root --name nmbd --quiet --pidfile $NMBDPID
57 start-stop-daemon --stop --oknodo --user root --name smbd --quiet --pidfile $SMBDPID
59 # Samba is running as daemons
60 /etc/init.d/samba stop
63 if [ "x$run_from_inetd" = "x" ]
65 echo "Run Samba as daemons or from inetd?"
66 echo -n "Press 'D' for to run as daemons or 'I' to run from inetd: [I] "
69 test -n "$mode" || mode="I"
82 if [ "$run_from_inetd" = 1 ]; then
83 echo "Samba will run from inetd. Run sambaconfig to reconfigure."
85 update-inetd --enable netbios-ssn
86 update-inetd --enable netbios-ns
89 echo "Samba will run as daemons. Run sambaconfig to reconfigure."
91 update-inetd --disable netbios-ssn
92 update-inetd --disable netbios-ns
96 # Rebuild Debian configuration file (only thing that could have
97 # changed so far is the variable called "run_mode".
99 # Start the Samba daemons (take care of whether the user used the --no-reload
100 # option and how Samba is running: from inetd or as daemons)
101 echo "config_version=$config_version" > $DEBIAN_CONFIG
102 echo "run_mode=$run_mode" >> $DEBIAN_CONFIG
103 echo "smbpasswd_created=$smbpasswd_created" >> $DEBIAN_CONFIG
105 if [ "$reload" = 0 ]; then
106 echo "Samba will not start (--no-reload parameter provided). Please note"
107 echo "that if you configured Samba to run from inetd, the Samba daemons"
108 echo "will start automatically when there is traffic in the NetBIOS ports"
109 elif [ "$run_from_inetd" = 1 ]; then
110 echo "The --no-reload parameter was not provided so I assume you want"
111 echo "to have the Samba daemons started. Since you are running from inetd"
112 echo "the Samba daemosn will start automatically when there is traffic"
113 echo "in the NetBIOS ports."
115 echo -n "The --no-reload parameter was not provided, start Samba now? [Y/n] "
117 test -n "$yn" || yn="Y"
121 echo "Not started; to start later, do: /etc/init.d/samba start"
122 echo -n "Press [ENTER] "
127 /etc/init.d/samba start