Debian Codegraph @

sbin/drbl-login-switch

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Steven Shiau <steven _at_ clonezilla org>
3 # Ceasar Sun <ceasar _at_ nchc org tw>
4 # License: GPL
5 # Description: To set the login mode for DRBL clients
6
7 # Load DRBL setting and functions
8 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
9
10 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
11
12 #
13 PWD_NO_0_1_MSG="Note!!! To avoid confusion, these random password does NOT contain digit 0 (zero) and digit 1 (one)!!!"
14
15 #
16 usagescip-shell shell shell-project 0.0.0 usage().() {
17 echoscip-shell system . . echo. "Switch the login mode for DRBL clients."
18 echoscip-shell system . . echo. "Usage: $0 [Options]"
19 echoscip-shell system . . echo. "Options:"
20 language_help_prompt_by_idx_no
21 echoscip-shell system . . echo. "-a, --auto: auto login for clients"
22 echoscip-shell system . . echo. "-g, --no-gen-ssi do NOT generate DRBL SSI template tarball."
23 echoscip-shell system . . echo. "-h, --host IP_ADDRESS: set login mode ony for the host with IP_ADDRESS instead of all DRBL clients"
24 echoscip-shell system . . echo. "-n, --normal: normal login for clients"
25 echoscip-shell system . . echo. "-t, --timed: timed login within time TIMED_LOGIN_TIME (sec)"
26 echoscip-shell system . . echo. "-p, --password_opt: the password option for auto and timed login."
27 echoscip-shell system . . echo. "-u, --no_nis_update: do NOT run NIS update"
28 echoscip-shell system . . echo. "-v, --verbose: verbose mode."
29 echoscip-shell system . . echo. "PASSWORD_OPT:"
30 echoscip-shell system . . echo. "If one digit, it's the length of randomly created password."
31 echoscip-shell system . . echo. "If more than one character, it's the password (i.e. if you enter \"drblclient\", then the password is \"drblclient\")."
32 echoscip-shell system . . echo. "If blank, it will be randomly generated with some (say:8) characters."
33 }
34
35 #
36 check_if_root
37
38 # Get the $GDM_CFG/$KDM_CFG filename
39 get_gdm_kdm_conf_filename
40
41 #
42 set_gdm_auto_loginscip-shell shell shell-project 0.0.0 set_gdm_auto_login().() {
43 # To config these two parameters:
44 # AutomaticLoginEnable=false/true
45 # AutomaticLogin=
46 local inode="$1"
47 local iauto_login_id="$2"
48 if [scip-shell system . . `[`. ! -f "$inode/$GDM_CFG" ]; then
49 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
50 echoscip-shell system . . echo. "GDM config in $inode NOT found, assume it's DRBL SSI mode!"
51 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
52 return 1
53 fi
54 # disable other types login (timed login) if exists
55 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginEnable=.*/TimedLoginEnable=false/" $inode/$GDM_CFG
56 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLogin=.*/TimedLogin=/" $inode/$GDM_CFG
57 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginDelay=.*/TimedLoginDelay=/" $inode/$GDM_CFG
58
59 # enable autologin
60 lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)"
61 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
62 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
63 chk_cmd="if ($begin_line..$end_line) {print}"
64 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$GDM_CFG | grepscip-shell system . . grep. -i "^AutomaticLoginEnable=")" ]; then
65 sub_cmd="if ($begin_line..$end_line) {s/^AutomaticLoginEnable=.*/AutomaticLoginEnable=true/}"
66 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
67 else
68 # insert 1 blank line
69 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
70 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
71 # replace the one we want in the added blank line
72 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/AutomaticLoginEnable=true/gi}"
73 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
74 fi
75 # put the autologin id
76 lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)"
77 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
78 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
79 chk_cmd="if ($begin_line..$end_line) {print}"
80 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$GDM_CFG | grepscip-shell system . . grep. -i "^AutomaticLogin=")" ]; then
81 sub_cmd="if ($begin_line..$end_line) {s/^AutomaticLogin=.*/AutomaticLogin=$iauto_login_id/}"
82 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
83 else
84 # insert 1 blank line
85 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
86 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
87 # replace the one we want in the added blank line
88 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/AutomaticLogin=$iauto_login_id/gi}"
89 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
90 fi
91 } # end of set_gdm_auto_login
92 #
93 set_gdm_timed_loginscip-shell shell shell-project 0.0.0 set_gdm_timed_login().() {
94 local inode="$1"
95 local iauto_login_id="$2"
96 local tlogin_time="$3"
97 if [scip-shell system . . `[`. ! -f $inode/$GDM_CFG ]; then
98 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
99 echoscip-shell system . . echo. "$inode/$GDM_CFG is NOT found!!! Assume it's DRBL SSI mode!"
100 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
101 return 1
102 fi
103 # set the timed login time
104 [scip-shell system . . `[`. -z "$tlogin_time" ] && tlogin_time="$TIMED_GDM_TIME_DEFAULT"
105 # disable other types login (auto login) if they exists
106 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLoginEnable=.*/AutomaticLoginEnable=false/" $inode/$GDM_CFG
107 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLogin=.*/AutomaticLogin=/" $inode/$GDM_CFG
108
109 # enable timed login
110 lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)"
111 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
112 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
113 chk_cmd="if ($begin_line..$end_line) {print}"
114 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$GDM_CFG | grepscip-shell system . . grep. -i "^TimedLoginEnable=")" ]; then
115 sub_cmd="if ($begin_line..$end_line) {s/^TimedLoginEnable=.*/TimedLoginEnable=true/}"
116 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
117 else
118 # insert 1 blank line
119 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
120 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
121 # replace the one we want in the added blank line
122 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLoginEnable=true/gi}"
123 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
124 fi
125 # put the timedlogin delay time
126 lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)"
127 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
128 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
129 chk_cmd="if ($begin_line..$end_line) {print}"
130 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$GDM_CFG | grepscip-shell system . . grep. -i "^TimedLoginDelay=")" ]; then
131 sub_cmd="if ($begin_line..$end_line) {s/^TimedLoginDelay=.*/TimedLoginDelay=$tlogin_time/}"
132 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
133 else
134 # insert 1 blank line
135 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
136 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
137 # replace the one we want in the added blank line
138 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLoginDelay=$tlogin_time/gi}"
139 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
140 fi
141 # put the timedlogin id
142 lines="$(get_block_line_in_gdm_kdm daemon $inode/$GDM_CFG)"
143 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
144 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
145 chk_cmd="if ($begin_line..$end_line) {print}"
146 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$GDM_CFG | grepscip-shell system . . grep. -i "^TimedLogin=")" ]; then
147 sub_cmd="if ($begin_line..$end_line) {s/^TimedLogin=.*/TimedLogin=$iauto_login_id/}"
148 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
149 else
150 # insert 1 blank line
151 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
152 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
153 # replace the one we want in the added blank line
154 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLogin=$iauto_login_id/gi}"
155 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$GDM_CFG
156 fi
157 } # end of set_gdm_timed_login
158 #
159 set_gdm_normal_loginscip-shell shell shell-project 0.0.0 set_gdm_normal_login().() {
160 local inode="$1"
161 if [scip-shell system . . `[`. ! -f $inode/$GDM_CFG ]; then
162 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
163 echoscip-shell system . . echo. "$inode/$GDM_CFG is NOT found!!! Assume it's DRBL SSI mode!"
164 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
165 return 1
166 fi
167 # disable auto and timed login, then it will be normal login since this is the default setting.
168 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLoginEnable=.*/AutomaticLoginEnable=false/" $inode/$GDM_CFG
169 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLogin=.*/AutomaticLogin=/" $inode/$GDM_CFG
170 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginEnable=.*/TimedLoginEnable=false/" $inode/$GDM_CFG
171 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLogin=.*/TimedLogin=/" $inode/$GDM_CFG
172 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginDelay=.*/TimedLoginDelay=/" $inode/$GDM_CFG
173 } # end of set_gdm_normal_login
174 #
175 set_lightdm_auto_loginscip-shell shell shell-project 0.0.0 set_lightdm_auto_login().() {
176 # To config these two parameters:
177 # autologin-user=<YOUR USER>
178 # autologin-user-timeout=0
179 local inode="$1"
180 local iauto_login_id="$2"
181 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" -a \
182 -d "$inode/etc/lightdm/lightdm.conf.d" ]; then
183 # For Ubuntu 13.10, lightdm 1.8.4 has different initial configration file.
184 # "/etc/lightdm/lightdm.conf" does not exist in the initial installation.
185 # While it will exist when a user configures that in the GUI.
186 # We create one here.
187 echoscip-shell system . . echo. "[SeatDefaults]" > $inode/$LIGHTDM_CFG
188 fi
189 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" ]; then
190 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
191 echoscip-shell system . . echo. "LightDM config in $inode NOT found, assume it's DRBL SSI mode!"
192 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
193 return 1
194 fi
195 # disable other types login (timed login) if exists
196 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user-timeout=.*/autologin-user-timeout=0/" $inode/$LIGHTDM_CFG
197
198 # put the autologin id
199 lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)"
200 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
201 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
202 chk_cmd="if ($begin_line..$end_line) {print}"
203 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grepscip-shell system . . grep. -i "^autologin-user=")" ]; then
204 sub_cmd="if ($begin_line..$end_line) {s/^autologin-user=.*/autologin-user=$iauto_login_id/}"
205 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
206 else
207 # insert 1 blank line
208 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
209 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
210 # replace the one we want in the added blank line
211 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/autologin-user=$iauto_login_id/gi}"
212 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
213 fi
214 } # end of set_lightdm_auto_login
215 #
216 set_lightdm_timed_loginscip-shell shell shell-project 0.0.0 set_lightdm_timed_login().() {
217 # //NOTE// Due to a bug, this /autologin-user-timeout=* actually won't work on Ubuntu 11.10 and 12.04.
218 # Ref: https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/902852
219 local inode="$1"
220 local iauto_login_id="$2"
221 local tlogin_time="$3"
222 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" -a \
223 -d "$inode/etc/lightdm/lightdm.conf.d" ]; then
224 # For Ubuntu 13.10, lightdm 1.8.4 has different initial configration file.
225 # "/etc/lightdm/lightdm.conf" does not exist in the initial installation.
226 # While it will exist when a user configures that in the GUI.
227 # We create one here.
228 echoscip-shell system . . echo. "[SeatDefaults]" > $inode/$LIGHTDM_CFG
229 fi
230 if [scip-shell system . . `[`. ! -f $inode/$LIGHTDM_CFG ]; then
231 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
232 echoscip-shell system . . echo. "$inode/$LIGHTDM_CFG is NOT found!!! Assume it's DRBL SSI mode!"
233 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
234 return 1
235 fi
236 # set the timed login time
237 [scip-shell system . . `[`. -z "$tlogin_time" ] && tlogin_time="$TIMED_LIGHTDM_TIME_DEFAULT"
238
239 # put the timedlogin delay time
240 lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)"
241 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
242 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
243 chk_cmd="if ($begin_line..$end_line) {print}"
244 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grepscip-shell system . . grep. -i "^autologin-user-timeout=")" ]; then
245 sub_cmd="if ($begin_line..$end_line) {s/^autologin-user-timeout=.*/autologin-user-timeout=$tlogin_time/}"
246 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
247 else
248 # insert 1 blank line
249 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
250 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
251 # replace the one we want in the added blank line
252 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/autologin-user-timeout=$tlogin_time/gi}"
253 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
254 fi
255 # put the timedlogin id
256 lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)"
257 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
258 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
259 chk_cmd="if ($begin_line..$end_line) {print}"
260 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grepscip-shell system . . grep. -i "^autologin-user=")" ]; then
261 sub_cmd="if ($begin_line..$end_line) {s/^autologin-user=.*/autologin-user=$iauto_login_id/}"
262 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
263 else
264 # insert 1 blank line
265 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
266 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
267 # replace the one we want in the added blank line
268 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/autologin-user=$iauto_login_id/gi}"
269 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
270 fi
271 # Append greeter-show-manual-login=true
272 tune_lightdm_manual_loginscip-shell shell shell-project 0.0.0 tune_lightdm_manual_login(). $inode true
273 } # end of set_lightdm_timed_login
274 #
275 tune_lightdm_manual_loginscip-shell shell shell-project 0.0.0 tune_lightdm_manual_login().() {
276 local inode="$1" # Path to $LIGHTDM_CFG
277 local manual_login_mode="$2" # true or false
278 # To config greeter-show-manual-login=true
279 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" ]; then
280 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
281 echoscip-shell system . . echo. "LightDM config in $inode NOT found, assume it's DRBL SSI mode!"
282 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
283 return 1
284 fi
285
286 # put the greeter-show-manual-login
287 end_line_of_file="$(LC_ALL=C wcscip-shell system . . wc. -l $inode/$LIGHTDM_CFG | awkscip-shell system . . awk. -F" " '{print $1}')"
288 lines="$(get_block_line_in_gdm_kdm SeatDefaults $inode/$LIGHTDM_CFG)"
289 # In Xenial, use [Seat:*] to replace with [SeatDefaults]. That's the reason to get "end_line_of_file first". By Ceasar
290 if [scip-shell system . . `[`. "$end_line_of_file" = "$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')" ]; then
291 lines="$(get_block_line_in_gdm_kdm 'Seat:\*' $inode/$LIGHTDM_CFG)"
292 fi
293 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
294 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
295 chk_cmd="if ($begin_line..$end_line) {print}"
296 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grepscip-shell system . . grep. -i "^greeter-show-manual-login=")" ]; then
297 sub_cmd="if ($begin_line..$end_line) {s/^greeter-show-manual-login=.*/greeter-show-manual-login=$manual_login_mode/}"
298 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
299 else
300 # insert 1 blank line
301 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
302 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
303 # replace the one we want in the added blank line
304 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/greeter-show-manual-login=$manual_login_mode/gi}"
305 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$LIGHTDM_CFG
306 fi
307 } # end of tune_lightdm_manual_login
308 #
309 set_lightdm_normal_loginscip-shell shell shell-project 0.0.0 set_lightdm_normal_login().() {
310 local inode="$1"
311 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" -a \
312 -d "$inode/etc/lightdm/lightdm.conf.d" ]; then
313 # For Ubuntu 13.10, lightdm 1.8.4 has different initial configration file.
314 # "/etc/lightdm/lightdm.conf" does not exist in the initial installation.
315 # While it will exist when a user configures that in the GUI.
316 # We create one here.
317 echoscip-shell system . . echo. "[SeatDefaults]" > $inode/$LIGHTDM_CFG
318 fi
319 if [scip-shell system . . `[`. ! -f $inode/$LIGHTDM_CFG ]; then
320 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
321 echoscip-shell system . . echo. "$inode/$LIGHTDM_CFG is NOT found!!! Assume it's DRBL SSI mode!"
322 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
323 return 1
324 fi
325 # disable auto and timed login, then it will be normal login since this is the default setting.
326 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user=.*/#autologin-user=/" $inode/$LIGHTDM_CFG
327 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user-timeout=.*/#autologin-user-timeout=/" $inode/$LIGHTDM_CFG
328 # Append greeter-show-manual-login=true
329 tune_lightdm_manual_loginscip-shell shell shell-project 0.0.0 tune_lightdm_manual_login(). $inode true
330 } # end of set_lightdm_normal_login
331 #
332 set_mdm_auto_loginscip-shell shell shell-project 0.0.0 set_mdm_auto_login().() {
333 local inode="$1"
334 local iauto_login_id="$2"
335 if [scip-shell system . . `[`. ! -f "$inode/$MDM_CFG" ]; then
336 echoscip-shell system . . echo. "[daemon]" > $inode/$MDM_CFG
337 fi
338 if [scip-shell system . . `[`. ! -f "$inode/$MDM_CFG" ]; then
339 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
340 echoscip-shell system . . echo. "LightDM config in $inode NOT found, assume it's DRBL SSI mode!"
341 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
342 return 1
343 fi
344 # disable other types login (timed login) if exists
345 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*TimedLoginEnable=.*/TimedLoginEnable=false/" $inode/$MDM_CFG
346
347 # put the autologin id
348 lines="$(get_block_line_in_gdm_kdm daemon $inode/$MDM_CFG)"
349 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
350 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
351 chk_cmd="if ($begin_line..$end_line) {print}"
352 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$MDM_CFG | grepscip-shell system . . grep. -i "^AutomaticLogin=")" ]; then
353 sub_cmd="if ($begin_line..$end_line) {s/^AutomaticLogin=.*/AutomaticLogin=$iauto_login_id/}"
354 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
355 else
356 # insert 2 blank line
357 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n\n/gi}"
358 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
359 # replace the one we want in the added blank line
360 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/AutomaticLogin=$iauto_login_id/gi}"
361 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
362 sub_cmd="if ($((end_line+2))..$((end_line+2))) {s/^$/AutomaticLoginEnable=true/gi}"
363 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
364
365 fi
366 } # end of set_mdm_auto_login
367 #
368 set_mdm_timed_loginscip-shell shell shell-project 0.0.0 set_mdm_timed_login().() {
369 local inode="$1"
370 local iauto_login_id="$2"
371 local tlogin_time="$3"
372 if [scip-shell system . . `[`. ! -f "$inode/$MDM_CFG" ]; then
373 echoscip-shell system . . echo. "[daemon]" > $inode/$MDM_CFG
374 fi
375 if [scip-shell system . . `[`. ! -f $inode/$MDM_CFG ]; then
376 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
377 echoscip-shell system . . echo. "$inode/$MDM_CFG is NOT found!!! Assume it's DRBL SSI mode!"
378 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
379 return 1
380 fi
381
382 # disable other types login (timed login) if exists
383 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutomaticLoginEnable=.*/AutomaticLoginEnable=false/" $inode/$MDM_CFG
384
385 # set the timed login time
386 [scip-shell system . . `[`. -z "$tlogin_time" ] && tlogin_time="$TIMED_LIGHTDM_TIME_DEFAULT"
387
388 # put the timedlogin delay time
389 lines="$(get_block_line_in_gdm_kdm daemon $inode/$MDM_CFG)"
390 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
391 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
392 chk_cmd="if ($begin_line..$end_line) {print}"
393 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$MDM_CFG | grepscip-shell system . . grep. -i "^TimedLoginDelay=")" ]; then
394 sub_cmd="if ($begin_line..$end_line) {s/^TimedLoginDelay=.*/TimedLoginDelay=$tlogin_time/}"
395 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
396 else
397 # insert 1 blank line
398 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
399 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
400 # replace the one we want in the added blank line
401 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLoginDelay=$tlogin_time/gi}"
402 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
403 fi
404 # put the timedlogin id
405 lines="$(get_block_line_in_gdm_kdm deamon $inode/$MDM_CFG)"
406 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
407 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
408 chk_cmd="if ($begin_line..$end_line) {print}"
409 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$MDM_CFG | grepscip-shell system . . grep. -i "^TimedLogin=")" ]; then
410 sub_cmd="if ($begin_line..$end_line) {s/^TimedLogin=.*/TimedLogin=$iauto_login_id/}"
411 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
412 else
413 # insert 2 blank line
414 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n\n/gi}"
415 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
416 # replace the one we want in the added blank line
417 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/TimedLogin=$iauto_login_id/gi}"
418 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
419 sub_cmd="if ($((end_line+2))..$((end_line+2))) {s/^$/TimedLoginEnable=true/gi}"
420 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
421 fi
422 # Append greeter-show-manual-login=true
423 tune_mdm_manual_loginscip-shell shell shell-project 0.0.0 tune_mdm_manual_login(). $inode true
424 } # end of set_mdm_timed_login
425 #
426 tune_mdm_manual_loginscip-shell shell shell-project 0.0.0 tune_mdm_manual_login().() {
427 local inode="$1" # Path to $LIGHTDM_CFG
428 local manual_login_mode="$2" # true or false
429 # To config greeter-show-manual-login=true
430 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" ]; then
431 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
432 echoscip-shell system . . echo. "LightDM config in $inode NOT found, assume it's DRBL SSI mode!"
433 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
434 return 1
435 fi
436
437 # put the greeter-show-manual-login
438 lines="$(get_block_line_in_gdm_kdm greeter $inode/$MDM_CFG)"
439 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
440 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
441 chk_cmd="if ($begin_line..$end_line) {print}"
442 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $inode/$LIGHTDM_CFG | grepscip-shell system . . grep. -i "^greeter-show-manual-login=")" ]; then
443 sub_cmd="if ($begin_line..$end_line) {s/^greeter-show-manual-login=.*/greeter-show-manual-login=$manual_login_mode/}"
444 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
445 else
446 # insert 1 blank line
447 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
448 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
449 # replace the one we want in the added blank line
450 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/greeter-show-manual-login=$manual_login_mode/gi}"
451 perlscip-shell system . . perl. -pi -e "$sub_cmd" $inode/$MDM_CFG
452 fi
453 } # end of tune_mdm_manual_login
454 #
455 set_mdm_normal_loginscip-shell shell shell-project 0.0.0 set_mdm_normal_login().() {
456 local inode="$1"
457 if [scip-shell system . . `[`. ! -f "$inode/$LIGHTDM_CFG" -a \
458 -d "$inode/etc/lightdm/lightdm.conf.d" ]; then
459 echoscip-shell system . . echo. "[SeatDefaults]" > $inode/$LIGHTDM_CFG
460 fi
461 if [scip-shell system . . `[`. ! -f $inode/$LIGHTDM_CFG ]; then
462 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
463 echoscip-shell system . . echo. "$inode/$LIGHTDM_CFG is NOT found!!! Assume it's DRBL SSI mode!"
464 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
465 return 1
466 fi
467 # disable auto and timed login, then it will be normal login since this is the default setting.
468 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user=.*/#autologin-user=/" $inode/$LIGHTDM_CFG
469 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*autologin-user-timeout=.*/#autologin-user-timeout=/" $inode/$LIGHTDM_CFG
470 # Append greeter-show-manual-login=true
471 tune_mdm_manual_loginscip-shell shell shell-project 0.0.0 tune_mdm_manual_login(). $inode true
472 } # end of set_mdm_normal_login
473 set_kdm_auto_loginscip-shell shell shell-project 0.0.0 set_kdm_auto_login().() {
474 local inode="$1"
475 if [scip-shell system . . `[`. ! -f "$inode/$KDM_CFG" ]; then
476 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
477 echoscip-shell system . . echo. "KDM config in $inode NOT found!!! Assume it's DRBL SSI mode!"
478 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
479 return 1
480 fi
481 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutoLoginEnable=.*/AutoLoginEnable=true/" $inode/$KDM_CFG
482 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*[[:space:]]*AutoLoginUser=.*/AutoLoginUser=$auto_login_id/" $inode/$KDM_CFG
483 } # end of set_kdm_auto_login
484 #
485 create_autologin_accountscip-shell shell shell-project 0.0.0 create_autologin_account().() {
486 # $create_account, $auto_login_id and $echo_no_digit_0_1 are global variables
487 local ihost="$1"
488 local shell_opt
489 get_autologin_account $ihost
490 # auto_login_id is got from get_autologin_account
491 [scip-shell system . . `[`. -z "$auto_login_id" ] && echoscip-shell system . . echo. "Unable to get $ip client's hostname! Skip this one!" && return 1
492 if ! grepscip-shell system . . grep. -q -E "^$auto_login_id:" /etc/passwdscip-shell filesystem . . `/etc/passwd`. ; then
493 # account $auto_login_id does not exists, create it.
494 create_account=1
495 # If /bin/bash is found, we try to se /bin/bash as default shell.
496 shell_opt=""
497 [scip-shell system . . `[`. -e /bin/bashscip-shell filesystem . . `/bin/bash`. ] && shell_opt="-s /bin/bash"
498 echoscip-shell system . . echo. -n "Creating account $auto_login_id... "
499 useraddscip-shell system . . useradd. -m $auto_login_id $shell_opt
500 fi
501
502 # set password when accounts are created (at that time the passwords are empty) or when password_opt is assigned
503 if [scip-shell system . . `[`. "$create_account" = "1" -o -n "$password_opt" ]; then
504 # clean the old file
505 clean_old_auto_login_id_passwd_filescip-shell shell shell-project 0.0.0 clean_old_auto_login_id_passwd_file(). $AUTO_LOGIN_ID_PASSWD $auto_login_id
506 # set the passwd
507 set_client_autologin_passwd=1
508 case "$password_opt" in
509 [0-9]|"")
510 echoscip-shell system . . echo. -n "The password_opt is set as \"$password_opt\". "
511 # echo the message $PWD_NO_0_1_MSG in the file $AUTO_LOGIN_ID_PASSWD
512 # if it does not exist.
513 if [scip-shell system . . `[`. -z "`grepscip-shell system . . grep. $PWD_NO_0_1_MSG $AUTO_LOGIN_ID_PASSWD 2>/dev/nullscip-shell filesystem . . `/dev/null`.`" ]; then
514 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
515 echoscip-shell system . . echo. $PWD_NO_0_1_MSG | teescip-shell system . . tee. -a $AUTO_LOGIN_ID_PASSWD
516 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
517 fi
518 echo_no_digit_0_1=1
519 # get one digit, so it must be the length of password
520 # or it's empty, we set it as $password_opt_default
521 if [scip-shell system . . `[`. -z "$password_opt" ]; then
522 echoscip-shell system . . echo. -n "You did NOT set the length of password, set it as $PASSWD_LENGTH_DEFAULT. "
523 password_opt="$PASSWD_LENGTH_DEFAULT"
524 fi
525 echoscip-shell system . . echo. -n "Generating random password from password length $password_opt... "
526 make_random_password $password_opt
527 passwd_now=$random_password
528 echoscip-shell system . . echo. "$auto_login_id:$passwd_now" | chpasswdscip-shell system . . chpasswd.
529 ;;
530 *)
531 echoscip-shell system . . echo. -n "Set password from input..."
532 passwd_now="$password_opt"
533 echoscip-shell system . . echo. "$auto_login_id:$passwd_now" | chpasswdscip-shell system . . chpasswd.
534 esac
535 echoscip-shell system . . echo. "$auto_login_id $passwd_now" >> $AUTO_LOGIN_ID_PASSWD
536 fi
537 } # end of create_autologin_account
538 #
539 clean_old_auto_login_id_passwd_filescip-shell shell shell-project 0.0.0 clean_old_auto_login_id_passwd_file().() {
540 local local_autologin_id_pwd_file="$1"
541 local local_auto_login_id="$2"
542 [scip-shell system . . `[`. -z "$local_auto_login_id" ] && echoscip-shell system . . echo. "Unable to get auto login id! Skip this one!" && return 1
543 # rename the old file, local_auto_login_id is a tag so that we will rename it just onece, not for every accounts.
544 if [scip-shell system . . `[`. -f "$local_autologin_id_pwd_file" ]; then
545 if grepscip-shell system . . grep. -q -E "\<$local_auto_login_id\>" $local_autologin_id_pwd_file; then
546 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
547 echoscip-shell system . . echo. "An existing file \"$local_autologin_id_pwd_file\" is found. Rename it as \"$local_autologin_id_pwd_file.drblsave\""
548 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
549 mvscip-shell system . . mv. -f $local_autologin_id_pwd_file ${local_autologin_id_pwd_file}.drblsave
550 fi
551 fi
552 } # end of clean_old_auto_login_id_passwd_file
553 #
554 output_result_and_update_ypscip-shell shell shell-project 0.0.0 output_result_and_update_yp().() {
555 # $create_account, $no_nis_update and $set_client_autologin_passwd are global variables
556 if [scip-shell system . . `[`. "$set_client_autologin_passwd" = "1" ]; then
557 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
558 echoscip-shell system . . echo. $msg_created_autologin_ID_passwd_file
559 #echo $PWD_NO_0_1_MSG | tee -a $AUTO_LOGIN_ID_PASSWD
560 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
561 # update the NIS
562 [scip-shell system . . `[`. "$no_nis_update" != "on" ] && makescip-shell system . . make. -C /var/ypscip-shell filesystem . . `/var/yp`.
563 fi
564 } # end of output_result_and_update_yp
565
566 ##############
567 ### MAIN ###
568 ##############
569 # set the flag for create account and echo prompt
570 # $create_account, $auto_login_id, $no_nis_update, $set_client_autologin_passwd and $echo_no_digit_0_1 are global variables
571 create_account=0
572 echo_no_digit_0_1=0
573 set_client_autologin_passwd=0
574
575 # If clonezilla box or drbl-ssi mode
576 [scip-shell system . . `[`. -f /etc/drbl/drbl_deploy.confscip-shell filesystem . . `/etc/drbl/drbl_deploy.conf`. ] && . /etc/drbl/drbl_deploy.confscip-shell source . . `/etc/drbl/drbl_deploy.conf`.
577 if [scip-shell system . . `[`. "$clonezilla_mode" = "clonezilla_box_mode" -o "$drbl_mode" = "drbl_ssi_mode" ]; then
578 gen_ssi="yes"
579 else
580 gen_ssi="no"
581 fi
582
583 while [scip-shell system . . `[`. $# -gt 0 ]; do
584 case "$1" in
585 -n|--normal)
586 shift; login_dm_mode="normal_login"
587 ;;
588 -a|--auto)
589 shift; login_dm_mode="auto_login"
590 ;;
591 -t|--timed)
592 shift; login_dm_mode="timed_login"
593 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
594 # skip the -xx option, in case
595 timed_login_time="$1"
596 shift
597 fi
598 ;;
599 -l|--language)
600 shift
601 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
602 # skip the -xx option, in case
603 specified_lang="$1"
604 shift
605 fi
606 ;;
607 -h|--host)
608 shift
609 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
610 # skip the -xx option, in case
611 specified_host="$1"
612 shift
613 fi
614 ;;
615 -g|--no-gen-ssi)
616 gen_ssi="no"
617 shift;;
618 -v|--verbose)
619 shift; verbose="on"
620 ;;
621 -u|--no_nis_update)
622 shift; no_nis_update="on"
623 ;;
624 -p|--password_opt)
625 shift
626 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
627 # skip the -xx option, in case
628 password_opt="$1"
629 shift
630 fi
631 ;;
632 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
633 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
634 exit 2 ;;
635 *) break ;;
636 esac
637 done
638
639 #
640 ask_and_load_lang_set $specified_lang
641
642 # check if the mode is set or net
643 [scip-shell system . . `[`. -z "$login_dm_mode" ] && usagescip-shell shell shell-project 0.0.0 usage(). && exit 1
644
645 #
646 if [scip-shell system . . `[`. -n "$specified_host" ]; then
647 [scip-shell system . . `[`. ! -d "$drblroot/$specified_host" ] && echoscip-shell system . . echo. "Can NOT find DRBL client $specified_host (i.e. no $drblroot/$specified_host)! Assume it's DRBL SSI client."
648 [scip-shell system . . `[`. -n "$verbose" ] && echoscip-shell system . . echo. "specified_host: $specified_host"
649 fi
650
651 # set the login option for GDM
652 [scip-shell system . . `[`. -n "$verbose" ] && echoscip-shell system . . echo. -n "The GDM login option: $login_dm_mode..."
653
654 # set the host to be processed
655 # host_list is the IP address of client, like 192.168.1.1...
656 host_list=""
657 if [scip-shell system . . `[`. -n "$specified_host" ]; then
658 # set the host path
659 host_list=$drblroot/$specified_host
660 else
661 # withoud specified_host, it must be all clients, append each one to $host_list
662 for ihost in `get-client-ip-list`; do
663 host_list="$host_list $drblroot/$ihost"
664 done
665 fi
666
667 RC=""
668 preferred="$(drbl-check-dm)"
669 RC=$?
670
671 [scip-shell system . . `[`. $RC -eq 0 ] && echoscip-shell system . . echo. "Display manager:\"$preferred\"..."
672
673 if [scip-shell system . . `[`. -z "$preferred" ]; then
674 echoscip-shell system . . echo. "No display manager was found!"
675 echoscip-shell system . . echo. "Skip changing client's login mode of graphical interface."
676 exit 3
677 fi
678
679 #
680 case "$preferred" in
681 gdm*)
682 for ihost in $host_list; do
683 echoscip-shell system . . echo. -n "Setting node `basenamescip-shell system . . basename. $ihost` as $login_dm_mode... "
684 case "$login_dm_mode" in
685 "auto_login"|"timed_login")
686 # create auto login account if necessary
687 create_autologin_accountscip-shell shell shell-project 0.0.0 create_autologin_account(). $ihost
688 # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only
689 [scip-shell system . . `[`. -f "$AUTO_LOGIN_ID_PASSWD" ] && chmodscip-shell system . . chmod. 600 $AUTO_LOGIN_ID_PASSWD
690 case "$login_dm_mode" in
691 "auto_login")
692 set_gdm_auto_loginscip-shell shell shell-project 0.0.0 set_gdm_auto_login(). $ihost $auto_login_id
693 ;;
694 "timed_login")
695 set_gdm_timed_loginscip-shell shell shell-project 0.0.0 set_gdm_timed_login(). $ihost $auto_login_id $timed_login_time
696 ;;
697 esac
698 echoscip-shell system . . echo. "done!"
699 ;;
700 "normal_login")
701 set_gdm_normal_loginscip-shell shell shell-project 0.0.0 set_gdm_normal_login(). $ihost
702 echoscip-shell system . . echo. "done!"
703 ;;
704 esac
705 done
706 # output result and update yp
707 output_result_and_update_ypscip-shell shell shell-project 0.0.0 output_result_and_update_yp().
708 ;;
709 kdm|mdkkdm)
710 # No timed_login for KDE... only auto_login or nornam_login
711 [scip-shell system . . `[`. "$login_dm_mode" = "timed_login" ] && echoscip-shell system . . echo. "No timed login for KDE... only auto login or normal login, so set it as auto login..."
712 for ihost in $host_list; do
713 echoscip-shell system . . echo. -n "Setting node `basenamescip-shell system . . basename. $ihost` as $login_dm_mode... "
714 case "$login_dm_mode" in
715 "auto_login"|"timed_login")
716 # create auto login account if necessary
717 create_autologin_accountscip-shell shell shell-project 0.0.0 create_autologin_account(). $ihost
718 # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only
719 [scip-shell system . . `[`. -f "$AUTO_LOGIN_ID_PASSWD" ] && chmodscip-shell system . . chmod. 600 $AUTO_LOGIN_ID_PASSWD
720 set_kdm_auto_loginscip-shell shell shell-project 0.0.0 set_kdm_auto_login(). $ihost
721 echoscip-shell system . . echo. "done!"
722 ;;
723 "normal_login")
724 [scip-shell system . . `[`. -f "$ihost/$SYSCONF_PATH/autologin" ] && rmscip-shell system . . rm. -f $ihost/$SYSCONF_PATH/autologin
725 echoscip-shell system . . echo. "done!"
726 ;;
727 esac
728 done
729 # output result and update yp
730 output_result_and_update_ypscip-shell shell shell-project 0.0.0 output_result_and_update_yp().
731 ;;
732 lightdm)
733 for ihost in $host_list; do
734 echoscip-shell system . . echo. -n "Setting node `basenamescip-shell system . . basename. $ihost` as $login_dm_mode... "
735 case "$login_dm_mode" in
736 "auto_login"|"timed_login")
737 # create auto login account if necessary
738 create_autologin_accountscip-shell shell shell-project 0.0.0 create_autologin_account(). $ihost
739 # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only
740 [scip-shell system . . `[`. -f "$AUTO_LOGIN_ID_PASSWD" ] && chmodscip-shell system . . chmod. 600 $AUTO_LOGIN_ID_PASSWD
741 case "$login_dm_mode" in
742 "auto_login")
743 set_lightdm_auto_loginscip-shell shell shell-project 0.0.0 set_lightdm_auto_login(). $ihost $auto_login_id
744 ;;
745 "timed_login")
746 set_lightdm_timed_loginscip-shell shell shell-project 0.0.0 set_lightdm_timed_login(). $ihost $auto_login_id $timed_login_time
747 ;;
748 esac
749 echoscip-shell system . . echo. "done!"
750 ;;
751 "normal_login")
752 set_lightdm_normal_loginscip-shell shell shell-project 0.0.0 set_lightdm_normal_login(). $ihost
753 echoscip-shell system . . echo. "done!"
754 ;;
755 esac
756 done
757 # output result and update yp
758 output_result_and_update_ypscip-shell shell shell-project 0.0.0 output_result_and_update_yp().
759 ;;
760 mdm)
761 for ihost in $host_list; do
762 echoscip-shell system . . echo. -n "Setting node `basenamescip-shell system . . basename. $ihost` as $login_dm_mode... "
763 case "$login_dm_mode" in
764 "auto_login"|"timed_login")
765 # create auto login account if necessary
766 create_autologin_accountscip-shell shell shell-project 0.0.0 create_autologin_account(). $ihost
767 # set the mode for $AUTO_LOGIN_ID_PASSWD as root access only
768 [scip-shell system . . `[`. -f "$AUTO_LOGIN_ID_PASSWD" ] && chmodscip-shell system . . chmod. 600 $AUTO_LOGIN_ID_PASSWD
769 case "$login_dm_mode" in
770 "auto_login")
771 set_mdm_auto_loginscip-shell shell shell-project 0.0.0 set_mdm_auto_login(). $ihost $auto_login_id
772 ;;
773 "timed_login")
774 set_mdm_timed_loginscip-shell shell shell-project 0.0.0 set_mdm_timed_login(). $ihost $auto_login_id $timed_login_time
775 ;;
776 esac
777 echoscip-shell system . . echo. "done!"
778 ;;
779 "normal_login")
780 set_mdm_normal_loginscip-shell shell shell-project 0.0.0 set_mdm_normal_login(). $ihost
781 echoscip-shell system . . echo. "done!"
782 ;;
783 esac
784 done
785 # output result and update yp
786 output_result_and_update_ypscip-shell shell shell-project 0.0.0 output_result_and_update_yp().
787 ;;
788 *)
789 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
790 echoscip-shell system . . echo. "Unknown display manager! This display manager \"$preferred\" is not supported by `basenamescip-shell system . . basename. $0`."
791 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
792 echoscip-shell system . . echo. "$msg_program_stop"
793 exit 1
794 ;;
795 esac
796
797 #
798 if [scip-shell system . . `[`. "$gen_ssi" = "yes" ]; then
799 echoscip-shell system . . echo. "-------------------------------------------------------"
800 echoscip-shell system . . echo. "Since some config files are modified in template client, creating template tarball for DRBL SSI..."
801 drbl-gen-ssi-files
802 fi