-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.iso.sh
executable file
·66 lines (62 loc) · 1.54 KB
/
make.iso.sh
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
#!/bin/bash
## prerequisites ##
# yum install -y xz-devel make gcc makeisofs syslinux
# detect and resolve symlink
if [[ $(readlink -f $0) =~ ^(.*)/([^/]+)$ ]]; then
WORKDIR="${BASH_REMATCH[1]}"
CALLED="${BASH_REMATCH[2]}"
fi
IPXEDIR="${WORKDIR}/ipxe/src"
MYDIR="$(pwd)"
# COLOURS
NC='\033[0m' # no colour
GREEN='\033[0;32m' # green
ORANGE='\033[0;33m' # orange
BLUE='\033[0;34m' # blue
CYAN='\e[0;36m' # cyan
function corange {
local STRING=${1}
printf "${ORANGE}${STRING}${NC}"
}
function cgreen {
local STRING=${1}
printf "${GREEN}${STRING}${NC}"
}
function ccyan {
local STRING=${1}
printf "${CYAN}${STRING}${NC}"
}
## check if ipxe exists, and download
if [[ ! -d ${IPXEDIR} ]]; then
printf "$(ccyan "IPXE not found, downloading now...")\n" 1>&2
git clone https://github.com/ipxe/ipxe
make -C ${IPXEDIR}
fi
FILE=$1
IPXE=$2
if [[ -n "${FILE}" ]]; then
# setup custom ipxe flags
cat <<-EOF > ${IPXEDIR}/config/local/general.h
#define DOWNLOAD_PROTO_HTTPS
#define PARAM_CMD
#define CONSOLE_CMD
#define IMAGE_COMBOOT
#define IMAGE_PNG
EOF
cat <<-EOF > ${IPXEDIR}/config/local/console.h
#define CONSOLE_FRAMEBUFFER
#define PING_CMD
#define NSLOOKUP_CMD
EOF
# build iso
MAKECMD="make -C ${IPXEDIR} bin/ipxe.iso"
if [[ -n "${IPXE}" ]]; then
MAKECMD+=" EMBED=${MYDIR}/${IPXE}"
fi
echo "${MAKECMD}"
eval "${MAKECMD}"
mv ${IPXEDIR}/bin/ipxe.iso ${MYDIR}/${FILE}
printf "File: $(ccyan "${FILE}") created\n" 1>&2
else
printf "[$(corange "ERROR")]: Usage: $(cgreen "make.iso.sh") $(ccyan "<output.file> [ <ipxe.script> ]")\n" 1>&2
fi