-
Notifications
You must be signed in to change notification settings - Fork 35
/
build-iso
executable file
·64 lines (57 loc) · 1.53 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
59
60
61
62
63
64
#!/bin/sh
set -e
. "$(dirname $0)/config.sh"
ORIG="ubuntu-$VERSION-$DISTRO-$ARCH.iso"
COPY="ubuntu-$VERSION-$DISTRO-$ARCH"
ISO="$NICKNAME-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.
{
# os x
sudo /usr/libexec/vndevice attach /dev/vn0 "$ORIG"
sudo mount -t cd9660 /dev/vn0 "mount"
} || {
# linux
rm -rf "mount"
mkdir "mount"
sudo mount -o loop "$ORIG" "mount"
}
rsync -a "mount/" "$COPY"
{
sudo diskutil unmount "mount"
sudo /usr/libexec/vndevice detach /dev/vn0
} || {
sudo umount "mount"
rm -rf "mount"
}
chmod -R +w "$COPY"
# Customize the writable copy.
cp "isolinux.cfg" "$COPY/isolinux/"
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" \
"unattended.seed.m4" >"$COPY/preseed/unattended.seed"
cp "$PUBLIC_KEY" "sudoers" "$COPY/"
m4 \
-D __USERNAME__="$USERNAME" \
-D __PUBLIC_KEY__="$PUBLIC_KEY" \
"late_command.sh.m4" >"$COPY/late_command.sh"
# Build a custom ISO.
mkisofs -r -V "Ubuntu $VERSION for Vagrant" \
-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"