| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Authors: Steven Shiau <steven _at_ clonezilla org> and Blake, Kuo-Lien Huang <klhaung _at_ gmail.com>, and Ceasar Sun <ceasar _at_ nchc org tw> |
| 3 | # License: GPL |
| 4 | # Description: DRBL utitilty to switch the mode for clients. |
| 5 | |
| 6 | # To use reboot, shutdown, wake-on-lan for Cygwin clients, you must put the |
| 7 | # ssh key to those Cygwin clients. |
| 8 | |
| 9 | DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" |
| 10 | |
| 11 | . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions |
| 12 | [scip-shell system . . `[`. -e /etc/drbl/drbl-ocs.confscip-shell filesystem . . `/etc/drbl/drbl-ocs.conf`. ] && . /etc/drbl/drbl-ocs.confscip-shell source . . `/etc/drbl/drbl-ocs.conf`. |
| 13 | [scip-shell system . . `[`. -e $DRBL_SCRIPT_PATH/sbin/ocs-functions ] && . $DRBL_SCRIPT_PATH/sbin/ocs-functions |
| 14 | |
| 15 | # Load the preset mode |
| 16 | # we need to know $drbl_ssi_mode... |
| 17 | [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`. |
| 18 | |
| 19 | # Load the config in ocs-live.conf. This is specially for DRBL/Clonezilla live. It will overwrite some settings of drbl-ocs.conf, such as $DIA... |
| 20 | [scip-shell system . . `[`. -e "/etc/ocs/ocs-live.confscip-shell filesystem . . `/etc/ocs/ocs-live.conf`." ] && . /etc/ocs/ocs-live.confscip-shell source . . `/etc/ocs/ocs-live.conf`. |
| 21 | |
| 22 | # |
| 23 | # DIA (="dialog") is loaded from drbl.conf |
| 24 | MAX_DIALOG_HEIGHT="12" |
| 25 | |
| 26 | # |
| 27 | check_if_root |
| 28 | |
| 29 | check_if_run_in_drbl_server $0 |
| 30 | |
| 31 | # get the OS_Version and OS_type |
| 32 | check_distribution_name |
| 33 | |
| 34 | # load user's default setting |
| 35 | [scip-shell system . . `[`. -e "$HOME/.dcsrc" ] && . $HOME/.dcsrc |
| 36 | |
| 37 | # function |
| 38 | USAGEscip-shell shell shell-project 0.0.0 USAGE().() { |
| 39 | echoscip-shell system . . echo. "Usage: $0 [OPTION] MODE [MODE2]" |
| 40 | echoscip-shell system . . echo. "OPTION" |
| 41 | language_help_prompt_by_idx_no |
| 42 | echoscip-shell system . . echo. "-h, --host [IP_LIST|MAC_LIST] Instead of all DRBL clients, assign some DRBL clients (IP_LIST or MAC_LIST) to be processed, if IP_LIST or MAC_LIST is not set, a dialog menu will be shown so that the target DRBL client(s) can be selected. The IP_LIST is like: \"192.168.0.1 192.168.0.2\", and the MAC_LIST is like \"00:50:56:01:02:01 00:50:56:01:02:02\". NOTE!!! You must put \" \" before and after the IP_LIST or MAC_LIST!" |
| 43 | echoscip-shell system . . echo. "-nl, --no-list-host Set all clients' mode (This is default)" |
| 44 | dialog_like_prog_help_prompt |
| 45 | echoscip-shell system . . echo. "MODE:" |
| 46 | echoscip-shell system . . echo. "remote-linux-gra Client machine will boot from DRBL server," |
| 47 | echoscip-shell system . . echo. " and enter graphic mode. For powerful client." |
| 48 | echoscip-shell system . . echo. "remote-linux-txt Client machine will boot from DRBL server," |
| 49 | echoscip-shell system . . echo. " and enter text mode. For powerful client." |
| 50 | echoscip-shell system . . echo. "terminal Remote display Linux, terminal mode." |
| 51 | echoscip-shell system . . echo. "remote-memtest Remote boot to run memtest86" |
| 52 | echoscip-shell system . . echo. "remote-fdos Remote boot to run FreeDOS" |
| 53 | echoscip-shell system . . echo. "clonezilla-start Start Clonezilla mode" |
| 54 | echoscip-shell system . . echo. "clonezilla-stop Stop the Clonezilla mode" |
| 55 | echoscip-shell system . . echo. "local Client machine will boot from local (now PXE only)" |
| 56 | echoscip-shell system . . echo. "reboot Reboot DRBL clients now" |
| 57 | echoscip-shell system . . echo. "shutdown Shutdown DRBL clients now" |
| 58 | echoscip-shell system . . echo. "Wake-on-LAN Turn on DRBL clients by Wake-on-LAN now" |
| 59 | echoscip-shell system . . echo. "netinstall Let clients to install Linux distribution via network (PXE/etherboot)" |
| 60 | echoscip-shell system . . echo. |
| 61 | echoscip-shell system . . echo. "MODE2:" |
| 62 | echoscip-shell system . . echo. "Based on MODE, assign the 2nd level mode:" |
| 63 | echoscip-shell system . . echo. "For MODE=clonezilla-start, available MODE2:" |
| 64 | echoscip-shell system . . echo. "save-disk: Clonezilla save disk mode" |
| 65 | echoscip-shell system . . echo. "restore-disk: Clonezilla restore disk Mode" |
| 66 | echoscip-shell system . . echo. "save-parts: Clonezilla save partitions mode" |
| 67 | echoscip-shell system . . echo. "restore-parts: Clonezilla restore partitions mode" |
| 68 | echoscip-shell system . . echo. "select-in-client: Select mode in client" |
| 69 | echoscip-shell system . . echo. "For MODE=more, available MODE2:" |
| 70 | echoscip-shell system . . echo. "switch-pxe-menu Switch DRBL client menus" |
| 71 | echoscip-shell system . . echo. "switch-pxe-bg-mode Switch PXE Linux background" |
| 72 | echoscip-shell system . . echo. "drbl-mode Switch diskless linux mode" |
| 73 | echoscip-shell system . . echo. "clonezilla-mode Switch Clonezilla mode" |
| 74 | echoscip-shell system . . echo. "login-switch Switch DRBL client login mode" |
| 75 | echoscip-shell system . . echo. "switch-drbl-serv Start, stop or restart DRBL related services in DRBL server" |
| 76 | echoscip-shell system . . echo. "client-reautologin Force to restart client autologin" |
| 77 | echoscip-shell system . . echo. "clean-autologin-account Delete all autologin accounts" |
| 78 | echoscip-shell system . . echo. "re-deploy Re-deploy files to clients, i.e. update the files of server to clients." |
| 79 | echoscip-shell system . . echo. "clean-dhcpd-lease Force to reset DHCP IP address leases" |
| 80 | echoscip-shell system . . echo. |
| 81 | echoscip-shell system . . echo. "If no argument is specified, a dialog will appear to let you choose the mode!" |
| 82 | echoscip-shell system . . echo. |
| 83 | echoscip-shell system . . echo. "EXAMPLE" |
| 84 | echoscip-shell system . . echo. " To turn off the local and memtest boot menues of clients, run:" |
| 85 | echoscip-shell system . . echo. " $0 -nl more switch-pxe-menu '-i local -i memtest hide'" |
| 86 | echoscip-shell system . . echo. " To switch client's PXE boot menu as graphic mode, run:" |
| 87 | echoscip-shell system . . echo. " $0 -nl more switch-pxe-bg-mode graphic" |
| 88 | echoscip-shell system . . echo. " To restart drbl-related service, run:" |
| 89 | echoscip-shell system . . echo. " $0 -nl more switch-drbl-serv restart" |
| 90 | } # Endo of USAGE |
| 91 | |
| 92 | # function : stop_ocs |
| 93 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary().() { |
| 94 | # $IP_LIST and $OCS_OPTS are global variables |
| 95 | # if "LIST_HOST" is NOT nothing, we will process those clients... use the |
| 96 | # -h parameter of drbl-ocs. |
| 97 | local host_opt |
| 98 | if [scip-shell system . . `[`. -f "$ocs_lock_dir/clonezilla.lock" ]; then |
| 99 | echoscip-shell system . . echo. "Your system is already in Clonezilla mode... we will stop it first, then change to other mode..." |
| 100 | if [scip-shell system . . `[`. -n "$IP_LIST" ]; then |
| 101 | host_opt="-h \"$IP_LIST\"" |
| 102 | fi |
| 103 | drbl-ocs -n $OCS_OPTS $host_opt -l $lang stop |
| 104 | fi |
| 105 | } # end of stop_ocs_if_necessary |
| 106 | |
| 107 | # |
| 108 | mcast_clonezilla_restore_not_for_all_clients_warningscip-shell shell shell-project 0.0.0 mcast_clonezilla_restore_not_for_all_clients_warning().() { |
| 109 | $DIA --title "$msg_multicast_clonezilla_warning" --clear \ |
| 110 | --msgbox "$msg_multicast_clonezilla_warning_des" 0 0 |
| 111 | } |
| 112 | |
| 113 | # |
| 114 | ask_if_want_list_hostscip-shell shell shell-project 0.0.0 ask_if_want_list_host().() { |
| 115 | local TMP mode |
| 116 | if [scip-shell system . . `[`. -z "$dcs_choose_client" ]; then |
| 117 | TMP=$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.) |
| 118 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 119 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 120 | "$msg_nchc_drbl" --menu "$msg_hint_multiple_choice_select_by_space \n$msg_select_all_clients_or_select_part_them \n$msg_choose_mode:" \ |
| 121 | 0 0 0 \ |
| 122 | "All" "$msg_select_all_clients" \ |
| 123 | "Part" "$msg_select_clients" \ |
| 124 | 2> $TMP |
| 125 | dcs_choose_client="$(catscip-shell system . . cat. $TMP)" |
| 126 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 127 | fi |
| 128 | case "$dcs_choose_client" in |
| 129 | All) |
| 130 | LIST_HOST="off";; |
| 131 | Part) |
| 132 | LIST_HOST="on";; |
| 133 | *) |
| 134 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 135 | echoscip-shell system . . echo. "$msg_program_stop!" |
| 136 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 137 | exit 1 |
| 138 | esac |
| 139 | } # end of ask_if_want_list_host |
| 140 | # |
| 141 | ask_if_input_save_image_name_in_serverscip-shell shell shell-project 0.0.0 ask_if_input_save_image_name_in_server().() { |
| 142 | local save_type=$1 |
| 143 | local TMP mode ans_ |
| 144 | if [scip-shell system . . `[`. -z "$dcs_input_img_name" ]; then |
| 145 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 146 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 147 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 148 | "$msg_nchc_clonezilla | $msg_mode: $ocs_mode_prompt" --menu "$msg_title_input_save_image_name_in_server \n$msg_ask_if_input_save_image_name_in_server \n$msg_choose_mode:" \ |
| 149 | 0 0 0 \ |
| 150 | "Now_in_server" "$msg_now_input_in_server" \ |
| 151 | "Later_in_client" "$msg_later_input_in_client" \ |
| 152 | 2> $TMP |
| 153 | dcs_input_img_name="$(catscip-shell system . . cat. $TMP)" |
| 154 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 155 | fi |
| 156 | |
| 157 | # Check input option |
| 158 | case "$dcs_input_img_name" in |
| 159 | "Now_in_server"|"Later_in_client") truescip-shell system . . true.;; |
| 160 | *) |
| 161 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 162 | echoscip-shell system . . echo. "\"$dcs_input_img_name\" is an unknown or unsupported mode! You must assign a correct option for dcs_input_img_name!" |
| 163 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 164 | echoscip-shell system . . echo. "$msg_program_stop!" |
| 165 | exit 1 |
| 166 | ;; |
| 167 | esac |
| 168 | |
| 169 | if [scip-shell system . . `[`. "$dcs_input_img_name" = "Now_in_server" ]; then |
| 170 | local ANS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_ans.XXXXXXscip-shell filesystem . . `/tmp/ocs_ans.XXXXXX`.` |
| 171 | local ASK_IMG_NAME=1 |
| 172 | trap "[ -f "$ANS_TMP" ] && rm -f $ANS_TMP" HUP INT QUIT TERM EXIT |
| 173 | while [scip-shell system . . `[`. "$ASK_IMG_NAME" -ne 0 ]; do |
| 174 | get_input_image_name $ANS_TMP |
| 175 | input_save_img_name="$(catscip-shell system . . cat. $ANS_TMP)" |
| 176 | if [scip-shell system . . `[`. "$input_save_img_name" = "ask_user" ]; then |
| 177 | $DIA --backtitle "$msg_nchc_free_software_labs" --title "$msg_nchc_clonezilla | $msg_mode: $ocs_mode_prompt" \ |
| 178 | --msgbox "$msg_ask_user_is_reserved_for_save_mode\n$msg_please_do_it_again!!!" 0 0 |
| 179 | else |
| 180 | ASK_IMG_NAME=0 |
| 181 | fi |
| 182 | done |
| 183 | [scip-shell system . . `[`. -f "$ANS_TMP" ] && rmscip-shell system . . rm. -f $ANS_TMP |
| 184 | |
| 185 | local TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_name.XXXXXXscip-shell filesystem . . `/tmp/ocs_name.XXXXXX`.` |
| 186 | local dev_prompt_and_example |
| 187 | local ASK_DEV_NAME=1 |
| 188 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 189 | case "$save_type" in |
| 190 | "savedisk") |
| 191 | dev_prompt_and_example="$msg_input_device_name ($msg_ex: 'hda' $msg_or 'sda' $msg_or 'hda hdb' $msg_or 'sda sdb') \n$msg_linux_disk_MS_mapping" |
| 192 | # savedisk_preset is from drbl-ocs.conf |
| 193 | dev_preset="$savedisk_preset" |
| 194 | ;; |
| 195 | "saveparts") |
| 196 | dev_prompt_and_example="$msg_input_device_name ($msg_ex: 'hda1 hda2' $msg_or 'sda1 sda2') \n$msg_linux_parts_MS_mapping" |
| 197 | # saveparts_preset is from drbl-ocs.conf |
| 198 | dev_preset="$saveparts_preset" |
| 199 | ;; |
| 200 | esac |
| 201 | while [scip-shell system . . `[`. "$ASK_DEV_NAME" -ne 0 ]; do |
| 202 | $DIA --backtitle "$msg_nchc_free_software_labs" --title "$msg_nchc_clonezilla | $msg_mode: $ocs_mode_prompt" \ |
| 203 | --inputbox "$dev_prompt_and_example" 0 0 "$dev_preset" 2> $TMP |
| 204 | input_device_name="$(catscip-shell system . . cat. $TMP)" |
| 205 | if [scip-shell system . . `[`. -z "$input_device_name" ]; then |
| 206 | $DIA --backtitle "$msg_nchc_free_software_labs" --title "$msg_nchc_clonezilla | $msg_mode: $ocs_mode_prompt" \ |
| 207 | --yesno "$msg_you_must_input_device_name_to_save_image! $msg_do_u_want_to_do_it_again" 0 0 |
| 208 | ans_="$?" |
| 209 | case "$ans_" in |
| 210 | 0) # yes is chosen |
| 211 | ASK_DEV_NAME=1;; |
| 212 | 1) # no is chosen |
| 213 | echoscip-shell system . . echo. "$msg_program_stop!" |
| 214 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 215 | exit 1;; |
| 216 | esac |
| 217 | else |
| 218 | ASK_DEV_NAME=0 |
| 219 | fi |
| 220 | done |
| 221 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 222 | fi |
| 223 | } # end of ask_if_input_save_image_name_in_server |
| 224 | # |
| 225 | run_login_switchscip-shell shell shell-project 0.0.0 run_login_switch().() { |
| 226 | local action="$1" |
| 227 | local TMP |
| 228 | if [scip-shell system . . `[`. -z "$action" ]; then |
| 229 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 230 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 231 | echoscip-shell system . . echo. "Switch DRBL client login mode" |
| 232 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 233 | "$msg_login_switch" --menu "$msg_choose_action:" \ |
| 234 | 0 0 0 \ |
| 235 | "normal" "$msg_normal_login" \ |
| 236 | "auto" "$msg_auto_login" \ |
| 237 | "timed" "$msg_timed_login" \ |
| 238 | 2> $TMP |
| 239 | action="--""$(catscip-shell system . . cat. $TMP)" |
| 240 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 241 | fi |
| 242 | [scip-shell system . . `[`. -z "$action" ] && echoscip-shell system . . echo. "You must specify the action! Program terminated!!!" && exit 1 |
| 243 | # If the mode is autologin or timed login graphic mode, we should switch to graphic mode first. |
| 244 | if [scip-shell system . . `[`. "$action" = "--auto" -o "$action" = "--timed" ]; then |
| 245 | echoscip-shell system . . echo. "Set the client as remote-linux graphic mode..." |
| 246 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 247 | drbl-client-switch -l $lang -h "$IP_LIST" remote-linux-gra |
| 248 | else |
| 249 | drbl-client-switch -l $lang -nl remote-linux-gra |
| 250 | fi |
| 251 | fi |
| 252 | drbl-login-switch $action -l $lang |
| 253 | } # end of run_login_switch |
| 254 | # |
| 255 | run_drbl_mode_switchscip-shell shell shell-project 0.0.0 run_drbl_mode_switch().() { |
| 256 | local drbl_mode_opt="$1" |
| 257 | local TMP |
| 258 | if [scip-shell system . . `[`. -z "$drbl_mode_opt" ]; then |
| 259 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 260 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 261 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 262 | "$msg_drbl_mode_switch" --menu "$msg_drbl_mode_switch_long" \ |
| 263 | 0 0 0 \ |
| 264 | "0" "$msg_drbl_mode_0" \ |
| 265 | "1" "$msg_drbl_mode_1" \ |
| 266 | "2" "$msg_drbl_mode_2" \ |
| 267 | 2> $TMP |
| 268 | drbl_mode_opt="$(catscip-shell system . . cat. $TMP)" |
| 269 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 270 | fi |
| 271 | if [scip-shell system . . `[`. -n "$drbl_mode_opt" ]; then |
| 272 | drbl_mode_opt="-d $drbl_mode_opt" |
| 273 | else |
| 274 | echoscip-shell system . . echo. "You must specify the drbl_mode_opt! Program terminated!!!" |
| 275 | exit 1 |
| 276 | fi |
| 277 | tune-clientdir-opt -l $lang $drbl_mode_opt |
| 278 | } # end of run_drbl_mode_switch |
| 279 | # |
| 280 | run_clonezilla_mode_switchscip-shell shell shell-project 0.0.0 run_clonezilla_mode_switch().() { |
| 281 | local clonezilla_mode_opt="$1" |
| 282 | local TMP2 |
| 283 | if [scip-shell system . . `[`. -z "$clonezilla_mode_opt" ]; then |
| 284 | TMP2="$(mktempscip-shell system . . mktemp. /tmp/menu2.XXXXXXscip-shell filesystem . . `/tmp/menu2.XXXXXX`.)" |
| 285 | trap "[ -f "$TMP2" ] && rm -f $TMP2" HUP INT QUIT TERM EXIT |
| 286 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 287 | "$msg_clonezilla_mode_switch" --menu "$msg_clonezilla_mode_switch_long" \ |
| 288 | 0 0 0 \ |
| 289 | "0" "$msg_clonezilla_mode_0" \ |
| 290 | "1" "$msg_clonezilla_mode_1" \ |
| 291 | "2" "$msg_clonezilla_mode_2" \ |
| 292 | 2> $TMP2 |
| 293 | clonezilla_mode_opt="$(catscip-shell system . . cat. $TMP2)" |
| 294 | [scip-shell system . . `[`. -f "$TMP2" ] && rmscip-shell system . . rm. -f $TMP2 |
| 295 | fi |
| 296 | if [scip-shell system . . `[`. -n "$clonezilla_mode_opt" ]; then |
| 297 | clonezilla_mode_opt="-z $clonezilla_mode_opt" |
| 298 | else |
| 299 | echoscip-shell system . . echo. "You must specify the clonezilla_mode_opt! Program terminated!!!" |
| 300 | exit 1 |
| 301 | fi |
| 302 | tune-clientdir-opt -l $lang $clonezilla_mode_opt |
| 303 | } # end of run_drbl_clonezilla_mode_switch |
| 304 | |
| 305 | do_clonezilla_save_devscip-shell shell shell-project 0.0.0 do_clonezilla_save_dev().() { |
| 306 | # dev is: disk or parts |
| 307 | local dev="$1" |
| 308 | [scip-shell system . . `[`. -z "$dev" ] && echoscip-shell system . . echo. "You must specify the device type (parts or disk)!!! Program terminated!!!" && exit 1 |
| 309 | |
| 310 | echoscip-shell system . . echo. -n "Setting client as clonezilla-save-${dev} mode..." |
| 311 | |
| 312 | # ask if want to input the saved name now |
| 313 | ask_if_input_save_image_name_in_serverscip-shell shell shell-project 0.0.0 ask_if_input_save_image_name_in_server(). save${dev} |
| 314 | |
| 315 | # ask if want to set ocs extra param |
| 316 | OCS_PARAM_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_param_tmp.XXXXXXscip-shell filesystem . . `/tmp/ocs_param_tmp.XXXXXX`.` |
| 317 | trap "[ -f "$OCS_PARAM_TMP" ] && rm -f $OCS_PARAM_TMP" HUP INT QUIT TERM EXIT |
| 318 | set_drbl_ocs_extra_param save $dev |
| 319 | OCS_OPTS="$(catscip-shell system . . cat. $OCS_PARAM_TMP)" |
| 320 | OCS_OPTS="$(echoscip-shell system . . echo. $OCS_OPTS)" # Make it in one line |
| 321 | [scip-shell system . . `[`. -f "$OCS_PARAM_TMP" ] && rmscip-shell system . . rm. -f $OCS_PARAM_TMP |
| 322 | |
| 323 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 324 | run_again_fname="/tmp/ocs-${input_save_img_name:-input-later}-`datescip-shell system . . date. +%F-%H-%M`" |
| 325 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 326 | # NOTE: For prompt, we use \" to show ", but actually run it without \ |
| 327 | drbl-ocs $OCS_OPTS $dcs_save_extra_opt -h "$IP_LIST" -l $lang start${dev} save $input_save_img_name $input_device_name |
| 328 | # deploy_pxecfg_grubefi_files is run inside drbl-ocs. |
| 329 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 330 | # NOTE: For prompt, we use \" to show ", but actually run it without \ |
| 331 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 332 | echoscip-shell system . . echo. drbl-ocs -b $OCS_OPTS $dcs_save_extra_opt -h \"$IP_LIST\" -l $lang start${dev} save $input_save_img_name $input_device_name | teescip-shell system . . tee. $run_again_fname |
| 333 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 334 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 335 | else |
| 336 | drbl-ocs $OCS_OPTS $dcs_save_extra_opt -l $lang start${dev} save $input_save_img_name $input_device_name |
| 337 | # deploy_pxecfg_grubefi_files is run inside drbl-ocs. |
| 338 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 339 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 340 | echoscip-shell system . . echo. drbl-ocs -b $OCS_OPTS $dcs_save_extra_opt -l $lang start${dev} save $input_save_img_name $input_device_name | teescip-shell system . . tee. $run_again_fname |
| 341 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 342 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 343 | fi |
| 344 | [scip-shell system . . `[`. -e "$run_again_fname" ] && chmodscip-shell system . . chmod. 755 $run_again_fname |
| 345 | echoscip-shell system . . echo. "done!" |
| 346 | } # end of do_clonezilla_save_dev |
| 347 | |
| 348 | # |
| 349 | do_clonezilla_restore_devscip-shell shell shell-project 0.0.0 do_clonezilla_restore_dev().() { |
| 350 | # dev is: disk or parts |
| 351 | local dev="$1" |
| 352 | local target_image default_mcast_client_no='' |
| 353 | local host_opt drbl_ocs_cmd |
| 354 | [scip-shell system . . `[`. -z "$dev" ] && echoscip-shell system . . echo. "You must specify the device type (parts or disk)!!! Program terminated!!!" && exit 1 |
| 355 | # We won't provide the method to change the mount point to replace /home/partimag in dcs, so we fix the imagedir="$ocsroot" (/home/partimag). However, user still can use drbl-ocs to do that. |
| 356 | # |
| 357 | # change to other mount point for extra harddisk |
| 358 | #if [ -n "$mount_point" ]; then |
| 359 | # imagedir="$mount_point" |
| 360 | # echo "Using the mount point $imagedir." |
| 361 | #else |
| 362 | # imagedir="$ocsroot" |
| 363 | #fi |
| 364 | imagedir="$ocsroot" |
| 365 | |
| 366 | echoscip-shell system . . echo. -n "Setting client as clonezilla-restore-$dev mode..." |
| 367 | |
| 368 | # ask if want to set ocs extra param |
| 369 | OCS_PARAM_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_param_tmp.XXXXXXscip-shell filesystem . . `/tmp/ocs_param_tmp.XXXXXX`.` |
| 370 | trap "[ -f "$OCS_PARAM_TMP" ] && rm -f $OCS_PARAM_TMP" HUP INT QUIT TERM EXIT |
| 371 | set_drbl_ocs_extra_param restore $dev |
| 372 | OCS_OPTS="$(catscip-shell system . . cat. $OCS_PARAM_TMP)" |
| 373 | OCS_OPTS="$(echoscip-shell system . . echo. $OCS_OPTS)" # Make it in one line |
| 374 | [scip-shell system . . `[`. -f "$OCS_PARAM_TMP" ] && rmscip-shell system . . rm. -f $OCS_PARAM_TMP |
| 375 | |
| 376 | if [scip-shell system . . `[`. -n "$(echoscip-shell system . . echo. $OCS_OPTS | grepscip-shell system . . grep. -E "\-[u]")" ]; then |
| 377 | # with -u, we will choose the image in the client, so |
| 378 | # 1. do not ask image name here. |
| 379 | # 2. only unicast available. |
| 380 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 381 | echoscip-shell system . . echo. "$msg_ocs_param_exclude_multicast" |
| 382 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 383 | dcs_cast_mode="unicast" |
| 384 | else |
| 385 | # if no -u, we have to ask image name here. |
| 386 | # get the image |
| 387 | ANS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_ans.XXXXXXscip-shell filesystem . . `/tmp/ocs_ans.XXXXXX`.` |
| 388 | trap "[ -f "$ANS_TMP" ] && rm -f $ANS_TMP" HUP INT QUIT TERM EXIT |
| 389 | get_existing_${dev}_image $ANS_TMP rest-unenc |
| 390 | # the return name will be only one image name. |
| 391 | target_image="$(catscip-shell system . . cat. $ANS_TMP)" |
| 392 | [scip-shell system . . `[`. -f "$ANS_TMP" ] && rmscip-shell system . . rm. -f $ANS_TMP |
| 393 | # Note! We won't add leading $ocsroot in $target_image, because when task_saveparts do the real job later, it will add that. |
| 394 | |
| 395 | # choose the only dev we want |
| 396 | case "$dev" in |
| 397 | "disk") |
| 398 | ANS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_ans.XXXXXXscip-shell filesystem . . `/tmp/ocs_ans.XXXXXX`.` |
| 399 | trap "[ -f "$ANS_TMP" ] && rm -f $ANS_TMP" HUP INT QUIT TERM EXIT |
| 400 | get_existing_disks_from_img $ANS_TMP $imagedir/$target_image |
| 401 | # we have to remove " (comes with checklist in dialog) so that for loop |
| 402 | # will work (Specially for FC3/4...) |
| 403 | target_dev="$(catscip-shell system . . cat. $ANS_TMP | trscip-shell system . . tr. -d \")" |
| 404 | [scip-shell system . . `[`. -f "$ANS_TMP" ] && rmscip-shell system . . rm. -f $ANS_TMP |
| 405 | ;; |
| 406 | "parts") |
| 407 | ANS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_ans.XXXXXXscip-shell filesystem . . `/tmp/ocs_ans.XXXXXX`.` |
| 408 | trap "[ -f "$ANS_TMP" ] && rm -f $ANS_TMP" HUP INT QUIT TERM EXIT |
| 409 | get_existing_partitions_from_img $ANS_TMP $imagedir/$target_image no restore |
| 410 | # we have to remove " (comes with checklist in dialog) so that for loop |
| 411 | # will work (Specially for FC3/4...) |
| 412 | target_dev="$(catscip-shell system . . cat. $ANS_TMP | trscip-shell system . . tr. -d \")" |
| 413 | [scip-shell system . . `[`. -f "$ANS_TMP" ] && rmscip-shell system . . rm. -f $ANS_TMP |
| 414 | ;; |
| 415 | esac |
| 416 | |
| 417 | # Enable bittorrent restoring when opentracker is available |
| 418 | if type opentracker && type ezio &>/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 419 | bt_restore_msg_1="bittorrent" |
| 420 | bt_restore_msg_2="$(rep_whspc_w_udrsc "$msg_bittorent_restore")" |
| 421 | fi |
| 422 | # get the mode of unicast of multicast |
| 423 | eval msg_choose_the_mode_to_restore_dev=\$msg_choose_the_mode_to_restore_$dev |
| 424 | if [scip-shell system . . `[`. -z "$dcs_cast_mode" ]; then |
| 425 | TMP=$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.) |
| 426 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 427 | $DIA \ |
| 428 | --backtitle "$msg_nchc_title" \ |
| 429 | --title "$msg_nchc_clonezilla | $msg_mode: $ocs_mode_prompt" \ |
| 430 | --menu "$msg_choose_the_mode_to_restore_dev" 0 0 0 \ |
| 431 | "multicast" "$msg_multicast_restore" \ |
| 432 | "broadcast" "$msg_broadcast_restore" \ |
| 433 | $bt_restore_msg_1 $bt_restore_msg_2 \ |
| 434 | "unicast" "$msg_unicast_restore" \ |
| 435 | 2> $TMP |
| 436 | dcs_cast_mode=$(catscip-shell system . . cat. $TMP) |
| 437 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 438 | fi |
| 439 | fi |
| 440 | |
| 441 | if [scip-shell system . . `[`. -z "$dcs_cast_mode" ]; then |
| 442 | echoscip-shell system . . echo. "No mode is selected! Program terminated!!!" |
| 443 | exit 1 |
| 444 | fi |
| 445 | case "$dcs_cast_mode" in |
| 446 | "multicast"|"broadcast"|"unicast"|"bittorrent") truescip-shell system . . true.;; |
| 447 | *) |
| 448 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 449 | echoscip-shell system . . echo. "\"$dcs_cast_mode\" is an unknown or unsupported mode! You must assign a correct option for dcs_cast_mode!" |
| 450 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 451 | echoscip-shell system . . echo. "$msg_program_stop!" |
| 452 | exit 1 |
| 453 | ;; |
| 454 | esac |
| 455 | |
| 456 | run_again_fname="/tmp/ocs-$target_image-`datescip-shell system . . date. +%F-%H-%M`" |
| 457 | if [scip-shell system . . `[`. "$dcs_cast_mode" = "unicast" ]; then |
| 458 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 459 | host_opt="-h \"$IP_LIST\"" |
| 460 | fi |
| 461 | # Squeeze multiple spaces to one only |
| 462 | drbl_ocs_cmd="$(echoscip-shell system . . echo. drbl-ocs $OCS_OPTS $dcs_restore_extra_opt $host_opt -l $lang start${dev} restore $target_image $target_dev | sedscip-shell system . . sed. -r -e "s|[[:space:]]+| |g")" |
| 463 | eval $drbl_ocs_cmd |
| 464 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 465 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 466 | echoscip-shell system . . echo. "$drbl_ocs_cmd" | teescip-shell system . . tee. $run_again_fname |
| 467 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 468 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 469 | elif [scip-shell system . . `[`. "$dcs_cast_mode" = "bittorrent" ]; then |
| 470 | mcast_mode_opt="" |
| 471 | ANS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_ans.XXXXXXscip-shell filesystem . . `/tmp/ocs_ans.XXXXXX`.` |
| 472 | trap "[ -f "$ANS_TMP" ] && rm -f $ANS_TMP" HUP INT QUIT TERM EXIT |
| 473 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 474 | default_bt_client_no="$(LC_ALL=C echoscip-shell system . . echo. $IP_LIST | wcscip-shell system . . wc. -w)" |
| 475 | fi |
| 476 | ask_clients_to_wait_for_bittorrent $ANS_TMP $default_bt_client_no |
| 477 | . $ANS_TMP |
| 478 | [scip-shell system . . `[`. -n "$clients_to_wait" ] && bt_mod_opt="--clients-to-wait $clients_to_wait" |
| 479 | [scip-shell system . . `[`. -f "$ANS_TMP" ] && rmscip-shell system . . rm. -f $ANS_TMP |
| 480 | |
| 481 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 482 | host_opt="-h \"$IP_LIST\"" |
| 483 | fi |
| 484 | # Squeeze multiple spaces to one only |
| 485 | drbl_ocs_cmd="$(echoscip-shell system . . echo. drbl-ocs $OCS_OPTS $dcs_restore_extra_opt $bt_mod_opt $host_opt -l $lang start${dev} bt_restore $target_image $target_dev | sedscip-shell system . . sed. -r -e "s|[[:space:]]+| |g")" |
| 486 | eval $drbl_ocs_cmd |
| 487 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 488 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 489 | echoscip-shell system . . echo. "$drbl_ocs_cmd" | teescip-shell system . . tee. $run_again_fname |
| 490 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 491 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 492 | else |
| 493 | # multicast or broadcast |
| 494 | # Get the multicast options: time_to_wait, clients_to_wait... |
| 495 | mcast_mode_opt="" |
| 496 | ANS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_ans.XXXXXXscip-shell filesystem . . `/tmp/ocs_ans.XXXXXX`.` |
| 497 | trap "[ -f "$ANS_TMP" ] && rm -f $ANS_TMP" HUP INT QUIT TERM EXIT |
| 498 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 499 | default_mcast_client_no="$(LC_ALL=C echoscip-shell system . . echo. $IP_LIST | wcscip-shell system . . wc. -w)" |
| 500 | fi |
| 501 | ask_time_or_clients_to_wait_for_mcast $ANS_TMP $default_mcast_client_no |
| 502 | . $ANS_TMP |
| 503 | # we will get time_to_wait or client_to_want. |
| 504 | [scip-shell system . . `[`. -n "$time_to_wait" ] && mcast_mode_opt="$mcast_mode_opt --time-to-wait $time_to_wait" |
| 505 | [scip-shell system . . `[`. -n "$clients_to_wait" ] && mcast_mode_opt="$mcast_mode_opt --clients-to-wait $clients_to_wait" |
| 506 | [scip-shell system . . `[`. -n "$max_time_to_wait" ] && mcast_mode_opt="$mcast_mode_opt --max-time-to-wait $max_time_to_wait" |
| 507 | [scip-shell system . . `[`. -f "$ANS_TMP" ] && rmscip-shell system . . rm. -f $ANS_TMP |
| 508 | # |
| 509 | [scip-shell system . . `[`. "$dcs_cast_mode" = "broadcast" ] && mcast_mode_opt="$mcast_mode_opt --broadcast" |
| 510 | |
| 511 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 512 | |
| 513 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 514 | mcast_clonezilla_restore_not_for_all_clients_warningscip-shell shell shell-project 0.0.0 mcast_clonezilla_restore_not_for_all_clients_warning(). |
| 515 | host_opt="-h \"$IP_LIST\"" |
| 516 | fi |
| 517 | # Squeeze multiple spaces to one only |
| 518 | drbl_ocs_cmd="$(echoscip-shell system . . echo. drbl-ocs $OCS_OPTS $dcs_restore_extra_opt $mcast_mode_opt $host_opt -l $lang start${dev} multicast_restore $target_image $target_dev | sedscip-shell system . . sed. -r -e "s|[[:space:]]+| |g")" |
| 519 | eval $drbl_ocs_cmd |
| 520 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 521 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 522 | echoscip-shell system . . echo. "$drbl_ocs_cmd" | teescip-shell system . . tee. $run_again_fname |
| 523 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 524 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 525 | fi |
| 526 | [scip-shell system . . `[`. -e "$run_again_fname" ] && chmodscip-shell system . . chmod. 755 $run_again_fname |
| 527 | echoscip-shell system . . echo. "done!" |
| 528 | } # end of do_clonezilla_restore_dev |
| 529 | |
| 530 | # |
| 531 | do_clonezilla_select_in_clientscip-shell shell shell-project 0.0.0 do_clonezilla_select_in_client().() { |
| 532 | OCS_PARAM_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_param_tmp.XXXXXXscip-shell filesystem . . `/tmp/ocs_param_tmp.XXXXXX`.` |
| 533 | trap "[ -f "$OCS_PARAM_TMP" ] && rm -f $OCS_PARAM_TMP" HUP INT QUIT TERM EXIT |
| 534 | # |
| 535 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 536 | "$msg_clonezilla_advanced_extra_param" --menu "$msg_default_pxemenu_for_clone:" \ |
| 537 | 0 0 0 $DIA_ESC \ |
| 538 | "-y1 " "$msg_ocs_param_y1" \ |
| 539 | "-y0 " "$msg_ocs_param_y0" \ |
| 540 | "-y2 " "$msg_ocs_param_y2" \ |
| 541 | "" "$msg_ocs_param_skip" \ |
| 542 | 2> $OCS_PARAM_TMP |
| 543 | # ask the action when clone finishes in client |
| 544 | |
| 545 | ocs_advanced_param_post_mode_after_clone $OCS_PARAM_TMP |
| 546 | |
| 547 | # force to strip the unnecessary quotation ', this is specially for dialog (from cdialog) in Mandriva. Otherwise it will cause -p reboot (containing space) becomes '-p reboot', which is wrong option in dcs. |
| 548 | OCS_OPTS="$(catscip-shell system . . cat. $OCS_PARAM_TMP | sedscip-shell system . . sed. -e "s/\'//g")" |
| 549 | OCS_OPTS="$(echoscip-shell system . . echo. $OCS_OPTS)" # Make it in one line |
| 550 | [scip-shell system . . `[`. -f "$OCS_PARAM_TMP" ] && rmscip-shell system . . rm. -f $OCS_PARAM_TMP |
| 551 | |
| 552 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 553 | run_again_fname="/tmp/ocs-select-in-client-`datescip-shell system . . date. +%F-%H-%M`" |
| 554 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 555 | drbl-ocs -h "$IP_LIST" -l $lang $OCS_OPTS select_in_client |
| 556 | # deploy_pxecfg_grubefi_files is run inside drbl-ocs. |
| 557 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 558 | echoscip-shell system . . echo. "$msg_authentication_pxe_linux_info" |
| 559 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 560 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 561 | echoscip-shell system . . echo. drbl-ocs -b -h \"$IP_LIST\" -l $lang $OCS_OPTS select_in_client | teescip-shell system . . tee. $run_again_fname |
| 562 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 563 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 564 | else |
| 565 | drbl-ocs -l $lang $OCS_OPTS select_in_client |
| 566 | # deploy_pxecfg_grubefi_files is run inside drbl-ocs. |
| 567 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 568 | echoscip-shell system . . echo. "$msg_authentication_pxe_linux_info" |
| 569 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 570 | echoscip-shell system . . echo. PS. $msg_run_drbl_ocs_again_cmd |
| 571 | echoscip-shell system . . echo. drbl-ocs -b -l $lang $OCS_OPTS select_in_client | teescip-shell system . . tee. $run_again_fname |
| 572 | echoscip-shell system . . echo. "$msg_ocs_sr_again_command_saved_filename: $run_again_fname" |
| 573 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 574 | fi |
| 575 | [scip-shell system . . `[`. -e "$run_again_fname" ] && chmodscip-shell system . . chmod. 755 $run_again_fname |
| 576 | echoscip-shell system . . echo. "done!" |
| 577 | } # end of do_clonezilla_select_in_client |
| 578 | |
| 579 | # |
| 580 | run_switch_drbl_servicescip-shell shell shell-project 0.0.0 run_switch_drbl_service().() { |
| 581 | local action="$1" |
| 582 | local TMP |
| 583 | if [scip-shell system . . `[`. -z "$action" ]; then |
| 584 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 585 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 586 | echoscip-shell system . . echo. "Switch DRBL related services in DRBL server" |
| 587 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 588 | "$msg_switch_drbl_service" --menu "$msg_choose_action:" \ |
| 589 | 0 0 0 \ |
| 590 | "start" "$msg_start_drbl_all_services" \ |
| 591 | "stop" "$msg_stop_drbl_all_services" \ |
| 592 | "restart" "$msg_restart_drbl_all_services" \ |
| 593 | "add" "$msg_add_drbl_all_services" \ |
| 594 | "del" "$msg_del_drbl_all_services" \ |
| 595 | 2> $TMP |
| 596 | action="$(catscip-shell system . . cat. $TMP)" |
| 597 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 598 | [scip-shell system . . `[`. -z "$action" ] && echoscip-shell system . . echo. "You must specify the action! Program terminated!!!" && exit 1 |
| 599 | fi |
| 600 | drbl-all-service $action |
| 601 | } # end of run_switch_drbl_service |
| 602 | # |
| 603 | run-switch-pxe-bg-modescip-shell shell shell-project 0.0.0 run-switch-pxe-bg-mode().() { |
| 604 | local action="$1" |
| 605 | local TMP |
| 606 | if [scip-shell system . . `[`. -z "$action" ]; then |
| 607 | TMP="$(mktempscip-shell system . . mktemp. /tmp/pxemenu.XXXXXXscip-shell filesystem . . `/tmp/pxemenu.XXXXXX`.)" |
| 608 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 609 | echoscip-shell system . . echo. "Switch DRBL client PXE boot menu mode" |
| 610 | $DIA --backtitle "$msg_nchc_free_software_labs" --title \ |
| 611 | "$msg_switch_pxe_bg_mode" --menu "$msg_switch_pxe_bg_mode" \ |
| 612 | 0 0 0 \ |
| 613 | "text" "$msg_pxemenu_text" \ |
| 614 | "graphic" "$msg_pxemenu_graphic" \ |
| 615 | 2> $TMP |
| 616 | action="$(catscip-shell system . . cat. $TMP)" |
| 617 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 618 | [scip-shell system . . `[`. -z "$action" ] && echoscip-shell system . . echo. "You must specify the mode! Program terminated!!!" && exit 1 |
| 619 | fi |
| 620 | switch-pxe-bg-mode -m $action |
| 621 | switch-efi-nb-bg-mode -m $action |
| 622 | } # end of run-switch-pxe-bg-mode |
| 623 | # |
| 624 | clean_stale_mac_cfg_for_pxelinux_or_notscip-shell shell shell-project 0.0.0 clean_stale_mac_cfg_for_pxelinux_or_not().() { |
| 625 | local ihlist="$*" |
| 626 | local OCS_TMP ih MAC rm_stale_mac_cfg |
| 627 | # In this case, use chooses to select client by IP address. Only IP style file will be created in $PXELINUX_DIR/. If no MAC address in dhcpd.conf, and we find some 01-MAC file in $PXELINUX_DIR/, we have to ask use if he want to clean those 01-MAC style files. Since we have no idea which one is for which IP address. Otherwise those stale 01-MAC will have higher priority then IP address style file. That will cause problem. |
| 628 | if [scip-shell system . . `[`. -n "$(lsscip-shell system . . ls. $PXELINUX_DIR/01-* 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" ]; then |
| 629 | # prepare the HOSTNAME-IP-MAC table |
| 630 | OCS_TMP=`mktempscip-shell system . . mktemp. /tmp/ocs_clean_tmp.XXXXXXscip-shell filesystem . . `/tmp/ocs_clean_tmp.XXXXXX`.` |
| 631 | trap "[ -f "$OCS_TMP" ] && rm -f $OCS_TMP" HUP INT QUIT TERM EXIT |
| 632 | parse_dhcpd_conf $OCS_TMP |
| 633 | for ih in $ihlist; do |
| 634 | MAC="$(grepscip-shell system . . grep. ${ih} $OCS_TMP | awkscip-shell system . . awk. -F" " '{print $3}')" |
| 635 | if [scip-shell system . . `[`. -z "$MAC" ]; then |
| 636 | $DIA --title "$msg_nchc_free_software_labs" \ |
| 637 | --yesno "$msg_do_you_want_to_clean_all_stale_mac_cfg" 0 0 |
| 638 | case $? in |
| 639 | 0) |
| 640 | rm_stale_mac_cfg="yes";; |
| 641 | 1) |
| 642 | rm_stale_mac_cfg="no";; |
| 643 | 255) |
| 644 | echoscip-shell system . . echo. "Box closed.";; |
| 645 | esac |
| 646 | if [scip-shell system . . `[`. "$rm_stale_mac_cfg" = "yes" ]; then |
| 647 | rmscip-shell system . . rm. -fv $PXELINUX_DIR/01-* |
| 648 | echoscip-shell system . . echo. -n "$msg_press_enter_to_continue" |
| 649 | read |
| 650 | fi |
| 651 | fi |
| 652 | done |
| 653 | [scip-shell system . . `[`. -f "$OCS_TMP" ] && rmscip-shell system . . rm. -f $OCS_TMP |
| 654 | fi |
| 655 | } # clean_stale_mac_cfg_for_pxelinux_or_not |
| 656 | |
| 657 | # Parse command-line options |
| 658 | while [scip-shell system . . `[`. $# -gt 0 ]; do |
| 659 | case "$1" in |
| 660 | -l|--language) |
| 661 | shift |
| 662 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 663 | # skip the -xx option, in case |
| 664 | specified_lang="$1" |
| 665 | shift |
| 666 | fi |
| 667 | ;; |
| 668 | -h|--host) |
| 669 | LIST_HOST="on" |
| 670 | shift |
| 671 | # skip the -xx option, in case |
| 672 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 673 | # parse if the arg is MAC or IP, skip those not MAC or IP |
| 674 | if [scip-shell system . . `[`. -n "$(echoscip-shell system . . echo. $1 | grepscip-shell system . . grep. -E "^[[:space:]]*([[:alnum:]]+:){5}[[:alnum:]]+([[:space:]]|$)+")" -o -n "$(echoscip-shell system . . echo. $1 | grepscip-shell system . . grep. -E "^[[:space:]]*([[:digit:]]+\.){3}[[:digit:]]+([[:space:]]|$)+")" -o -z "$1" ] ; then |
| 675 | IP_LIST=$1 |
| 676 | shift |
| 677 | else |
| 678 | echoscip-shell system . . echo. "\"$1\" is not a suitable IP_LIST or MAC_LIST !!! Program terminated!!!" |
| 679 | exit 1 |
| 680 | fi |
| 681 | fi |
| 682 | ;; |
| 683 | -nl|--no-list-host) |
| 684 | LIST_HOST="off" |
| 685 | shift;; |
| 686 | -d0|--dialog) |
| 687 | # $DIA, $DIA_OPT are used in dcs, it won't pass to drbl-ocs, ocs-sr. |
| 688 | DIA="dialog" |
| 689 | DIA_OPT="-d0" |
| 690 | shift;; |
| 691 | -d1|--Xdialog) |
| 692 | DIA="Xdialog" |
| 693 | DIA_OPT="-d1" |
| 694 | shift;; |
| 695 | -d2|--whiptail) |
| 696 | DIA="whiptail" |
| 697 | DIA_OPT="-d2" |
| 698 | shift;; |
| 699 | -d3|--gdialog) |
| 700 | DIA="gdialog" |
| 701 | DIA_OPT="-d3" |
| 702 | shift;; |
| 703 | -d4|--kdialog) |
| 704 | DIA="kdialog" |
| 705 | DIA_OPT="-d4" |
| 706 | shift;; |
| 707 | -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2 |
| 708 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). >& 2 |
| 709 | exit 2 ;; |
| 710 | *) break ;; |
| 711 | esac |
| 712 | done |
| 713 | |
| 714 | ###### |
| 715 | ## main script |
| 716 | ###### |
| 717 | MODE="$1" |
| 718 | # We have two levels, like clonezilla-start save-disk |
| 719 | MODE2="$2" |
| 720 | MORE_OPT_for_MODE2="$3" |
| 721 | |
| 722 | ask_and_load_lang_set $specified_lang |
| 723 | |
| 724 | # check DIA |
| 725 | check_DIA_set_ESC $DIA |
| 726 | |
| 727 | [scip-shell system . . `[`. -z "$LIST_HOST" ] && ask_if_want_list_hostscip-shell shell shell-project 0.0.0 ask_if_want_list_host(). |
| 728 | |
| 729 | # |
| 730 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 731 | # We need 1 file and 1 variable to sepcify hosts, |
| 732 | # (1) file "HOSTS_TMP", which contains IP list or MAC list. |
| 733 | # (2) variable "IP_LIST", which contains IP list only (if user specify MAC list, we will convert them to IP list based on dhcpd.conf) |
| 734 | |
| 735 | # NOTES: after the modification of PXE_CONF, we must run |
| 736 | # [ "$LIST_HOST" = "on" ] && set_specific_host_pxe_conf `cat $HOSTS_TMP` |
| 737 | # to update the pxeconf (both for 01-MAC and IP) |
| 738 | |
| 739 | HOSTS_TMP="$(mktempscip-shell system . . mktemp. /tmp/hosts_tmp.XXXXXXXscip-shell filesystem . . `/tmp/hosts_tmp.XXXXXXX`.)" |
| 740 | trap "[ -f "$HOSTS_TMP" ] && rm -f $HOSTS_TMP" HUP INT QUIT TERM EXIT |
| 741 | MAC_LIST="" |
| 742 | # The content of $HOSTS_TMP can be IP list or MAC list (generated by select-drbl-clients) |
| 743 | if [scip-shell system . . `[`. -z "$IP_LIST" ]; then |
| 744 | select-drbl-clients $DIA_OPT -l $lang $HOSTS_TMP |
| 745 | retval=$? |
| 746 | else |
| 747 | # user already specified the hosts, so we just put them in $HOSTS_TMP |
| 748 | echoscip-shell system . . echo. $IP_LIST > $HOSTS_TMP |
| 749 | retval=$? |
| 750 | fi |
| 751 | if [scip-shell system . . `[`. $retval -eq 0 ]; then |
| 752 | # copy the skeleton file |
| 753 | PXE_CONF="$PXELINUX_DIR/default_skeleton" |
| 754 | cpscip-shell system . . cp. -f $PXELINUX_DIR/default $PXE_CONF |
| 755 | GRUB_CONF="$GRUB_EFINB_DIR/grub.cfg_skeleton" |
| 756 | cpscip-shell system . . cp. -f $GRUB_EFINB_DIR/grub.cfg $GRUB_CONF |
| 757 | |
| 758 | if grepscip-shell system . . grep. -Eq "^[[:space:]]*([[:alnum:]]+:){5}[[:alnum:]]+([[:space:]]|$)+" $HOSTS_TMP; then |
| 759 | # HOSTS_TMP is MAC list. |
| 760 | # prepare the IP list if the HOSTS_TMP is MAC list. |
| 761 | MAC_LIST="$(catscip-shell system . . cat. $HOSTS_TMP)" |
| 762 | for imac in $MAC_LIST; do |
| 763 | #IP="$(awk -F" " '/$imac/ {print $2}' $HOST_MAC_TABLE)" |
| 764 | IP="$(grepscip-shell system . . grep. -iE "$imac" $HOST_MAC_TABLE | awkscip-shell system . . awk. -F" " '{print $2}')" |
| 765 | IP_LIST="$IP_LIST $IP" |
| 766 | done |
| 767 | else |
| 768 | # HOSTS_TMP is IP list. |
| 769 | IP_LIST="$(catscip-shell system . . cat. $HOSTS_TMP)" |
| 770 | clean_stale_mac_cfg_for_pxelinux_or_notscip-shell shell shell-project 0.0.0 clean_stale_mac_cfg_for_pxelinux_or_not(). $IP_LIST |
| 771 | fi |
| 772 | else |
| 773 | echoscip-shell system . . echo. "No client is selected! Abort!" |
| 774 | exit 0 |
| 775 | fi |
| 776 | else |
| 777 | PXE_CONF="$PXELINUX_DIR/default" |
| 778 | GRUB_CONF="$GRUB_EFINB_DIR/grub.cfg" |
| 779 | fi |
| 780 | # If clonezilla box mode, we have to suppress some functions |
| 781 | [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`. |
| 782 | # |
| 783 | if [scip-shell system . . `[`. "$drbl_mode" != "none" ]; then |
| 784 | # "remote-linux-gra" "$msg_remote_linux_graphic" off \ |
| 785 | remote_linux_gra_1="remote-linux-gra" |
| 786 | remote_linux_gra_2="$(rep_whspc_w_udrsc "$msg_remote_linux_graphic")" |
| 787 | # "remote-linux-txt" "$msg_remote_linux_text" off \ |
| 788 | remote_linux_txt_1="remote-linux-txt" |
| 789 | remote_linux_txt_2="$(rep_whspc_w_udrsc "$msg_remote_linux_text")" |
| 790 | # "terminal" "$msg_terminal" off \ |
| 791 | terminal_1="terminal" |
| 792 | terminal_2="$(rep_whspc_w_udrsc "$msg_thin_client")" |
| 793 | # "login-switch" "$msg_login_switch" off \ |
| 794 | login_switch_1="login-switch" |
| 795 | login_switch_2="$(rep_whspc_w_udrsc "$msg_login_switch")" |
| 796 | # "client-reautologin" "$msg_client_reautologin" off \ |
| 797 | client_reautologin_1="client-reautologin" |
| 798 | client_reautologin_2="$(rep_whspc_w_udrsc "$msg_client_reautologin")" |
| 799 | # "clean-autologin-account" "$msg_clean_autologin_account" off \ |
| 800 | clean_autologin_account_1="clean-autologin-account" |
| 801 | clean_autologin_account_2="$(rep_whspc_w_udrsc "$msg_clean_autologin_account")" |
| 802 | # "reset-autologin-account" "$msg_reset_autologin_account" off \ |
| 803 | reset_autologin_account_1="reset-autologin-account" |
| 804 | reset_autologin_account_2="$(rep_whspc_w_udrsc "$msg_reset_autologin_account")" |
| 805 | fi |
| 806 | if [scip-shell system . . `[`. "$clonezilla_mode" != "none" ]; then |
| 807 | clonezilla_start_1="clonezilla-start" |
| 808 | clonezilla_start_2="$(rep_whspc_w_udrsc "$msg_clonezilla_start")" |
| 809 | clonezilla_stop_1="clonezilla-stop" |
| 810 | clonezilla_stop_2="$(rep_whspc_w_udrsc "$msg_clonezilla_stop")" |
| 811 | fi |
| 812 | if [scip-shell system . . `[`. -n "$(lsscip-shell system . . ls. $pxecfg_pd/*netinstall* 2>/dev/nullscip-shell filesystem . . `/dev/null`. )" ]; then |
| 813 | netinstall_1="netinstall" |
| 814 | netinstall_2="$(rep_whspc_w_udrsc "$msg_netinstall")" |
| 815 | fi |
| 816 | |
| 817 | # Get the mode from use |
| 818 | if [scip-shell system . . `[`. -z "$MODE" ]; then |
| 819 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 820 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 821 | $DIA \ |
| 822 | --backtitle "$msg_nchc_title" \ |
| 823 | --title "$msg_nchc_drbl" \ |
| 824 | --menu "$msg_switch_client_mode:" 0 0 0 \ |
| 825 | $remote_linux_gra_1 $remote_linux_gra_2 \ |
| 826 | $remote_linux_txt_1 $remote_linux_txt_2 \ |
| 827 | $terminal_1 $terminal_2 \ |
| 828 | "remote-memtest" "$msg_remote_memtest" \ |
| 829 | "remote-fdos" "$msg_remote_fdos" \ |
| 830 | $clonezilla_start_1 $clonezilla_start_2 \ |
| 831 | $clonezilla_stop_1 $clonezilla_stop_2 \ |
| 832 | $netinstall_1 $netinstall_2 \ |
| 833 | "local" "$msg_boot_client_local" \ |
| 834 | "reboot" "$msg_reboot_the_client" \ |
| 835 | "shutdown" "$msg_shutdown_the_client" \ |
| 836 | "Wake-on-LAN" "$msg_Wake_on_LAN" \ |
| 837 | "more" "$msg_dcs_more_modes" \ |
| 838 | 2> $TMP |
| 839 | MODE=$(catscip-shell system . . cat. $TMP) |
| 840 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 841 | fi |
| 842 | |
| 843 | # set the mode for PXE client |
| 844 | case "$MODE" in |
| 845 | "remote-linux-gra") |
| 846 | echoscip-shell system . . echo. "Settinig client as remote-linux graphic mode..." |
| 847 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 848 | set-default-pxe-img -i drbl -c $PXE_CONF -l "$FULL_OS_Version $powerful_client_menu_label" |
| 849 | set-default-grub-efi-img -i drbl-client -c $GRUB_CONF |
| 850 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 851 | # now use --no-gen-ssi, but we will run drbl-gen-ssi-files when finished |
| 852 | drbl-powerful-thin-client --no-gen-ssi -p -h "$IP_LIST" -ln $lang |
| 853 | else |
| 854 | # now use --no-gen-ssi, but we will run drbl-gen-ssi-files when finished |
| 855 | drbl-powerful-thin-client --no-gen-ssi -p -ln $lang |
| 856 | fi |
| 857 | |
| 858 | deploy_pxecfg_grubefi_files |
| 859 | |
| 860 | for host in $drblroot/*; do |
| 861 | # if the LIST_HOST is on, skip those IP not listed in the $IP_LIST |
| 862 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 863 | [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $IP_LIST | grepscip-shell system . . grep. -E "\<${host##/*/}\>")" ] && continue |
| 864 | fi |
| 865 | |
| 866 | # |
| 867 | host_ip=$(basenamescip-shell system . . basename. $host) |
| 868 | echoscip-shell system . . echo. "Setting the remote-linux graphic mode for node IP = $host_ip" |
| 869 | if [scip-shell system . . `[`. -e /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ]; then |
| 870 | # Debian |
| 871 | if [scip-shell system . . `[`. -e /etc/b2d-releasescip-shell filesystem . . `/etc/b2d-release`. ]; then |
| 872 | # For B2D, it uses runlevel 5 for X |
| 873 | CLIENT_INIT="5" |
| 874 | else |
| 875 | # For Debian, Ubuntu, it uses runlevel 2 for X |
| 876 | CLIENT_INIT="2" |
| 877 | fi |
| 878 | default_dm="$(drbl-check-dm -h $host_ip)" |
| 879 | prepare_update_rc_d_env $host |
| 880 | get_debian_ubuntu_init_serv_control_prog |
| 881 | if [scip-shell system . . `[`. "$dbn_ubn_serv_control_prog" = "use-insserv" ]; then |
| 882 | # Use insserv |
| 883 | LC_ALL=C chrootscip-shell system . . chroot. $host/ insserv $default_dm &> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 884 | else |
| 885 | # Use update-rc.d |
| 886 | LC_ALL=C chrootscip-shell system . . chroot. $host/ /usr/sbin/update-rc.dscip-shell filesystem . . `/usr/sbin/update-rc.d`. $default_dm start 99 2 3 4 5 . stop 05 0 1 6 . &> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 887 | fi |
| 888 | if [scip-shell system . . `[`. -e "$host/etc/init/${default_dm}.conf" ]; then |
| 889 | switch_upstart_service $host/etc/init/${default_dm}.conf on |
| 890 | fi |
| 891 | else |
| 892 | # RH-like or SUSE |
| 893 | # set the init to 5, i.e. default is X |
| 894 | CLIENT_INIT="5" |
| 895 | fi |
| 896 | # Modify client's /etc/inittab |
| 897 | if [scip-shell system . . `[`. -e "$host/etc/inittab" ]; then |
| 898 | perlscip-shell system . . perl. -p -i -e "s/^id:[0-9]:initdefault:/id:$CLIENT_INIT:initdefault:/g" $host/etc/inittab |
| 899 | fi |
| 900 | # For systemd-like |
| 901 | #if [ -e "$host/etc/systemd/system/default.target" ]; then |
| 902 | # ln -fsv /lib/systemd/system/runlevel${CLIENT_INIT}.target $host/etc/systemd/system/default.target |
| 903 | #fi |
| 904 | if is_systemd_init; then |
| 905 | remove_opt_in_pxelinux_cfg_block drbl systemd.unit |
| 906 | remove_opt_in_grub_efi_cfg_block drbl-client systemd.unit |
| 907 | add_opt_in_pxelinux_cfg_block -n drbl systemd.unit graphical.target |
| 908 | add_opt_in_grub_efi_cfg_block -n drbl-client systemd.unit graphical.target |
| 909 | fi |
| 910 | done |
| 911 | echoscip-shell system . . echo. "done!" |
| 912 | # |
| 913 | echoscip-shell system . . echo. "-------------------------------------------------------" |
| 914 | if [scip-shell system . . `[`. "$drbl_mode" = "drbl_ssi_mode" ]; then |
| 915 | echoscip-shell system . . echo. "Since it's in DRBL SSI mode, and some config files are modified in template client, creating template tarball for DRBL SSI..." |
| 916 | drbl-gen-ssi-files |
| 917 | fi |
| 918 | ;; |
| 919 | "remote-linux-txt") |
| 920 | echoscip-shell system . . echo. "Setting client as remote-linux text mode..." |
| 921 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 922 | set-default-pxe-img -i drbl -c $PXE_CONF -l "$FULL_OS_Version $powerful_client_menu_label" |
| 923 | set-default-grub-efi-img -i drbl-client -c $GRUB_CONF |
| 924 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 925 | # now use --no-gen-ssi, but we will run drbl-gen-ssi-files when finished |
| 926 | drbl-powerful-thin-client --no-gen-ssi -p -h "$IP_LIST" -ln $lang |
| 927 | else |
| 928 | # now use --no-gen-ssi, but we will run drbl-gen-ssi-files when finished |
| 929 | drbl-powerful-thin-client --no-gen-ssi -p -ln $lang |
| 930 | fi |
| 931 | |
| 932 | deploy_pxecfg_grubefi_files |
| 933 | |
| 934 | for host in $drblroot/*; do |
| 935 | # if the LIST_HOST is on, skip those IP not listed in the $IP_LIST |
| 936 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 937 | [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $IP_LIST | grepscip-shell system . . grep. -E "\<${host##/*/}\>")" ] && continue |
| 938 | fi |
| 939 | |
| 940 | # |
| 941 | host_ip=$(basenamescip-shell system . . basename. $host) |
| 942 | echoscip-shell system . . echo. "Setting the remote-linux text mode for node IP = $host_ip" |
| 943 | if [scip-shell system . . `[`. -e /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ]; then |
| 944 | CLIENT_INIT="2" |
| 945 | default_dm="$(drbl-check-dm -h $host_ip)" |
| 946 | prepare_update_rc_d_env $host |
| 947 | get_debian_ubuntu_init_serv_control_prog |
| 948 | if [scip-shell system . . `[`. "$dbn_ubn_serv_control_prog" = "use-insserv" ]; then |
| 949 | # Use insserv |
| 950 | LC_ALL=C chrootscip-shell system . . chroot. $host/ insserv -r $default_dm &> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 951 | else |
| 952 | # Use update-rc.d |
| 953 | LC_ALL=C chrootscip-shell system . . chroot. $host/ /usr/sbin/update-rc.dscip-shell filesystem . . `/usr/sbin/update-rc.d`. -f $default_dm remove &> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 954 | fi |
| 955 | if [scip-shell system . . `[`. -e "$host/etc/init/${default_dm}.conf" ]; then |
| 956 | switch_upstart_service $host/etc/init/${default_dm}.conf off |
| 957 | fi |
| 958 | else |
| 959 | # RH-like or SUSE |
| 960 | # set the init to 3, i.e. default is text mode |
| 961 | CLIENT_INIT="3" |
| 962 | fi |
| 963 | if [scip-shell system . . `[`. -e "$host/etc/inittab" ]; then |
| 964 | perlscip-shell system . . perl. -p -i -e "s/^id:[0-9]:initdefault:/id:$CLIENT_INIT:initdefault:/g" $host/etc/inittab |
| 965 | fi |
| 966 | # For systemd-like |
| 967 | #if [ -e "$host/etc/systemd/system/default.target" ]; then |
| 968 | # ln -fsv /lib/systemd/system/runlevel${CLIENT_INIT}.target $host/etc/systemd/system/default.target |
| 969 | #fi |
| 970 | if is_systemd_init; then |
| 971 | remove_opt_in_pxelinux_cfg_block drbl systemd.unit |
| 972 | remove_opt_in_grub_efi_cfg_block drbl-client systemd.unit |
| 973 | add_opt_in_pxelinux_cfg_block -n drbl systemd.unit multi-user.target |
| 974 | add_opt_in_grub_efi_cfg_block -n drbl-client systemd.unit multi-user.target |
| 975 | fi |
| 976 | done |
| 977 | echoscip-shell system . . echo. "done!" |
| 978 | # |
| 979 | echoscip-shell system . . echo. "-------------------------------------------------------" |
| 980 | if [scip-shell system . . `[`. "$drbl_mode" = "drbl_ssi_mode" ]; then |
| 981 | echoscip-shell system . . echo. "Since it's in DRBL SSI mode, and some config files are modified in template client, creating template tarball for DRBL SSI..." |
| 982 | drbl-gen-ssi-files |
| 983 | fi |
| 984 | ;; |
| 985 | "remote-memtest") |
| 986 | echoscip-shell system . . echo. -n "Setting client as remote-memtest mode..." |
| 987 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 988 | set-default-pxe-img -i memtest -c $PXE_CONF |
| 989 | deploy_pxecfg_grubefi_files |
| 990 | echoscip-shell system . . echo. "done!" |
| 991 | ;; |
| 992 | "remote-fdos") |
| 993 | echoscip-shell system . . echo. -n "Setting client as remote-fdos mode..." |
| 994 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 995 | set-default-pxe-img -i fdos -c $PXE_CONF |
| 996 | deploy_pxecfg_grubefi_files |
| 997 | echoscip-shell system . . echo. "done!" |
| 998 | ;; |
| 999 | "terminal") |
| 1000 | echoscip-shell system . . echo. -n "Settinig client as DRBL terminal mode..." |
| 1001 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 1002 | set-default-pxe-img -i drbl-terminal -c $PXE_CONF -l "$FULL_OS_Version $thin_client_menu_label" |
| 1003 | deploy_pxecfg_grubefi_files |
| 1004 | |
| 1005 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1006 | drbl-client-system-select -e -h "$IP_LIST" on |
| 1007 | drbl-powerful-thin-client -t -h "$IP_LIST" -ln $lang |
| 1008 | else |
| 1009 | drbl-client-system-select -e on |
| 1010 | drbl-powerful-thin-client -t -ln $lang |
| 1011 | fi |
| 1012 | echoscip-shell system . . echo. "done!" |
| 1013 | ;; |
| 1014 | "netinstall") |
| 1015 | netinstall_list="$(grepscip-shell system . . grep. -Ei "^[[:space:]]*label[[:space:]]+netinstall-" $PXELINUX_DIR/default | sedscip-shell system . . sed. -e "s/^[[:space:]]*label[[:space:]]*//g" | sortscip-shell system . . sort.)" |
| 1016 | if [scip-shell system . . `[`. -z "$MODE2" ]; then |
| 1017 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 1018 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 1019 | if [scip-shell system . . `[`. -z "$netinstall_list" ]; then |
| 1020 | $DIA --title "$msg_no_network_installation_img" --clear \ |
| 1021 | --msgbox "$msg_no_network_installation_img_des" 0 0 |
| 1022 | exit 0 |
| 1023 | fi |
| 1024 | MENU="" |
| 1025 | numimages=0 |
| 1026 | for i in $netinstall_list; do |
| 1027 | numimages=$((numimages + 1)) |
| 1028 | # EX for i: netinstall-ubuntu-breezy-i386 |
| 1029 | # create the description for the netinstall image |
| 1030 | des="$(echoscip-shell system . . echo. $i | sedscip-shell system . . sed. -e "s/^netinstall-//gi" | sedscip-shell system . . sed. -e "s/-/_/g")" |
| 1031 | des="${des}_$(rep_whspc_w_udrsc "$msg_install_via_network")" |
| 1032 | # NOTE! The extra space in the end is a must! |
| 1033 | MENU="$MENU $i $des " |
| 1034 | done |
| 1035 | if [scip-shell system . . `[`. $numimages -gt 0 ]; then |
| 1036 | if [scip-shell system . . `[`. $numimages -lt $MAX_DIALOG_HEIGHT ]; then |
| 1037 | height=$numimages |
| 1038 | else |
| 1039 | height="$MAX_DIALOG_HEIGHT" |
| 1040 | fi |
| 1041 | $DIA \ |
| 1042 | --backtitle "$msg_nchc_title" \ |
| 1043 | --title "$msg_netinstall" \ |
| 1044 | --menu "$msg_choose_netinstall_imag" 0 80 $height \ |
| 1045 | $MENU 2> $TMP |
| 1046 | OS_netinstall="$(catscip-shell system . . cat. $TMP)" |
| 1047 | fi |
| 1048 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 1049 | else |
| 1050 | if [scip-shell system . . `[`. -n "$(echoscip-shell system . . echo. $netinstall_list | grepscip-shell system . . grep. -Ew "$MODE2")" ]; then |
| 1051 | # only if MODE2 containing netinstall and the image block exists in pxelinux.cfg/default. |
| 1052 | OS_netinstall="$MODE2" |
| 1053 | else |
| 1054 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 1055 | echoscip-shell system . . echo. "netinstall \"$MODE2\" is not found in $PXELINUX_DIR/default!" |
| 1056 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 1057 | echoscip-shell system . . echo. "Available netinstall are: `echoscip-shell system . . echo. $netinstall_list`" # make it show in one line |
| 1058 | echoscip-shell system . . echo. "$msg_program_stop!" |
| 1059 | exit 1 |
| 1060 | fi |
| 1061 | fi |
| 1062 | [scip-shell system . . `[`. -z "$OS_netinstall" ] && echoscip-shell system . . echo. "No distribution is selected! Program terminated!!!" && exit 1 |
| 1063 | echoscip-shell system . . echo. "This network installation is for: $OS_netinstall" |
| 1064 | echoscip-shell system . . echo. "Setting client to the mode for installing this distribution via network..." |
| 1065 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 1066 | echoscip-shell system . . echo. -n "Set the PXE/uEFI netboot environment..." |
| 1067 | set-default-pxe-img -i $OS_netinstall -c $PXE_CONF |
| 1068 | set-default-grub-efi-img -i $OS_netinstall -c $GRUB_CONF |
| 1069 | echoscip-shell system . . echo. "done!" |
| 1070 | deploy_pxecfg_grubefi_files |
| 1071 | ;; |
| 1072 | "clonezilla-start") |
| 1073 | [scip-shell system . . `[`. -z "$ocs_user_mode" ] && ask_if_beginner_or_expert_mode |
| 1074 | if [scip-shell system . . `[`. -z "$MODE2" ]; then |
| 1075 | TMP=$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.) |
| 1076 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 1077 | $DIA \ |
| 1078 | --backtitle "$msg_nchc_title" \ |
| 1079 | --title "$msg_start_clonezilla_mode" \ |
| 1080 | --menu "$msg_clonezilla_is_free_and_no_warranty\n$msg_choose_mode:" 0 0 0 \ |
| 1081 | "save-disk" "$msg_clonezilla_save_disk" \ |
| 1082 | "save-parts" "$msg_clonezilla_save_parts" \ |
| 1083 | "restore-disk" "$msg_clonezilla_restore_disk" \ |
| 1084 | "restore-parts" "$msg_clonezilla_restore_parts" \ |
| 1085 | "select-in-client" "$msg_clonezilla_selec_in_client" \ |
| 1086 | 2> $TMP |
| 1087 | ocs_mode=$(catscip-shell system . . cat. $TMP) |
| 1088 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 1089 | else |
| 1090 | ocs_mode="$MODE2" |
| 1091 | fi |
| 1092 | # ocs_mode_prompt is to be shown in the title of dialog menu later |
| 1093 | ocs_mode_prompt="$ocs_mode" |
| 1094 | [scip-shell system . . `[`. -z "$ocs_mode" ] && echoscip-shell system . . echo. "No Clonezilla mode is selected! Program terminated!!!" && exit 1 |
| 1095 | echoscip-shell system . . echo. "Now the Clonezilla mode is: $ocs_mode" |
| 1096 | case "$ocs_mode" in |
| 1097 | # keep clonezilla-* for backword compatible |
| 1098 | "clonezilla-save-disk"|"save-disk") |
| 1099 | do_clonezilla_save_devscip-shell shell shell-project 0.0.0 do_clonezilla_save_dev(). disk |
| 1100 | ;; |
| 1101 | "clonezilla-restore-disk"|"restore-disk") |
| 1102 | do_clonezilla_restore_devscip-shell shell shell-project 0.0.0 do_clonezilla_restore_dev(). disk |
| 1103 | ;; |
| 1104 | "clonezilla-save-parts"|"save-parts") |
| 1105 | do_clonezilla_save_devscip-shell shell shell-project 0.0.0 do_clonezilla_save_dev(). parts |
| 1106 | ;; |
| 1107 | "clonezilla-restore-parts"|"restore-parts") |
| 1108 | do_clonezilla_restore_devscip-shell shell shell-project 0.0.0 do_clonezilla_restore_dev(). parts |
| 1109 | ;; |
| 1110 | "select-in-client") |
| 1111 | do_clonezilla_select_in_clientscip-shell shell shell-project 0.0.0 do_clonezilla_select_in_client(). |
| 1112 | ;; |
| 1113 | esac |
| 1114 | ;; |
| 1115 | |
| 1116 | "clonezilla-stop") |
| 1117 | echoscip-shell system . . echo. -n "Trying to stop the clonezilla mode..." |
| 1118 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 1119 | # When clonezilla stops, we should make clients boot locally |
| 1120 | set-default-pxe-img -i local -c $PXE_CONF |
| 1121 | set-default-grub-efi-img -i local-disk -c $GRUB_CONF |
| 1122 | deploy_pxecfg_grubefi_files |
| 1123 | echoscip-shell system . . echo. "done!" |
| 1124 | ;; |
| 1125 | |
| 1126 | "local") |
| 1127 | echoscip-shell system . . echo. -n "Setting client as local mode..." |
| 1128 | stop_ocs_if_necessaryscip-shell shell shell-project 0.0.0 stop_ocs_if_necessary(). |
| 1129 | set-default-pxe-img -i local -c $PXE_CONF |
| 1130 | set-default-grub-efi-img -i local-disk -c $GRUB_CONF |
| 1131 | deploy_pxecfg_grubefi_files |
| 1132 | echoscip-shell system . . echo. "done!" |
| 1133 | ;; |
| 1134 | "reboot") |
| 1135 | echoscip-shell system . . echo. "Rebooting clients if they are up and running... 3 types of clients are possible..." |
| 1136 | echoscip-shell system . . echo. "(1) For DRBL clients... (Commands run in background)" |
| 1137 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1138 | drbl-doit -b -u root -h "$IP_LIST" reboot & |
| 1139 | else |
| 1140 | drbl-doit -b -u root reboot & |
| 1141 | fi |
| 1142 | echoscip-shell system . . echo. "(2) For Cygwin clients... (Commands run in background)" |
| 1143 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1144 | drbl-doit -b -u $MSWIN_ADMIN_ID -h "$IP_LIST" /usr/bin/shutdownscip-shell filesystem . . `/usr/bin/shutdown`. -f -r now & |
| 1145 | else |
| 1146 | drbl-doit -b -u $MSWIN_ADMIN_ID /usr/bin/shutdownscip-shell filesystem . . `/usr/bin/shutdown`. -f -r now & |
| 1147 | fi |
| 1148 | echoscip-shell system . . echo. "(3) For Clonezilla live clients of Clonezilla SE... (Commands run in background)" |
| 1149 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1150 | drbl-doit -b -u $ocs_live_username -p $ocs_live_passwd -h "$IP_LIST" sudo reboot & |
| 1151 | else |
| 1152 | drbl-doit -b -u $ocs_live_username -p $ocs_live_passwd sudo reboot & |
| 1153 | fi |
| 1154 | ;; |
| 1155 | "shutdown") |
| 1156 | echoscip-shell system . . echo. "Shutdowning clients if they are up and running... 3 types of clients are possible..." |
| 1157 | echoscip-shell system . . echo. "(1) For DRBL clients... (Commands run in background)" |
| 1158 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1159 | drbl-doit -b -u root -h "$IP_LIST" poweroff & |
| 1160 | else |
| 1161 | drbl-doit -b -u root poweroff & |
| 1162 | fi |
| 1163 | echoscip-shell system . . echo. "(2) For Cygwin clients... (Commands run in background)" |
| 1164 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1165 | drbl-doit -b -u $MSWIN_ADMIN_ID -h "$IP_LIST" /usr/bin/shutdownscip-shell filesystem . . `/usr/bin/shutdown`. -f -s -x now & |
| 1166 | else |
| 1167 | drbl-doit -b -u $MSWIN_ADMIN_ID /usr/bin/shutdownscip-shell filesystem . . `/usr/bin/shutdown`. -f -s -x now & |
| 1168 | fi |
| 1169 | echoscip-shell system . . echo. "(3) For Clonezilla live clients of Clonezilla SE... (Commands run in background)" |
| 1170 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1171 | drbl-doit -b -u $ocs_live_username -p $ocs_live_passwd -h "$IP_LIST" sudo poweroff & |
| 1172 | else |
| 1173 | drbl-doit -b -u $ocs_live_username -p $ocs_live_passwd sudo poweroff & |
| 1174 | fi |
| 1175 | ;; |
| 1176 | "Wake-on-LAN") |
| 1177 | echoscip-shell system . . echo. "Turn on DRBL clients by Wake-on-LAN now..." |
| 1178 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1179 | drbl-doit -b -h "$IP_LIST" --wol |
| 1180 | else |
| 1181 | drbl-doit -b --wol |
| 1182 | fi |
| 1183 | echoscip-shell system . . echo. "done!" |
| 1184 | ;; |
| 1185 | "more") |
| 1186 | if [scip-shell system . . `[`. -z "$MODE2" ]; then |
| 1187 | TMP="$(mktempscip-shell system . . mktemp. /tmp/menu.XXXXXXscip-shell filesystem . . `/tmp/menu.XXXXXX`.)" |
| 1188 | trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT |
| 1189 | $DIA \ |
| 1190 | --backtitle "$msg_nchc_title" \ |
| 1191 | --title "$msg_nchc_drbl" \ |
| 1192 | --menu "$msg_switch_client_mode:" 0 0 0 \ |
| 1193 | "switch-pxe-menu" "$msg_switch_pxe_menu" \ |
| 1194 | "switch-pxe-bg-mode" "$msg_switch_pxe_bg_mode" \ |
| 1195 | "drbl-mode" "$msg_drbl_mode_switch" \ |
| 1196 | "clonezilla-mode" "$msg_clonezilla_mode_switch" \ |
| 1197 | "gen-template-files" "$msg_gen_template_files" \ |
| 1198 | $login_switch_1 $login_switch_2 \ |
| 1199 | $client_reautologin_1 $client_reautologin_2 \ |
| 1200 | $clean_autologin_account_1 $clean_autologin_account_2 \ |
| 1201 | $reset_autologin_account_1 $reset_autologin_account_2 \ |
| 1202 | "switch-drbl-serv" "$msg_switch_drbl_service" \ |
| 1203 | "re-deploy" "$msg_re_deploy" \ |
| 1204 | "clean-dhcpd-lease" "$msg_clean_dhcpd_lease" \ |
| 1205 | "gen_3N_conf" "$msg_regenerate_nfs_nis_nat_config" \ |
| 1206 | 2> $TMP |
| 1207 | OTHER_MODE=$(catscip-shell system . . cat. $TMP) |
| 1208 | [scip-shell system . . `[`. -f "$TMP" ] && rmscip-shell system . . rm. -f $TMP |
| 1209 | else |
| 1210 | OTHER_MODE=$MODE2 |
| 1211 | fi |
| 1212 | case "$OTHER_MODE" in |
| 1213 | "switch-pxe-menu") |
| 1214 | echoscip-shell system . . echo. "Switch DRBL client menus..." |
| 1215 | TMP_PXEMENU="$(mktempscip-shell system . . mktemp. /tmp/pxemenu.XXXXXXscip-shell filesystem . . `/tmp/pxemenu.XXXXXX`.)" |
| 1216 | trap "[ -f "$TMP_PXEMENU" ] && rm -f $TMP_PXEMENU" HUP INT QUIT TERM EXIT |
| 1217 | switch-pxe-menu -c $PXE_CONF -l $lang -o $TMP_PXEMENU $DIA_OPT $MORE_OPT_for_MODE2 |
| 1218 | rc=$? |
| 1219 | if [scip-shell system . . `[`. -e "$TMP_PXEMENU" ]; then |
| 1220 | # Convert PXE ID to grub NB ID |
| 1221 | perlscip-shell system . . perl. -pi -e "s/drbl/drbl-client/g; \ |
| 1222 | s/clonezilla/clonezilla-se-client/g; \ |
| 1223 | s/local/local-disk/g" $TMP_PXEMENU |
| 1224 | # Load them |
| 1225 | . $TMP_PXEMENU # Obtain "action" and "image_selected" |
| 1226 | switch-efi-nb-menu -c $GRUB_CONF -l $lang -i "$image_selected" $action $DIA_OPT $MORE_OPT_for_MODE2 |
| 1227 | fi |
| 1228 | [scip-shell system . . `[`. "$rc" -eq 0 ] && deploy_pxecfg_grubefi_files |
| 1229 | [scip-shell system . . `[`. -e "$TMP_PXEMENU" ] && rmscip-shell system . . rm. -f $TMP_PXEMENU |
| 1230 | ;; |
| 1231 | "switch-pxe-bg-mode") |
| 1232 | run-switch-pxe-bg-modescip-shell shell shell-project 0.0.0 run-switch-pxe-bg-mode(). $MORE_OPT_for_MODE2 ;; |
| 1233 | "drbl-mode") |
| 1234 | run_drbl_mode_switchscip-shell shell shell-project 0.0.0 run_drbl_mode_switch(). $MORE_OPT_for_MODE2 ;; |
| 1235 | "clonezilla-mode") |
| 1236 | run_clonezilla_mode_switchscip-shell shell shell-project 0.0.0 run_clonezilla_mode_switch(). $MORE_OPT_for_MODE2 ;; |
| 1237 | "gen-template-files") |
| 1238 | drbl-gen-ssi-files $MORE_OPT_for_MODE2 ;; |
| 1239 | "client-reautologin") |
| 1240 | if [scip-shell system . . `[`. "$LIST_HOST" = "on" ]; then |
| 1241 | drbl-client-reautologin -h "$IP_LIST" |
| 1242 | else |
| 1243 | drbl-client-reautologin |
| 1244 | fi |
| 1245 | ;; |
| 1246 | "clean-autologin-account") |
| 1247 | drbl-clean-autologin-account -l $lang ;; |
| 1248 | "reset-autologin-account") |
| 1249 | drbl-user-env-reset -l $lang --auto-login ;; |
| 1250 | "switch-drbl-serv") |
| 1251 | run_switch_drbl_servicescip-shell shell shell-project 0.0.0 run_switch_drbl_service(). $MORE_OPT_for_MODE2 ;; |
| 1252 | "re-deploy") |
| 1253 | if [scip-shell system . . `[`. ! -f "$drbl_syscfg/drblpush.conf" ]; then |
| 1254 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 1255 | echoscip-shell system . . echo. "Previously saved config file $drbl_syscfg/drblpush.conf is NOT found. Did you run \"drblpush -i\" before ?" |
| 1256 | echoscip-shell system . . echo. "Program Terminated!!!" |
| 1257 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 1258 | exit 1 |
| 1259 | fi |
| 1260 | drblpush --ln $lang -c $drbl_syscfg/drblpush.conf |
| 1261 | ;; |
| 1262 | "clean-dhcpd-lease") |
| 1263 | drbl-clean-dhcpd-leases ;; |
| 1264 | "gen_3N_conf") |
| 1265 | drbl-3n-conf generate ;; |
| 1266 | "login-switch") |
| 1267 | run_login_switchscip-shell shell shell-project 0.0.0 run_login_switch(). $MORE_OPT_for_MODE2;; |
| 1268 | esac |
| 1269 | ;; |
| 1270 | *) |
| 1271 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). |
| 1272 | ;; |
| 1273 | esac |
| 1274 | # |
| 1275 | [scip-shell system . . `[`. -f "$HOSTS_TMP" ] && rmscip-shell system . . rm. -f $HOSTS_TMP |
| 1276 | |
| 1277 | exit 0 |