Debian Codegraph @

scripts/bin/hide_reveal_pxe_img

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: Hide or reveal the menus in PXE Linux config file.
5 # Load DRBL setting and functions
6 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
7
8 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
9
10 # functions
11 prog="$(basenamescip-shell system . . basename. $0)"
12 USAGEscip-shell shell shell-project 0.0.0 USAGE().() {
13 echoscip-shell system . . echo. "Usage:"
14 echoscip-shell system . . echo. "$prog LABEL [hide|reveal] PXE_CONF_FILE"
15 echoscip-shell system . . echo. "Ex: To hide the label drbl in /tftpboot/nbi_img/pxelinux.cfg/default, run:"
16 echoscip-shell system . . echo. " $prog drbl hide /tftpboot/nbi_img/pxelinux.cfg/default"
17 }
18
19 lab="$1"
20 ACT="$2"
21 PXE_CONF="$3"
22 for i in lab ACT PXE_CONF; do
23 eval arg=\$$i
24 [scip-shell system . . `[`. -z "$arg" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1
25 done
26 if [scip-shell system . . `[`. ! -f "$PXE_CONF" ]; then
27 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
28 echoscip-shell system . . echo. "file $PXE_CONF not found!"
29 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
30 exit 1
31 fi
32 # Check in the other way, not using check_img_in_pxe_cfg since it gives red error, while we just need warning especially when "clonezilla-live" is not available for Clonezilla SE with Clonezilla live client.
33 #check_img_in_pxe_cfg $lab $PXE_CONF
34 # turn off MENU DEFAULT & turn on MENU HIDE for the specified image
35 lines="$(get_pxecfg_image_block $lab $PXE_CONF)"
36 begin_line="$(LC_ALL=C echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $1}')"
37 end_line="$(LC_ALL=C echoscip-shell system . . echo. $lines | awkscip-shell system . . awk. -F" " '{print $2}')"
38 case "$ACT" in
39 "hide")
40 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "Hide $lab in $PXE_CONF... "
41 if [scip-shell system . . `[`. -z "$begin_line" -o -z "$end_line" ]; then
42 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
43 echoscip-shell system . . echo. "No hidden label $lab was found! Skip it."
44 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
45 exit 2
46 fi
47 sub_act_cmd="if ($begin_line..$end_line) {s/^(#|[[:space:]])*MENU HIDE.*/ MENU HIDE/i}"
48 ;;
49 "reveal")
50 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "Reveal $lab in $PXE_CONF... "
51 if [scip-shell system . . `[`. -z "$begin_line" -o -z "$end_line" ]; then
52 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
53 echoscip-shell system . . echo. "No revealed label $lab was found! Skip it."
54 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
55 exit 2
56 fi
57 sub_act_cmd="if ($begin_line..$end_line) {s/^(#|[[:space:]])*MENU HIDE.*/ # MENU HIDE/i}"
58 ;;
59 esac
60 LC_ALL=C perlscip-shell system . . perl. -pi -e "$sub_act_cmd" $PXE_CONF