aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/disk-image-builder/nested/patches
diff options
context:
space:
mode:
Diffstat (limited to 'resources/tools/disk-image-builder/nested/patches')
-rwxr-xr-xresources/tools/disk-image-builder/nested/patches/01-serial-console23
-rwxr-xr-xresources/tools/disk-image-builder/nested/patches/02-users37
-rwxr-xr-xresources/tools/disk-image-builder/nested/patches/03-network37
-rwxr-xr-xresources/tools/disk-image-builder/nested/patches/04-qemu-ga33
-rwxr-xr-xresources/tools/disk-image-builder/nested/patches/05-ssh-hostkeys11
5 files changed, 141 insertions, 0 deletions
diff --git a/resources/tools/disk-image-builder/nested/patches/01-serial-console b/resources/tools/disk-image-builder/nested/patches/01-serial-console
new file mode 100755
index 0000000000..99b6f7f3c8
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/patches/01-serial-console
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+patch boot/grub/menu.lst <<"_EOF"
+2c2,4
+< timeout 10
+---
+> timeout 1
+> serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
+> terminal --timeout=0 serial console
+15c17
+< kernel /boot/bzImage rw root=/dev/sda1
+---
+> kernel /boot/bzImage rw root=/dev/sda1 console=ttyS0,115200n8
+_EOF
+
+patch etc/inittab <<"_EOF"
+27c27,29
+< console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
+---
+> console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
+> # ttyS1 to be used by qemu-ga
+> ttyS2::respawn:/sbin/getty -L ttyS2 0 vt100 # Additional serial
+_EOF
diff --git a/resources/tools/disk-image-builder/nested/patches/02-users b/resources/tools/disk-image-builder/nested/patches/02-users
new file mode 100755
index 0000000000..9b7db0969a
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/patches/02-users
@@ -0,0 +1,37 @@
+#!/bin/sh -e
+
+patch etc/sudoers <<"_EOF"
+97a98,100
+>
+> csit ALL=(root) NOPASSWD:ALL
+> cisco ALL=(root) NOPASSWD:ALL
+_EOF
+
+patch etc/passwd <<"_EOF"
+10a11,12
+> csit:x:1001:1001:CSIT user:/tmp:/bin/sh
+> cisco:x:1002:1002:Cisco user:/tmp:/bin/sh
+_EOF
+
+patch etc/shadow <<"_EOF"
+1c1
+< root::10933:0:99999:7:::
+---
+> root:5pcUkhKEiBBfw:16892:0:99999:7:::
+10a11,12
+> csit:5pcUkhKEiBBfw:16892:0:99999:7:::
+> cisco:5piAVSAyGsbaI:16892:0:99999:7:::
+_EOF
+
+patch etc/group <<"_EOF"
+27a28,29
+> csit:x:1001:
+> cisco:x:1002:
+_EOF
+
+patch etc/ssh/sshd_config <<"_EOF"
+44c44
+< #PermitRootLogin prohibit-password
+---
+> PermitRootLogin yes
+_EOF
diff --git a/resources/tools/disk-image-builder/nested/patches/03-network b/resources/tools/disk-image-builder/nested/patches/03-network
new file mode 100755
index 0000000000..ca5c4f952d
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/patches/03-network
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+patch boot/grub/menu.lst <<"_EOF"
+17c17
+< kernel /boot/bzImage rw root=/dev/sda1 console=ttyS0,115200n8
+---
+> kernel /boot/bzImage rw root=/dev/sda1 ipv6.disable=1 console=ttyS0,115200n8
+_EOF
+
+patch etc/network/interfaces <<"_EOF"
+4a5,7
+>
+> auto mgmt0
+> iface mgmt0 inet dhcp
+_EOF
+
+patch etc/init.d/S40network <<"_EOF"
+11a12,29
+>
+> # Rename interfaces. The e1000 interface is managment.
+> NUM_VIRTIO=0
+> NUM_MGMT=0
+> for dev in /sys/class/net/eth*
+> do
+> devname=`basename $dev`
+> driver=`readlink ${dev}/device/driver`
+> if test "${driver#*virtio}" != "$driver"
+> then
+> ip link set dev $devname name virtio${NUM_VIRTIO}
+> NUM_VIRTIO=$(($NUM_VIRTIO+1))
+> else
+> ip link set dev $devname name mgmt${NUM_MGMT}
+> NUM_MGMT=$((NUM_MGMT+1))
+> fi
+> done
+>
+_EOF
diff --git a/resources/tools/disk-image-builder/nested/patches/04-qemu-ga b/resources/tools/disk-image-builder/nested/patches/04-qemu-ga
new file mode 100755
index 0000000000..2897260d10
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/patches/04-qemu-ga
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+cat - > etc/init.d/S45qemu-ga <<"_EOF"
+#!/bin/sh
+#
+# Start QEMU guest agent
+#
+QEMU_GA_MODE="isa-serial"
+QEMU_GA_DEV="/dev/ttyS1"
+
+case "$1" in
+ start)
+ echo "Starting qemu guest agent..."
+ /usr/bin/qemu-ga -m $QEMU_GA_MODE -p $QEMU_GA_DEV -d
+ ;;
+ stop)
+ echo "Stopping quemu guest agent..."
+ killall qemu-ga
+ ;;
+ restart|reload)
+ "$0" stop
+ "$0" start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
+_EOF
+
+chown root.root etc/init.d/S45qemu-ga
+chmod 755 etc/init.d/S45qemu-ga
diff --git a/resources/tools/disk-image-builder/nested/patches/05-ssh-hostkeys b/resources/tools/disk-image-builder/nested/patches/05-ssh-hostkeys
new file mode 100755
index 0000000000..de8be15798
--- /dev/null
+++ b/resources/tools/disk-image-builder/nested/patches/05-ssh-hostkeys
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Generate host keys here. This will speed up first boot time ever so slightly.
+# It does however mean that keys are not unique across installations -- which
+# shouldn't be an issue for our use case though.
+
+sudo mkdir -m 0775 -p etc/ssh
+for a in rsa ecdsa ed25519 dsa
+do
+ sudo ssh-keygen -f etc/ssh/ssh_host_${a}_key -N "" -t ${a}
+done