File: set-default-pxe-img

package info (click to toggle)
drbl 5.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,996 kB
  • sloc: sh: 43,555; perl: 8,820; xml: 867; makefile: 135
file content (92 lines) | stat: -rwxr-xr-x 2,441 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# Author: Steven Shiau <steven _at_ clonezilla org>
# License: GPL
# Description: set the default pxe image for simple menu format.

# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions

#
PXE_CONF_DEF="$PXELINUX_DIR/default"

#
USAGE() {
    echo "Usage:"
    echo "To set the default PXE client menu:"
    echo "`basename $0` [OPTION]"
    echo " Options:"
    echo " -i, --image IMG   Set IMG as the default one"
    echo " -c, --config CONF Use the CONF file instead of default one ($PXE_CONF_DEF)"
    echo " -l, --label LABEL Assign the menu LABEL description"  
    echo " -n, --no-simple-menu Turn off simple menu"
    echo " -s, --simple-menu Turn on simple menu"
    echo " -v, --verbose     Show verbose messages"
    echo " -h, --help        Display this help and exit"
}

SIMPLE_MENU=""
# Parse command-line options
while [ $# -gt 0 ]; do
  case "$1" in
    -i|--image)  
            shift;
            # skip the -xx option, in case 
	    if [ -z "$(echo $1 |grep ^-.)" ]; then
	      IMG="$1"
	      shift
            fi
            ;;
    -c|--config)  
            shift;
            # skip the -xx option, in case 
	    if [ -z "$(echo $1 |grep ^-.)" ]; then
              PXE_CONF="$1" 
	      shift
            fi
            ;;
    -n|--no-simple-menu)  
            SIMPLE_MENU="off" 
	    shift;;
    -s|--simple-menu)  
            SIMPLE_MENU="on" 
	    shift;;
    -h|--help)  
            USAGE >& 2
            exit 2 ;;
    -l|--label)  
            shift;
            # skip the -xx option, in case 
	    if [ -z "$(echo $1 |grep ^-.)" ]; then
	      MENU_LABEL="$1" 
	      shift
            fi
            ;;
    -v|--verbose)  
            VERBOSE="on"
	    shift;;
    -*)     echo "${0}: ${1}: invalid option" >&2
            USAGE >& 2
            exit 2 ;;
    *)      break ;;
  esac
done

[ -z "$PXE_CONF" ] && PXE_CONF=$PXE_CONF_DEF
if [ -z "$IMG" ]; then
   [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
   echo "You must specify the image name! Program terminated!!!"
   [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
   USAGE
   exit 1
fi

sub_default_pxe_img $IMG $PXE_CONF "$MENU_LABEL"

# process simple menu
if [ "$SIMPLE_MENU" = "off" ]; then 
  perl -pi -e "s/^default .*/default $IMG/g" $PXE_CONF
elif [ "$SIMPLE_MENU" = "on" ]; then
  perl -pi -e "s/^default .*/default vesamenu.c32/g" $PXE_CONF
fi