forked from jasherai/ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-iso
executable file
·58 lines (51 loc) · 1.56 KB
/
build-iso
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
#!/bin/sh
set -e
. "$(dirname $0)/config.sh"
for ARCH in $ARCHS
do
ORIG="ubuntu-$VERSION-$DISTRO-$ARCH.iso"
COPY="ubuntu-$VERSION-$DISTRO-$ARCH"
ISO="${ISOPREFIX}-ubuntu-$VERSION-$DISTRO-$ARCH.iso"
# Download the original ISO if it isn't present already.
[ -f "$ORIG" ] || curl -L -o "$ORIG" \
-d distro="$DISTRO" \
-d release="$RELEASE" \
-d bits="$([ "$ARCH" = "i386" ] && echo 32 || echo 64)" \
"http://www.ubuntu.com/start-download"
# Make a writable copy of the original ISO.
mkdir -p isomount
sudo mount -o loop,user "${ORIG}" isomount
rsync -a "isomount/" "$COPY"
sudo umount isomount
chmod -R +w "$COPY"
# Customize the writable copy.
m4 \
-D __LABEL__="${LABEL}" \
"isolinux.cfg.m4" > "$COPY/isolinux/isolinux.cfg"
m4 \
-D __HOST__="$HOST" \
-D __DOMAIN__="$DOMAIN" \
-D __KERNEL__="linux-$([ "$ARCH" = "i386" ] \
&& echo generic-pae \
|| echo server
)" \
-D __ROOT_PASSWORD__="$ROOT_PASSWORD" \
-D __USERNAME__="$USERNAME" \
-D __PASSWORD__="$PASSWORD" \
-D __LABEL__="${LABEL}" \
"default.seed.m4" >"$COPY/preseed/${LABEL}.seed"
# cp "$PUBLIC_KEY" "setup.sh" "$COPY/"
cp "$PUBLIC_KEY" "sudoers" "$COPY/"
m4 \
-D __USERNAME__="$USERNAME" \
-D __PUBLIC_KEY__="$PUBLIC_KEY" \
"default.sh.m4" >"$COPY/${LABEL}.sh"
# Build a custom ISO.
mkisofs -r -V "Ubuntu $VERSION for ${LABEL}" \
-cache-inodes -J -l -no-emul-boot \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-boot-load-size 4 -boot-info-table \
-o "$ISO" "$COPY"
echo "Completed building custom is for ${LABEL} [${ARCH}]"
done