Debian Codegraph @

scripts/sbin/switch-pxe-bg-mode

raw symbols SCIP
1 #!/bin/bash
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: swith the pxe menu (simple menu format) to text or graphic mode
5
6 # Load DRBL setting and functions
7 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
8
9 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
10
11 #
12 PXE_CONF_DEF="$PXELINUX_DIR/default"
13
14 #
15 USAGE() {
16 echo "Usage:"
17 echo "To set the default PXE client menu:"
18 echo "`basename $0` [OPTION]"
19 echo " Options:"
20 echo " -m, --mode [text|graphic] Set the default mode to text or graphic"
21 echo " -c, --config CONF Use the CONF file instead of default one ($PXE_CONF_DEF)"
22 echo " -v, --verbose Show verbose messages"
23 echo " -h, --help Display this help and exit"
24 }
25
26 SIMPLE_MENU=""
27 # Parse command-line options
28 while [ $# -gt 0 ]; do
29 case "$1" in
30 -m|--mode)
31 shift;
32 # skip the -xx option, in case
33 if [ -z "$(echo $1 |grep ^-.)" ]; then
34 mode="$1"
35 shift
36 fi
37 ;;
38 -c|--config)
39 shift;
40 # skip the -xx option, in case
41 if [ -z "$(echo $1 |grep ^-.)" ]; then
42 PXE_CONF="$1"
43 shift
44 fi
45 ;;
46 -h|--help)
47 USAGE >& 2
48 exit 2 ;;
49 -v|--verbose)
50 VERBOSE="on"
51 shift;;
52 -*) echo "${0}: ${1}: invalid option" >&2
53 USAGE >& 2
54 exit 2 ;;
55 *) break ;;
56 esac
57 done
58
59 [ -z "$PXE_CONF" ] && PXE_CONF=$PXE_CONF_DEF
60 if [ -z "$mode" ]; then
61 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
62 echo "You must specify the mode! Program terminated!!!"
63 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
64 USAGE
65 exit 1
66 fi
67
68 # process mode
69 case "$mode" in
70 text|TEXT)
71 echo -n "Modifying $PXE_CONF to let DRBL client use text PXE boot menu... "
72 perl -pi -e 's/^default .*/default menu.c32/g' $PXE_CONF
73 # Turn off all the color settings, use the default value
74 perl -pi -e 's/^(MENU COLOR .*)/# $1/g' $PXE_CONF
75 echo "done!"
76 ;;
77 graphic|GRAPHIC)
78 echo -n "Modifying $PXE_CONF to let DRBL client use graphical PXE boot menu... "
79 perl -pi -e 's/^default .*/default vesamenu.c32/g' $PXE_CONF
80 # Turn on all the color settings
81 perl -pi -e 's/^[[:space:]]*#[[:space:]]*(MENU COLOR .*)/$1/g' $PXE_CONF
82 echo "done!"
83 ;;
84 esac