| 1 | #!/bin/bash |
| 2 | # Author: Steven Shiau <steven _at_ clonezilla org> |
| 3 | # License: GPL |
| 4 | |
| 5 | # |
| 6 | DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" |
| 7 | |
| 8 | . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions |
| 9 | [ -e /etc/drbl/drbl-ocs.conf ] && . /etc/drbl/drbl-ocs.conf |
| 10 | [ -e $DRBL_SCRIPT_PATH/sbin/ocs-functions ] && . $DRBL_SCRIPT_PATH/sbin/ocs-functions |
| 11 | |
| 12 | # 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... |
| 13 | [ -e "/etc/ocs/ocs-live.conf" ] && . /etc/ocs/ocs-live.conf |
| 14 | |
| 15 | # functions |
| 16 | USAGE() { |
| 17 | echo "To start, restart or stop DRBL service in DRBL Live environment." |
| 18 | echo "Usage:" |
| 19 | echo "$0 [OPTION] {start|stop|restart}" |
| 20 | echo "OPTION:" |
| 21 | echo "-b, -batch, --batch Run program in batch mode, i.e. without any prompt or wait for pressing enter key. //NOTE// You have to use '-batch' instead of '-b' when you want to use it in the boot parameters. Otherwise the program init on system will honor '-b', too." |
| 22 | echo "-c, -client-no NO Assign the client number as NO for each network card connected to clients" |
| 23 | echo "-p, --prepare-ocsroot Prepare clonezilla image home dir also." |
| 24 | echo "-s, --skip-pause-in-the-end Skip showing the messsage and pause in the end of execuation." |
| 25 | echo "-n, --no-prompt-drbl-live Assume it's running for drbl live. (This is normally only used for clonezilla server edition script ocs-srv-live in DRBL live mode)" |
| 26 | echo "start Start DRBL services now" |
| 27 | echo "stop Stop DRBL services now" |
| 28 | echo "restart Restart DRBL services now" |
| 29 | echo "Example: To start all DRBL services in this DRBL Live server" |
| 30 | echo "$0 start" |
| 31 | } |
| 32 | |
| 33 | # set locale for clients |
| 34 | set_locale_for_clients() { |
| 35 | # Some of the code is referred to pakcage casper /usr/share/initramfs-tools/scripts/casper-bottom/14locales |
| 36 | # We use the locale from server as the default one in client. |
| 37 | if [ -e /etc/default/locale ]; then |
| 38 | grep_file=/etc/default/locale |
| 39 | elif [ -e /etc/environment ]; then # Old locales policy |
| 40 | grep_file=/etc/environment |
| 41 | fi |
| 42 | if [ -n "${grep_file}" ]; then |
| 43 | # use server's configured locale |
| 44 | locale=$(grep -s 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' ) |
| 45 | fi |
| 46 | if [ -z "$locale" ]; then |
| 47 | # Set a default one |
| 48 | locale=en_US.UTF-8 |
| 49 | fi |
| 50 | LANG="${locale}" |
| 51 | |
| 52 | # write the setting in clients. |
| 53 | for ih in $drblroot/*; do |
| 54 | echo "LANG=${LANG}" > $ih/${grep_file} |
| 55 | done |
| 56 | echo "Since some config files are modified in template client, recreating template tarball for DRBL SSI..." |
| 57 | drbl-gen-ssi-files |
| 58 | } # end of set_locale_for_clients |
| 59 | # |
| 60 | prep_live_system_for_drbl_clonezilla_clients(){ |
| 61 | # Sep/10/2015 Due to this /tmp/ or /dev/ missing issue, we switch to use live system for Clonezilla SE client |
| 62 | # http://lists.freedesktop.org/archives/systemd-devel/2015-September/034175.html |
| 63 | # Actually this method is easier and better for Clonezilla jobs. |
| 64 | # (1) Prepre the Clonezilla SE client with live system |
| 65 | # The kernel (Clonezilla-live-vmlinuz) and initrd (Clonezilla-live-initrd.img) from $LIVE_MEDIA will be linked as "DRBL-live-vmlinuz" and "DRBL-live-initrd.img" in drbl-ocs-live-prep |
| 66 | drbl-ocs-live-prep -p $LIVE_MEDIA |
| 67 | |
| 68 | # (2) Update the network boot menu for DRBL client with live system |
| 69 | # Prepare the keyboard and locales for DRBL clients |
| 70 | if [ -n "$(printenv LC_ALL)" ]; then |
| 71 | client_locale="$(printenv LC_ALL)" |
| 72 | elif [ -n "$(printenv LANG)" ]; then |
| 73 | client_locale="$(printenv LANG)" |
| 74 | else |
| 75 | # If both LC_ALL and LANG are not found, force to set en_US.UTF-8 |
| 76 | client_locale="en_US.UTF-8" |
| 77 | fi |
| 78 | if [ -e /etc/default/keyboard ]; then |
| 79 | . /etc/default/keyboard |
| 80 | client_kb_layout="$XKBLAYOUT" |
| 81 | client_kb_model="$XKBMODEL" |
| 82 | client_kb_variant="$XKBVARIANT" |
| 83 | client_kb_options="$XKBOPTIONS" |
| 84 | fi |
| 85 | if [ -z "$client_kb_layout" ]; then |
| 86 | # If no keybouard layout is found, set it as us. |
| 87 | client_kb_layout=us |
| 88 | # For the rest (model, variant or options they might be nothing. |
| 89 | fi |
| 90 | # We will make pxelinux config like this for DRBL client: |
| 91 | # APPEND initrd=DRBL-live-initrd.img boot=live union=overlay username=drbl config components nomodeset quiet nosplash keyboard-layouts=NONE locales=en_US.UTF-8 drbl_live_noconfx ocs_daemonon="ssh" noeject netboot=nfs nfsroot=192.168.7.254:/tftpboot/node_root/clonezilla-live/ dcs_put_dticons="no" |
| 92 | |
| 93 | PXE_CONF="$PXE_CONF_DEF" |
| 94 | GRUB_CONF="$GRUB_EFINB_CONF_DEF" |
| 95 | # TODO: find a better way to give different nfs_srv IP address if more than one available, so that clients can be grouped to different NFS server. |
| 96 | live_nfs_srv="$(get-all-nic-ip -b | awk -F" " '{print $1}')" |
| 97 | # Find the boot parameters from the server, and re-use it for client. |
| 98 | # It maybe be customized by users, so we have to filter some more, like ocs_prerun*, and some will be added later, like "drbl_live_noconfx" so we force to remove it to avoid duplicated. |
| 99 | # E.g: |
| 100 | # BOOT_IMAGE=/live/vmlinuz initrd=/live/initrd.img boot=live union=overlay username=user config components nomodeset quiet vga=785 ip= net.ifnames=0 nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 keyboard-layouts=NONE locales=en_US.UTF-8 drbl_live_noconfx ocs_daemonon="ssh" ocs_prerun1="ifconfig eth0 192.168.120.3; route add default gw 192.168.120.254 eth0; ifconfig eth1 192.168.7.254 netmask 255.255.255.0; echo nameserver 8.8.8.8 > /etc/resolv.conf" ocs_prerun2="mount -t nfs 192.168.120.254:/home/partimag /home/partimag" ocs_prerun3="drbl-live --batch --skip-pause-in-the-end --no-prompt-drbl-live start" ocs_prerun5="perl -pi -e 's/timeout 70/timeout 10/' /tftpboot/nbi_img/pxelinux.cfg/default" |
| 101 | cl_gp_boot_param="$(LC_ALL=C cat /proc/cmdline | filter_cl_gp_boot_param)" |
| 102 | # Append those preseeding boot param we want for live system client |
| 103 | # //NOTE// This is only for DRBL part. For that about Clonezilla part, it's parsed in drbl-sl. Just search "clonezilla_se_live_opts" or "stick-to-pxe-srv" in drbl-sl. |
| 104 | cl_gp_boot_param="$cl_gp_boot_param hostname=drbl-client username=drbl \ |
| 105 | keyboard-layouts=$client_kb_layout locales=$client_locale drbl_live_noconfx \ |
| 106 | stick-to-pxe-srv dhcp-vendor-id=DRBLClient ocs_daemonon=\"ssh\" noeject netboot=nfs \ |
| 107 | nfsroot=${live_nfs_srv}:$drbl_common_root/clonezilla-live/ \ |
| 108 | dcs_put_dticons=\"no\"" |
| 109 | # This is for the boot parameters in grub config, i.e. those in the "linux" line, e.g. |
| 110 | # linux vmlinuz-pxe boot=live union=overlay config components nomodeset quiet |
| 111 | boot_param_in_grub_cfg="DRBL-live-vmlinuz $cl_gp_boot_param" |
| 112 | # This is the boot parameters for PXElinux config, i.e. those in the "append" line, e.g. |
| 113 | # append initrd=/live/initrd.img boot=live union=overlay config components nomodeset quiet |
| 114 | boot_param_in_pxe_cfg="initrd=DRBL-live-initrd.img $cl_gp_boot_param" |
| 115 | |
| 116 | override_opt_in_pxelinux_cfg_block drbl "$boot_param_in_pxe_cfg" |
| 117 | override_opt_in_pxelinux_cfg_block -k drbl "DRBL-live-vmlinuz" |
| 118 | override_opt_in_grub_efi_cfg_block drbl-client "$boot_param_in_grub_cfg" |
| 119 | override_opt_in_grub_efi_cfg_block -i drbl-client "DRBL-live-initrd.img" |
| 120 | |
| 121 | } # end of prep_live_system_for_drbl_clonezilla_clients |
| 122 | # |
| 123 | start_drbl_live() { |
| 124 | if [ "$prompt_drbl_live" = "yes" ]; then |
| 125 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 126 | echo "$msg_this_is_for_drbl_server_not_for_clonezilla_server_edition" |
| 127 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 128 | echo "$msg_are_u_sure_u_want_to_continue" |
| 129 | echo -n "[Y/n] " |
| 130 | read drbl_live_ans |
| 131 | case "$drbl_live_ans" in |
| 132 | n|N|[nN][oO]) echo "$msg_program_stop" |
| 133 | exit 1 ;; |
| 134 | *) echo "$msg_ok_let_do_it" ;; |
| 135 | esac |
| 136 | fi |
| 137 | |
| 138 | # config network first: |
| 139 | config_drbl_live_network |
| 140 | |
| 141 | # |
| 142 | if [ "$prepare_ocsroot" = "yes" ]; then |
| 143 | echo "Preparing clonezilla image home dir..." |
| 144 | prep-ocsroot --skip-ocsroot-mountpoint-chk # will check later to avoid the exit is only for prep-ocsroot program, not for this $0. |
| 145 | check_if_ocsroot_a_mountpoint |
| 146 | fi |
| 147 | |
| 148 | # |
| 149 | echo "$msg_delimiter_star_line" |
| 150 | echo $msg_now_continue_to_run_drblpush |
| 151 | echo $msg_this_might_take_several_minutes |
| 152 | if [ "$ocs_batch_mode" != "on" ]; then |
| 153 | echo -n $msg_press_enter_to_continue |
| 154 | read |
| 155 | fi |
| 156 | |
| 157 | # Make a tag in client's root to mark this is drbl-live system. Since this is live system, we do not have to clean it later. |
| 158 | get_live_media_mnt_point |
| 159 | if [ -z "$LIVE_MEDIA" ]; then |
| 160 | echo "///WARNING/// filesystem.squashfs not found! No idea where is LIVE_MEDIA!!!" |
| 161 | fi |
| 162 | echo "Live media is in $LIVE_MEDIA" |
| 163 | echo "This is drbl live system." > $drbl_common_root/drbl_ssi/drbl-live-system.txt |
| 164 | if [ -e "$LIVE_MEDIA/DRBL-Live-Version" ]; then |
| 165 | cat $LIVE_MEDIA/DRBL-Live-Version >> $drbl_common_root/drbl_ssi/drbl-live-system.txt |
| 166 | elif [ -e "$LIVE_MEDIA/live/DRBL-Live-Version" ]; then |
| 167 | cat $LIVE_MEDIA/live/DRBL-Live-Version >> $drbl_common_root/drbl_ssi/drbl-live-system.txt |
| 168 | else |
| 169 | [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 170 | echo "File \"$LIVE_MEDIA/DRBL-Live-Version\" or \"$LIVE_MEDIA/live/DRBL-Live-Version\" _NOT_ found!" |
| 171 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 172 | echo -n $msg_press_enter_to_continue |
| 173 | read |
| 174 | fi |
| 175 | |
| 176 | # Before we run drblpush, we have to remove the services we put only for DRBL live server when creating drbl live. This will avoide those to be copied to SSI template tarball. Since these services are one-time use only for server during booting. |
| 177 | rm -f /etc/rcS.d/*kbd-conf |
| 178 | rm -f /etc/rcS.d/*Forcevideo-drbl-live |
| 179 | |
| 180 | # Before running drblpush, first we add a group for the autologin accounts |
| 181 | if [ -z "$(grep -E "^$autologin_group:" /etc/group)" ]; then |
| 182 | groupadd "$autologin_group" |
| 183 | fi |
| 184 | |
| 185 | # Now we can add the group "$autologin_group" to sudo |
| 186 | if [ -e /etc/sudoers -a -x /usr/sbin/xfsm-shutdown-helper ]; then |
| 187 | if [ -z "$(grep -E "^%$autologin_group ALL=NOPASSWD:.*xfsm-shutdown-helper" /etc/sudoers)" ]; then |
| 188 | chmod u+w /etc/sudoers |
| 189 | echo "# Added by DRBL" >> /etc/sudoers |
| 190 | echo "%$autologin_group ALL=NOPASSWD:/usr/sbin/xfsm-shutdown-helper" >> /etc/sudoers |
| 191 | chmod u-w /etc/sudoers |
| 192 | fi |
| 193 | fi |
| 194 | |
| 195 | # 2015/Sep/14 We have update the use_run_in_initrd and use_dev_pts_in_initrd by default to fit that in Sid, therefore comment this. |
| 196 | # Run mknic-nbi again. Because we run mknic-nbi in the chroot when creating DRBL live. However, the variable use_run_in_initrd and use_dev_pts_in_initrd in initramfs' /etc/linuxrc.conf (i.e. "/usr/lib/mkpxeinitrd-net/initrd-skel/etc/linuxrc.conf") need to be updated in the run time. |
| 197 | #echo |
| 198 | #echo "Updating the initramfs for PXE clients..." |
| 199 | #mknic-nbi -p 1 |
| 200 | |
| 201 | prep_live_system_for_drbl_clonezilla_clients |
| 202 | |
| 203 | # 1st we load $client_no_per_NIC and $autologin_passwd_opt from the ocs-live-hook.conf when creating DRBL live. |
| 204 | # However, later if client_no_per_NIC is assigned in boot parameter or "-c" option, it will be override. |
| 205 | . $drbl_setup_path/files/ocs/live-hook/ocs-live-hook.conf |
| 206 | |
| 207 | # ocs_client_no_per_NIC is read from /etc/ocs/ocs-live.conf, which might be from boot parameter, or is assigned by this program with option "-c" |
| 208 | if [ -n "$ocs_client_no_per_NIC" ]; then |
| 209 | if [ -n "$(grep -Ew "^client_no_per_NIC=.*" /etc/ocs/ocs-live.conf)" ]; then |
| 210 | LC_ALL=C perl -pi -e "s/^client_no_per_NIC=.*/client_no_per_NIC=$ocs_client_no_per_NIC/g" /etc/ocs/ocs-live.conf |
| 211 | else |
| 212 | echo "client_no_per_NIC=$ocs_client_no_per_NIC" >> /etc/ocs/ocs-live.conf |
| 213 | fi |
| 214 | fi |
| 215 | # Now load $client_no_per_NIC for later use |
| 216 | . /etc/ocs/ocs-live.conf |
| 217 | |
| 218 | # run drblpush again so that the network interface can be updated. Maybe there is new ethx. |
| 219 | yes "" | drblpush -i -r 1 -z 1 --not-add-start-drbl-srvi --skip-drbl-ocs-live-prep -p $client_no_per_NIC |
| 220 | |
| 221 | # The override from drbl live system should be removed. It's autologin for Live system, not for drbl client |
| 222 | rm -rf $drbl_common_root/etc/systemd/system/getty\@tty* |
| 223 | rm -rf $drbl_common_root/etc/systemd/system/serial-getty\@ttyS* |
| 224 | rm -rf $drblroot/*/etc/systemd/system/getty\@tty* |
| 225 | rm -rf $drblroot/*/etc/systemd/system/serial-getty\@ttyS* |
| 226 | |
| 227 | # Since we use Clonezilla box or live system for clients OS when doing Clonezilla jobs, they all listen to the boot parameters |
| 228 | # Therefore here we change ocs_client_trig_type as proc-cmdline to make drbl-ocs run a little bit faster. |
| 229 | perl -pi -e "s/^ocs_client_trig_type=.*/ocs_client_trig_type=proc-cmdline/g" /etc/drbl/drbl-ocs.conf |
| 230 | |
| 231 | echo "$msg_delimiter_star_line" |
| 232 | if [ "$limit_pxe_drbl_client" = "yes" ]; then |
| 233 | # modify dhcpd.conf, provide IP address to PXE/Etherboot/DRBL client only |
| 234 | echo "Modifying dhcpd.conf, now only PXE/Etherboot/DRBL client can lease IP address from this server..." |
| 235 | perl -pi -e 's/^([[:space:]]*)#[[:space:]]*(allow members of "DRBL-Client";)/$1$2/g' $DHCPDCONF_DIR/dhcpd.conf |
| 236 | else |
| 237 | echo "Modifying dhcpd.conf, now ANY client, not only PXE/Etherboot/DRBL client, can lease IP address from this server..." |
| 238 | perl -pi -e 's/^([[:space:]]*)#*[[:space:]]*(allow members of "DRBL-Client";)/$1#$2/g' $DHCPDCONF_DIR/dhcpd.conf |
| 239 | fi |
| 240 | |
| 241 | echo "$msg_delimiter_star_line" |
| 242 | echo "Enable auto login for drbl clients..." |
| 243 | # enable autologin |
| 244 | case "$autologin_passwd_opt" in |
| 245 | "random") |
| 246 | make_random_password $password_opt |
| 247 | passwd_autologin="$random_password" |
| 248 | ;; |
| 249 | *) |
| 250 | passwd_autologin="$passwd_autologin_def" |
| 251 | ;; |
| 252 | esac |
| 253 | drbl-login-switch -a --no_nis_update -p "${passwd_autologin}" |
| 254 | |
| 255 | # Add the auto login accounts in every client so that we can add them to the group "autologin" |
| 256 | echo -n "Adding the auto login accounts to the group $autologin_group..." |
| 257 | for ihost in `get-client-ip-list`; do |
| 258 | iaccount="$(get_existing_autologin_account $ihost)" |
| 259 | adduser $iaccount $autologin_group &>/dev/null |
| 260 | echo -n "." |
| 261 | done |
| 262 | echo " done!" |
| 263 | |
| 264 | echo "$msg_delimiter_star_line" |
| 265 | # turn on tcpwrapper |
| 266 | echo "Setting /etc/hosts.allow..." |
| 267 | mv -f /etc/hosts.allow /etc/hosts.allow.orig |
| 268 | client_IP_list="$(get-client-ip-list)" |
| 269 | client_IP_list="$(echo $client_IP_list)" # convert to 1 line |
| 270 | client_IP_list_ar=( $client_IP_list ) # put it in an array |
| 271 | # We can not list too long in hosts.allow, so put 20 elements in a line. |
| 272 | nloop="$(echo "scale=0; ${#client_IP_list_ar[@]}/20" | bc -l )" |
| 273 | echo "# Created by drbl-live" > /etc/hosts.allow |
| 274 | for i in `seq 1 $nloop`; do |
| 275 | istart="$(echo "scale=0; 20*$((i-1))" | bc -l)" |
| 276 | iend="$(echo "scale=0; 20*$((i-1))+19" | bc -l)" |
| 277 | echo -n "ALL: " >> /etc/hosts.allow |
| 278 | for j in `seq $istart $iend`; do |
| 279 | echo -n "${client_IP_list_ar[j]} " >> /etc/hosts.allow |
| 280 | done |
| 281 | echo >> /etc/hosts.allow |
| 282 | done |
| 283 | |
| 284 | # set locales for clients. |
| 285 | set_locale_for_clients |
| 286 | |
| 287 | # |
| 288 | echo "Start all DRBL related services by running 'drbl-all-service start'..." |
| 289 | drbl-all-service start |
| 290 | |
| 291 | # Now the YP service is up, we can update YP data. |
| 292 | make -C /var/yp |
| 293 | |
| 294 | # |
| 295 | echo "$msg_delimiter_star_line" |
| 296 | echo "$msg_done!" |
| 297 | |
| 298 | if [ "$pause_in_the_end" = "yes" ]; then |
| 299 | [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 300 | echo "$msg_all_set_you_can_turn_on_clients" |
| 301 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 302 | echo -n $msg_press_enter_to_continue |
| 303 | # This is a weird problem about tftpd-hpa when it is restared in 'drbl-all-service start' in the above. It's: |
| 304 | # ------- |
| 305 | # /etc/init.d/tftpd-hpa restart |
| 306 | # echo -n "press key... " |
| 307 | # read |
| 308 | # ------- |
| 309 | # and we always get such an error when running it: |
| 310 | # ------- |
| 311 | # Restarting HPA's tftpd: in.tftpd. |
| 312 | # press key... ./td: line 4: read: read error: 0: Resource temporarily unavailable |
| 313 | # ------- |
| 314 | # Therefore we use < /dev/stdin to avoid tihs. |
| 315 | read dummy_var < /dev/stdin |
| 316 | fi |
| 317 | } # end of start_drbl_live |
| 318 | # |
| 319 | stop_drbl_live() { |
| 320 | # block all the clients. |
| 321 | mv -f /etc/hosts.allow /etc/hosts.allow.orig2 |
| 322 | echo "# Disabled by drbl-live" > /etc/hosts.allow |
| 323 | |
| 324 | # stop and remove all services |
| 325 | echo "Stop DRBL service.." |
| 326 | drbl-all-service stop |
| 327 | echo "Removing DRBL-related services..." |
| 328 | drbl-all-service del |
| 329 | # |
| 330 | echo "$msg_delimiter_star_line" |
| 331 | echo "$msg_done!" |
| 332 | echo -n $msg_press_enter_to_continue |
| 333 | read |
| 334 | } # end of stop_drbl_live |
| 335 | |
| 336 | |
| 337 | ################# |
| 338 | ##### MAIN ###### |
| 339 | ################# |
| 340 | check_if_root |
| 341 | |
| 342 | # |
| 343 | ask_and_load_lang_set |
| 344 | |
| 345 | # Default settings. |
| 346 | prepare_ocsroot="no" |
| 347 | pause_in_the_end="yes" |
| 348 | prompt_drbl_live="yes" |
| 349 | autologin_group="autologin" |
| 350 | # |
| 351 | while [ $# -gt 0 ]; do |
| 352 | case "$1" in |
| 353 | -b|-batch|--batch) |
| 354 | ocs_batch_mode="on" |
| 355 | shift;; |
| 356 | -c|-client-no) |
| 357 | shift |
| 358 | if [ -z "$(echo $1 |grep ^-.)" ]; then |
| 359 | # skip the -xx option, in case |
| 360 | ocs_client_no_per_NIC="$1" |
| 361 | shift |
| 362 | fi |
| 363 | ;; |
| 364 | -p|--prepare-ocsroot) |
| 365 | prepare_ocsroot="yes" |
| 366 | shift ;; |
| 367 | -s|--skip-pause-in-the-end) |
| 368 | pause_in_the_end="no" |
| 369 | shift ;; |
| 370 | -n|--no-prompt-drbl-live) |
| 371 | prompt_drbl_live="no" |
| 372 | shift ;; |
| 373 | -*) echo "${0}: ${1}: invalid option" >&2 |
| 374 | USAGE >& 2 |
| 375 | exit 2 ;; |
| 376 | *) break ;; |
| 377 | esac |
| 378 | done |
| 379 | |
| 380 | switch=$1 |
| 381 | # |
| 382 | if [ -z "$switch" ]; then |
| 383 | USAGE |
| 384 | exit 1 |
| 385 | fi |
| 386 | |
| 387 | # |
| 388 | if ! is_boot_from_live; then |
| 389 | [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 390 | echo "This command $0 is used in DRBL Live environment only!" |
| 391 | [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 392 | echo "$msg_program_stop" |
| 393 | exit 1 |
| 394 | fi |
| 395 | |
| 396 | case "$switch" in |
| 397 | "start"|"restart") start_drbl_live ;; |
| 398 | "stop") stop_drbl_live ;; |
| 399 | esac |