Debian Codegraph @

scripts/sbin/drbl-powerful-thin-client

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: To set the server so that client can run gdm/kdm remotely.
5
6 # Load DRBL setting and functions
7 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
8
9 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
10
11 #
12 check_if_root
13
14 # Get the $GDM_CFG/$KDM_CFG filename
15 get_gdm_kdm_conf_filename
16 if [scip-shell system . . `[`. -z "$GDM_CFG" -a -z "$KDM_CFG" ]; then
17 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
18 echoscip-shell system . . echo. "The GDM or KDM config file is NOT found! Skip setting the DM! Maybe you will not be able to make this DRBL server as thin client server!"
19 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
20 exit 1
21 fi
22
23 #
24 SERVER_INIT="5"
25
26 #
27 usagescip-shell shell shell-project 0.0.0 usage().() {
28 echoscip-shell system . . echo. "Description:"
29 echoscip-shell system . . echo. "Switch the DRBL clients to thin or powerful mode."
30 echoscip-shell system . . echo. "Usage: `basenamescip-shell system . . basename. $0` [-p|--powerful] [-t|--thin]"
31 echoscip-shell system . . echo. "-p, --powerful Powerful client"
32 echoscip-shell system . . echo. "-t, --thin Thin client"
33 echoscip-shell system . . echo. "-h, --hosts IP_LIST Instead of all DRBL clients, assign the clients by IP address, like: -h \"192.168.0.1 192.168.0.2\" NOTE!!! You must put \" \" before and after the IP_LIST!"
34 echoscip-shell system . . echo. "-g, --no-gen-ssi Do NOT generate DRBL SSI template tarball."
35 language_help_prompt_by_idx_no
36 language_help_prompt_by_idx_name
37 }
38 # option
39 while [scip-shell system . . `[`. $# -gt 0 ]; do
40 case "$1" in
41 -p|--powerful)
42 shift; xdmcp_mode="off"
43 ;;
44 -t|--thin)
45 shift; xdmcp_mode="on"
46 ;;
47 -h|--hosts)
48 shift;
49 LIST_HOST="on"
50 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
51 # skip the -xx option, in case
52 IP_LIST="$1"
53 fi
54 shift ;;
55 -g|--no-gen-ssi)
56 gen_ssi="no"
57 shift;;
58 -l|--language)
59 shift;
60 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
61 # skip the -xx option, in case
62 language_opt="$1"
63 fi
64 shift ;;
65 -ln)
66 shift;
67 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
68 # skip the -xx option, in case
69 language_opt="$1"
70 fi
71 shift ;;
72 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
73 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
74 exit 2 ;;
75 *) break ;;
76 esac
77 done
78
79 [scip-shell system . . `[`. -z "$xdmcp_mode" ] && usagescip-shell shell shell-project 0.0.0 usage(). && exit 1
80
81 #
82 ask_and_load_lang_set $language_opt
83
84 # function
85 clean_all_client_drblthincli_cfgscip-shell shell shell-project 0.0.0 clean_all_client_drblthincli_cfg().() {
86 # clean the drblthincli
87 findscip-shell system . . find. $drblroot/*/$SYSCONF_PATH/ -name drblthincli -exec rm -f {} \;
88 }
89
90 #
91 set_gdm_remote_accessscip-shell shell shell-project 0.0.0 set_gdm_remote_access().() {
92 action=$1
93 case "$action" in
94 "on")
95 # make sure inittab in the clients is runlevel 5, only in RH-like
96 [scip-shell system . . `[`. ! -f /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ] && switch_clients_init 5 $IP_LIST
97
98 # for server
99 if [scip-shell system . . `[`. -e "$GDM_CFG" ]; then
100 # Set DisallowTCP=false in $GDM_CFG
101 lines="$(get_block_line_in_gdm_kdm xdmcp $GDM_CFG)"
102 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
103 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
104 chk_cmd="if ($begin_line..$end_line) {print}"
105 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^DisallowTCP=")" ]; then
106 sub_cmd="if ($begin_line..$end_line) {s/^DisallowTCP=.*/DisallowTCP=false/}"
107 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
108 else
109 # insert 1 blank line
110 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
111 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
112 # replace the one we want in the added blank line
113 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/DisallowTCP=false/gi}"
114 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
115 fi
116 fi
117 if [scip-shell system . . `[`. -e "$FAC_GDM_CFG" ]; then
118 # Debian Etch does not have $FAC_GDM_CFG
119 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*DisallowTCP=.*/DisallowTCP=false/" $FAC_GDM_CFG
120 fi
121 #
122 lines=$(get_block_line_in_gdm_kdm xdmcp $GDM_CFG)
123 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
124 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
125 chk_cmd="if ($begin_line..$end_line) {print}"
126 # If we found the xdmcp in gdm.conf is "Enable=false", enable it.
127 # If the xdmcp setting is already on, we should not restart gdm if in graphic mode (runlevel 5 or dm is running)
128 # but If the xdmcp setting is already on, we should start gdm if in text mode (runlevel 3 or dm is NOT running)
129 if [scip-shell system . . `[`. -e /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ]; then
130 # Debian
131 default_dm="$(drbl-check-dm)"
132 pid_run="$(catscip-shell system . . cat. /var/run/${default_dm}.pid 2>/dev/nullscip-shell filesystem . . `/dev/null`.)"
133 if [scip-shell system . . `[`. -n "$(psscip-shell system . . ps. --pid $pid_run | grepscip-shell system . . grep. $default_dm 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" ]; then
134 srv_mode=graphic
135 else
136 srv_mode=text
137 fi
138 else
139 # RH-like or SUSE
140 RL=$(runlevel | awkscip-shell system . . awk. -F" " '{print $2}')
141 if [scip-shell system . . `[`. "$RL" = "5" ]; then
142 srv_mode=graphic
143 else
144 srv_mode=text
145 fi
146 fi
147 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^Enable=false")" ]; then
148 echoscip-shell system . . echo. "$msg_turn_on_gdm_remote_access"
149 sub_cmd="if ($begin_line..$end_line) {s/^Enable=.*/Enable=true/}"
150 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
151
152 # Ask user to restart gdm if necessary
153 [scip-shell system . . `[`. ! -f /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ] && perlscip-shell system . . perl. -p -i -e "s/^id:[1-5]:initdefault:/id:$SERVER_INIT:initdefault:/g" /etc/inittabscip-shell filesystem . . `/etc/inittab`.
154 if [scip-shell system . . `[`. "$srv_mode" = "graphic" ]; then
155 # alread in graphic mode, assume gdm is running.
156 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
157 echoscip-shell system . . echo. "$msg_logout_X_for_thin_client_gdm"
158 /usr/sbin/gdm-safe-restartscip-shell filesystem . . `/usr/sbin/gdm-safe-restart`.
159 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
160 else
161 # not in graphic mode, start gdm now
162 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
163 echoscip-shell system . . echo. "$msg_restart_graphic_mode_later"
164 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
165 fi
166 elif [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^Enable=true")" ]; then
167 echoscip-shell system . . echo. "$msg_gdm_remote_access_is_already_on"
168 # If the xdmcp setting is already on, we should start gdm if in runlevel 3
169 if [scip-shell system . . `[`. "$srv_mode" = "text" ]; then
170 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
171 echoscip-shell system . . echo. "$msg_restart_graphic_mode_later"
172 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
173 fi
174 else
175 # Empty, such as default custom.conf, we should insert Enable=true in $GDM_CFG
176 lines="$(get_block_line_in_gdm_kdm xdmcp $GDM_CFG)"
177 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
178 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
179 chk_cmd="if ($begin_line..$end_line) {print}"
180 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^Enable=")" ]; then
181 sub_cmd="if ($begin_line..$end_line) {s/^Enable=.*/Enable=true/}"
182 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
183 else
184 # insert 1 blank line
185 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
186 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
187 # replace the one we want in the added blank line
188 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/Enable=true/gi}"
189 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
190 fi
191 fi
192
193 # make the tag for client
194 echoscip-shell system . . echo. "$msg_set_thin_client_mode_for_clients"
195 for ihost in $drblroot/*; do
196 # skip those IP not listed in the $IP_LIST
197 if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then
198 [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $IP_LIST | grepscip-shell system . . grep. -E "\<${ihost##/*/}\>")" ] && continue
199 fi
200 echoscip-shell system . . echo. "Set system config DRBL_THIN_CLIENT=on for client ${ihost##/*/}"
201 echoscip-shell system . . echo. "DRBL_THIN_CLIENT=on" > $ihost/$SYSCONF_PATH/drblthincli
202 done
203 echoscip-shell system . . echo. "$msg_done !"
204 ;;
205
206 "off")
207 if [scip-shell system . . `[`. -e "$GDM_CFG" ]; then
208 # Set DisallowTCP=true in $GDM_CFG
209 lines="$(get_block_line_in_gdm_kdm xdmcp $GDM_CFG)"
210 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
211 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
212 chk_cmd="if ($begin_line..$end_line) {print}"
213 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^DisallowTCP=")" ]; then
214 sub_cmd="if ($begin_line..$end_line) {s/^DisallowTCP=.*/DisallowTCP=true/}"
215 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
216 else
217 # insert 1 blank line
218 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
219 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
220 # replace the one we want in the added blank line
221 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/DisallowTCP=true/gi}"
222 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
223 fi
224 fi
225 if [scip-shell system . . `[`. -e "$FAC_GDM_CFG" ]; then
226 # Debian Etch does not have $FAC_GDM_CFG
227 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*DisallowTCP=.*/DisallowTCP=true/" $FAC_GDM_CFG
228 fi
229 lines=$(get_block_line_in_gdm_kdm xdmcp $GDM_CFG)
230 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
231 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
232 chk_cmd="if ($begin_line..$end_line) {print}"
233 # If we found the xdmcp in gdm.conf is "Enable=true", disable it.
234 # If the xdmcp is already off, we should not restart gdm
235 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^Enable=true")" ]; then
236 echoscip-shell system . . echo. "$msg_turn_on_gdm_remote_access"
237 sub_cmd="if ($begin_line..$end_line) {s/^Enable=.*/Enable=false/}"
238 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
239
240 # Ask user to restart gdm if necessary
241 [scip-shell system . . `[`. ! -f /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ] && perlscip-shell system . . perl. -p -i -e "s/^id:[1-5]:initdefault:/id:$SERVER_INIT:initdefault:/g" /etc/inittabscip-shell filesystem . . `/etc/inittab`.
242 if [scip-shell system . . `[`. "$srv_mode" = "graphic" ]; then
243 # alread in graphic mode, assume gdm is running.
244 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
245 echoscip-shell system . . echo. "$msg_logout_X_for_thin_client_gdm"
246 /usr/sbin/gdm-safe-restartscip-shell filesystem . . `/usr/sbin/gdm-safe-restart`.
247 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
248 else
249 # not in graphic mode, start gdm now
250 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
251 echoscip-shell system . . echo. "$msg_restart_graphic_mode_later"
252 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
253 fi
254 elif [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^Enable=false")" ]; then
255 echoscip-shell system . . echo. "$msg_gdm_remote_access_is_already_off"
256 else
257 # Empty, such as default custom.conf, we should insert Enable=false in $GDM_CFG
258 lines="$(get_block_line_in_gdm_kdm xdmcp $GDM_CFG)"
259 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
260 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
261 chk_cmd="if ($begin_line..$end_line) {print}"
262 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $GDM_CFG | grepscip-shell system . . grep. -iE "^Enable=")" ]; then
263 sub_cmd="if ($begin_line..$end_line) {s/^Enable=.*/Enable=false/}"
264 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
265 else
266 # insert 1 blank line
267 sub_cmd="if ($((end_line))..$((end_line))) {s/^(.*)$/\$1\n/gi}"
268 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
269 # replace the one we want in the added blank line
270 sub_cmd="if ($((end_line+1))..$((end_line+1))) {s/^$/Enable=false/gi}"
271 perlscip-shell system . . perl. -pi -e "$sub_cmd" $GDM_CFG
272 fi
273 fi
274
275 # make a tag for not using thin client
276 echoscip-shell system . . echo. "$msg_disable_thin_client_mode_for_clients"
277 for ihost in $drblroot/*; do
278 # skip those IP not listed in the $IP_LIST
279 if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then
280 [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $IP_LIST | grepscip-shell system . . grep. -E "\<${ihost##/*/}\>")" ] && continue
281 fi
282
283 if [scip-shell system . . `[`. -d "$$ihost/$SYSCONF_PATH" ]; then
284 echoscip-shell system . . echo. "Set system config DRBL_THIN_CLIENT=off for client ${ihost##/*/}"
285 echoscip-shell system . . echo. "DRBL_THIN_CLIENT=off" > $ihost/$SYSCONF_PATH/drblthincli
286 fi
287 done
288 echoscip-shell system . . echo. "$msg_done !"
289 ;;
290 esac
291 }
292
293 set_kdm_remote_accessscip-shell shell shell-project 0.0.0 set_kdm_remote_access().() {
294 # no $FAC_GDM_CFG file for KDM
295 # and it seems no DisallowTCP in KDM_CFG, anyway, just set it if available
296 action=$1
297 case "$action" in
298 "on")
299 # make sure inittab in the clients is runlevel 5, only in RH-like
300 [scip-shell system . . `[`. ! -f /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ] && switch_clients_init 5 $IP_LIST
301
302 # for server
303 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*DisallowTCP=.*/DisallowTCP=false/" $KDM_CFG
304 lines=$(get_block_line_in_gdm_kdm xdmcp $KDM_CFG)
305 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
306 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
307 chk_cmd="if ($begin_line..$end_line) {print}"
308 # If we found the xdmcp in kdmrc is "Enable=false", enable it.
309 # If the xdmcp setting is already on, we should not restart kdm if in graphic mode (runlevel 5 or dm is running)
310 # but If the xdmcp setting is already on, we should start kdm if in text mode (runlevel 3 or dm is NOT running)
311 if [scip-shell system . . `[`. -e /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ]; then
312 # Debian
313 default_dm="$(drbl-check-dm)"
314 pid_run="$(catscip-shell system . . cat. /var/run/${default_dm}.pid 2>/dev/nullscip-shell filesystem . . `/dev/null`.)"
315 if [scip-shell system . . `[`. -n "$(psscip-shell system . . ps. --pid $pid_run | grepscip-shell system . . grep. $default_dm 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" ]; then
316 srv_mode=graphic
317 else
318 srv_mode=text
319 fi
320 else
321 # RH-like
322 RL=$(runlevel | awkscip-shell system . . awk. -F" " '{print $2}')
323 if [scip-shell system . . `[`. "$RL" = "5" ]; then
324 srv_mode=graphic
325 else
326 srv_mode=text
327 fi
328 fi
329 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $KDM_CFG | grepscip-shell system . . grep. "^Enable=false")" ]; then
330 echoscip-shell system . . echo. "$msg_turn_on_kdm_remote_access"
331 sub_cmd="if ($begin_line..$end_line) {s/^Enable=.*/Enable=true/}"
332 perlscip-shell system . . perl. -pi -e "$sub_cmd" $KDM_CFG
333
334 # Ask user to restart kdm if necessary
335 [scip-shell system . . `[`. ! -f /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ] && perlscip-shell system . . perl. -p -i -e "s/^id:[1-5]:initdefault:/id:$SERVER_INIT:initdefault:/g" /etc/inittabscip-shell filesystem . . `/etc/inittab`.
336 if [scip-shell system . . `[`. "$srv_mode" = "graphic" ]; then
337 # alread in graphic mode, assume kdm is running.
338 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
339 echoscip-shell system . . echo. "$msg_restart_X_for_thin_client_kdm"
340 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
341 else
342 # not in graphic mode, start gdm now
343 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
344 echoscip-shell system . . echo. "$msg_restart_graphic_mode_later"
345 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
346 fi
347 else
348 echoscip-shell system . . echo. "$msg_kdm_remote_access_is_already_on"
349 if [scip-shell system . . `[`. "$srv_mode" = "text" ]; then
350 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
351 echoscip-shell system . . echo. "$msg_restart_graphic_mode_later"
352 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
353 fi
354 fi
355
356 # make the tag for client
357 echoscip-shell system . . echo. "$msg_set_thin_client_mode_for_clients"
358 for ihost in $drblroot/*; do
359 # skip those IP not listed in the $IP_LIST
360 if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then
361 [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $IP_LIST | grepscip-shell system . . grep. -E "\<${ihost##/*/}\>")" ] && continue
362 fi
363
364 echoscip-shell system . . echo. "Set system config DRBL_THIN_CLIENT=on for client ${ihost##/*/}"
365 echoscip-shell system . . echo. "DRBL_THIN_CLIENT=on" > $ihost/$SYSCONF_PATH/drblthincli
366 done
367 echoscip-shell system . . echo. "$msg_done !"
368 ;;
369
370 "off")
371 perlscip-shell system . . perl. -p -i -e "s/^[[:space:]]*#*DisallowTCP=.*/DisallowTCP=true/" $KDM_CFG
372 lines=$(get_block_line_in_gdm_kdm xdmcp $KDM_CFG)
373 begin_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')
374 end_line=$(echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')
375 chk_cmd="if ($begin_line..$end_line) {print}"
376 # If we found the xdmcp in gdm.conf is "Enable=true", disable it.
377 # If the xdmcp is already off, we should not restart gdm
378 if [scip-shell system . . `[`. -n "$(perlscip-shell system . . perl. -n -e "$chk_cmd" $KDM_CFG | grepscip-shell system . . grep. "^Enable=true")" ]; then
379 echoscip-shell system . . echo. "$msg_turn_off_kdm_remote_access"
380 sub_cmd="if ($begin_line..$end_line) {s/^Enable=.*/Enable=false/}"
381 perlscip-shell system . . perl. -pi -e "$sub_cmd" $KDM_CFG
382
383 # Ask user to restart kdm if necessary
384 [scip-shell system . . `[`. ! -f /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ] && perlscip-shell system . . perl. -p -i -e "s/^id:[1-5]:initdefault:/id:$SERVER_INIT:initdefault:/g" /etc/inittabscip-shell filesystem . . `/etc/inittab`.
385 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
386 echoscip-shell system . . echo. "$msg_logout_X_for_modified_kdm_config_work"
387 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
388 else
389 echoscip-shell system . . echo. "$msg_kdm_remote_access_is_already_off"
390 fi
391
392 # make a tag for not using thin client
393 echoscip-shell system . . echo. "$msg_disable_thin_client_mode_for_clients"
394 for ihost in $drblroot/*; do
395 # skip those IP not listed in the $IP_LIST
396 if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then
397 [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $IP_LIST | grepscip-shell system . . grep. -E "\<${ihost##/*/}\>")" ] && continue
398 fi
399
400 echoscip-shell system . . echo. "Set system config DRBL_THIN_CLIENT=off for client ${ihost##/*/}"
401 echoscip-shell system . . echo. "DRBL_THIN_CLIENT=off" > $ihost/$SYSCONF_PATH/drblthincli
402 done
403 echoscip-shell system . . echo. "$msg_done !"
404 ;;
405 esac
406 }
407
408 RC=""
409 preferred="$(drbl-check-dm)"
410 if [scip-shell system . . `[`. "$preferred" = "gdm" -a -z "$GDM_CFG" ]; then
411 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
412 echoscip-shell system . . echo. "The GDM config file is NOT found! Skip setting the DM! Maybe you will not be able to make this DRBL server as thin client server!"
413 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
414 exit 1
415 fi
416 if [scip-shell system . . `[`. "$preferred" = "kdm" -a -z "$KDM_CFG" ]; then
417 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
418 echoscip-shell system . . echo. "The KDM config file is NOT found! Skip setting the DM! Maybe you will not be able to make this DRBL server as thin client server!"
419 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
420 exit 1
421 fi
422
423 RC=$?
424 [scip-shell system . . `[`. $RC -eq 0 ] && echoscip-shell system . . echo. "$msg_dm_in_DRBL_server \"$preferred\""
425
426 #
427 case "$preferred" in
428 gdm)
429 set_gdm_remote_accessscip-shell shell shell-project 0.0.0 set_gdm_remote_access(). $xdmcp_mode
430 ;;
431 kdm|mdkkdm)
432 set_kdm_remote_accessscip-shell shell shell-project 0.0.0 set_kdm_remote_access(). $xdmcp_mode
433 ;;
434 esac
435 #
436 if [scip-shell system . . `[`. "$gen_ssi" != "no" ]; then
437 echoscip-shell system . . echo. "-------------------------------------------------------"
438 echoscip-shell system . . echo. "Since some config files are modified in template client, creating template tarball for DRBL SSI..."
439 drbl-gen-ssi-files
440 fi