Setting account policy values is done using -C, not -V. Fixes bug #120
[kai/samba.git] / packaging / Debian / debian / sambaconfig
1 #!/bin/sh
2 #
3 #       Written by Eloy A. Paris <peloy@debian.org> for Debian GNU/Linux.
4 #
5
6 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
7 DEBIAN_CONFIG=/etc/samba/debian_config
8
9 NMBDPID=/var/state/samba/nmbd.pid
10 SMBDPID=/var/state/samba/smbd.pid
11
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"
15         echo "Samba."
16         exit 1
17 fi
18
19 # Read current Samba configuration
20 . $DEBIAN_CONFIG
21
22 reload=1
23
24 while [ $# -gt 0 ]
25 do
26         case "$1" in
27                 --run-from-inetd)
28                         run_from_inetd=1
29                         shift
30                 ;;
31
32                 --run-as-daemons)
33                         run_from_inetd=0
34                         shift
35                 ;;
36                 --no-reload)
37                         reload=0
38                         shift
39                 ;;
40
41                 *)
42                         echo "Usage: $0 [--run-from-inetd|--run-as-daemons] [no-reload]" >&2
43                         exit 1
44                 ;;
45         esac
46 done
47
48 # Make sure there are no Samba daemons (nmbd or smbd) running
49 #
50
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
58 else
59         # Samba is running as daemons
60         /etc/init.d/samba stop
61 fi
62
63 if [ "x$run_from_inetd" = "x" ]
64 then
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] "
67
68         read mode
69         test -n "$mode" || mode="I"
70
71         case "$mode" in
72                 [Dd]*)
73                         run_from_inetd=0
74                 ;;
75
76                 *)
77                         run_from_inetd=1
78                 ;;
79         esac
80 fi
81
82 if [ "$run_from_inetd" = 1 ]; then
83         echo "Samba will run from inetd. Run sambaconfig to reconfigure."
84         echo ""
85         update-inetd --enable netbios-ssn
86         update-inetd --enable netbios-ns
87         run_mode="from_inetd"
88 else
89         echo "Samba will run as daemons. Run sambaconfig to reconfigure."
90         echo ""
91         update-inetd --disable netbios-ssn
92         update-inetd --disable netbios-ns
93         run_mode="as_daemons"
94 fi
95
96 # Rebuild Debian configuration file (only thing that could have
97 #       changed so far is the variable called "run_mode".
98
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
104
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."
114 else
115         echo -n "The --no-reload parameter was not provided, start Samba now? [Y/n] "
116         read yn
117         test -n "$yn" || yn="Y"
118
119         case "$yn" in
120                 [Nn]*)
121                         echo "Not started; to start later, do: /etc/init.d/samba start"
122                         echo -n "Press [ENTER] "
123                         read line
124                 ;;
125
126                 *)
127                         /etc/init.d/samba start
128                 ;;
129         esac
130 fi