Debian Codegraph @

sbin/drbl-client-system-select

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Steven Shiau <[email protected]>
3 # License: GPL
4 # Description: To set the clients show prompt for boot system or not
5
6 # Load DRBL setting and functions
7 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
8
9 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
10 #
11 check_if_root
12
13 #
14 usagescip-shell shell shell-project 0.0.0 usage().() {
15 echoscip-shell system . . echo. "Usage:"
16 echoscip-shell system . . echo. "To set the clients show prompt for boot system or not:"
17 echoscip-shell system . . echo. "`basenamescip-shell system . . basename. $0` [OPTION] [on|off]"
18 echoscip-shell system . . echo. " Options:"
19 echoscip-shell system . . echo. " -t, --time the time to show prompt for boot system (unit: 1/10 sec) "
20 echoscip-shell system . . echo. " -e, --enable-thin-client enable the thin client option in PXE boot menu"
21 echoscip-shell system . . echo. " -d, --disable-thin-client disable the thin client option in PXE boot menu"
22 echoscip-shell system . . echo. "-h, --hosts IP_LIST Instead of all DRBL clients, assign the clients by IP address, like: -h \"192.168.0.1 192.168.0.2\" NOTE!!! You must put \" \" before and after the IP_LIST!"
23 echoscip-shell system . . echo. " -v, --verbose prints out verbose information"
24 }
25
26 # Parse command-line options
27 while [scip-shell system . . `[`. $# -gt 0 ]; do
28 case "$1" in
29 -t|--time)
30 shift;
31 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
32 # skip the -xx option, in case
33 timeout="$1"
34 fi
35 shift ;;
36 -e|--enable-thin-client)
37 shift; thinclient="on"
38 ;;
39 -d|--disable-thin-client)
40 shift; thinclient="off"
41 ;;
42 -h|--hosts)
43 shift;
44 LIST_HOST="on"
45 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
46 # skip the -xx option, in case
47 IP_LIST="$1"
48 fi
49 shift ;;
50 -v|--verbose)
51 shift; VERBOSE="on"
52 ;;
53 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
54 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
55 exit 2 ;;
56 *) break ;;
57 esac
58 done
59
60 # get the switch
61 switch=$1
62 [scip-shell system . . `[`. -z "$switch" ] && usagescip-shell shell shell-project 0.0.0 usage(). && exit 0
63
64 #
65 if [scip-shell system . . `[`. -n "$IP_LIST" ]; then
66 # copy the skeleton file
67 PXE_CONF="$PXELINUX_DIR/default_skeleton"
68 cpscip-shell system . . cp. -f $PXELINUX_DIR/default $PXE_CONF
69 else
70 PXE_CONF="$PXELINUX_DIR/default"
71 # Clean all the previous saved config file.
72 # These files maybe look like: 01-MAC address, something like C0A8XXXX (only for 192.168.x), default_skeleton
73 echoscip-shell system . . echo. -n "Clean all the previous saved config file if they exist..."
74 for ifile in $PXELINUX_DIR/*; do
75 [scip-shell system . . `[`. "$ifile" != "$PXE_CONF" -a -f "$ifile" ] && rmscip-shell system . . rm. -f $ifile
76 done
77 echoscip-shell system . . echo. "done!"
78 fi
79
80 #
81 case "$switch" in
82 on)
83 echoscip-shell system . . echo. -n "Turn on the boot prompt for PXE client..."
84 [scip-shell system . . `[`. -z "$timeout" ] && timeout=$DEFAULT_PXE_TIMEOUT
85 timeout_sub="s/^timeout.*/timeout $timeout/"
86 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "mode = $switch"
87 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "timeout = $timeout"
88 perlscip-shell system . . perl. -pi -e "$timeout_sub" $PXE_CONF
89
90 # force prompt to always be 0, we need this for simple menu
91 perlscip-shell system . . perl. -pi -e 's/^(#|[[:space:]])*prompt.*/prompt 0/i' $PXE_CONF
92
93 # reveal some menus
94 for i in $IMG_SHOW_IN_MENU; do
95 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "Reveal image $i"
96 hide_reveal_pxe_img $i reveal $PXE_CONF
97 done
98 echoscip-shell system . . echo. "done!"
99 ;;
100
101 off)
102 echoscip-shell system . . echo. -n "Turn off the boot prompt for PXE client..."
103 # we just prompt 0.5 sec for that image... the only one image
104 timeout=5
105 timeout_sub="s/^timeout.*/timeout $timeout/"
106 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "mode = $switch"
107 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "timeout = $timeout"
108 perlscip-shell system . . perl. -pi -e "$timeout_sub" $PXE_CONF
109 perlscip-shell system . . perl. -pi -e 's/^prompt.*/prompt 0/' $PXE_CONF
110
111 # hide some menus, but at least we will reveal one "drbl", otherwise
112 # client will have problem "boot: EL entries found in configuration file!"
113 for i in $IMG_SHOW_IN_MENU; do
114 if [scip-shell system . . `[`. "$i" != "drbl" ]; then
115 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "Hide image $i"
116 hide_reveal_pxe_img $i hide $PXE_CONF
117 else
118 [scip-shell system . . `[`. -n "$VERBOSE" ] && echoscip-shell system . . echo. "Reveal image $i"
119 hide_reveal_pxe_img $i reveal $PXE_CONF
120 fi
121 done
122
123 echoscip-shell system . . echo. "done!"
124 ;;
125 esac
126
127 case "$thinclient" in
128 "on")
129 echoscip-shell system . . echo. -n "Turn on the thin client option in PXE menu..."
130 hide_reveal_pxe_img drbl-terminal reveal $PXE_CONF
131 echoscip-shell system . . echo. "done!"
132
133 ;;
134 "off")
135 echoscip-shell system . . echo. -n "Turn off the thin client option in PXE boot menu..."
136 hide_reveal_pxe_img drbl-terminal hide $PXE_CONF
137 echoscip-shell system . . echo. "done!"
138 ;;
139 esac
140
141 # specify the nodes if assigned by user
142 [scip-shell system . . `[`. "$LIST_HOST" = "on" ] && set_specific_host_pxe_conf $IP_LIST