| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Author: Steven Shiau <steven _at_ clonezilla org> |
| 3 | # License: GPL |
| 4 | # Description: set the default pxe image for simple menu format. |
| 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 | USAGEscip-shell shell shell-project 0.0.0 USAGE().() { |
| 16 | echoscip-shell system . . echo. "Usage:" |
| 17 | echoscip-shell system . . echo. "To set the default PXE client menu:" |
| 18 | echoscip-shell system . . echo. "`basenamescip-shell system . . basename. $0` [OPTION]" |
| 19 | echoscip-shell system . . echo. " Options:" |
| 20 | echoscip-shell system . . echo. " -i, --image IMG Set IMG as the default one" |
| 21 | echoscip-shell system . . echo. " -c, --config CONF Use the CONF file instead of default one ($PXE_CONF_DEF)" |
| 22 | echoscip-shell system . . echo. " -l, --label LABEL Assign the menu LABEL description" |
| 23 | echoscip-shell system . . echo. " -n, --no-simple-menu Turn off simple menu" |
| 24 | echoscip-shell system . . echo. " -s, --simple-menu Turn on simple menu" |
| 25 | echoscip-shell system . . echo. " -v, --verbose Show verbose messages" |
| 26 | echoscip-shell system . . echo. " -h, --help Display this help and exit" |
| 27 | } |
| 28 | |
| 29 | SIMPLE_MENU="" |
| 30 | # Parse command-line options |
| 31 | while [scip-shell system . . `[`. $# -gt 0 ]; do |
| 32 | case "$1" in |
| 33 | -i|--image) |
| 34 | shift; |
| 35 | # skip the -xx option, in case |
| 36 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 37 | IMG="$1" |
| 38 | shift |
| 39 | fi |
| 40 | ;; |
| 41 | -c|--config) |
| 42 | shift; |
| 43 | # skip the -xx option, in case |
| 44 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 45 | PXE_CONF="$1" |
| 46 | shift |
| 47 | fi |
| 48 | ;; |
| 49 | -n|--no-simple-menu) |
| 50 | SIMPLE_MENU="off" |
| 51 | shift;; |
| 52 | -s|--simple-menu) |
| 53 | SIMPLE_MENU="on" |
| 54 | shift;; |
| 55 | -h|--help) |
| 56 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). >& 2 |
| 57 | exit 2 ;; |
| 58 | -l|--label) |
| 59 | shift; |
| 60 | # skip the -xx option, in case |
| 61 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 62 | MENU_LABEL="$1" |
| 63 | shift |
| 64 | fi |
| 65 | ;; |
| 66 | -v|--verbose) |
| 67 | VERBOSE="on" |
| 68 | shift;; |
| 69 | -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2 |
| 70 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). >& 2 |
| 71 | exit 2 ;; |
| 72 | *) break ;; |
| 73 | esac |
| 74 | done |
| 75 | |
| 76 | [scip-shell system . . `[`. -z "$PXE_CONF" ] && PXE_CONF=$PXE_CONF_DEF |
| 77 | if [scip-shell system . . `[`. -z "$IMG" ]; then |
| 78 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 79 | echoscip-shell system . . echo. "You must specify the image name! Program terminated!!!" |
| 80 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 81 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). |
| 82 | exit 1 |
| 83 | fi |
| 84 | |
| 85 | sub_default_pxe_img $IMG $PXE_CONF "$MENU_LABEL" |
| 86 | |
| 87 | # process simple menu |
| 88 | if [scip-shell system . . `[`. "$SIMPLE_MENU" = "off" ]; then |
| 89 | perlscip-shell system . . perl. -pi -e "s/^default .*/default $IMG/g" $PXE_CONF |
| 90 | elif [scip-shell system . . `[`. "$SIMPLE_MENU" = "on" ]; then |
| 91 | perlscip-shell system . . perl. -pi -e "s/^default .*/default vesamenu.c32/g" $PXE_CONF |
| 92 | fi |