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 93 94 95 96 97 98 99
|
#!/bin/sh
set -e
if [ -x ./openstack-tempest-ci-build-live-image-clean ] ; then
./openstack-tempest-ci-build-live-image-clean
else
openstack-tempest-ci-build-live-image-clean
fi
for i in $@ ; do
case "${1}" in
"--pxe-server-ip")
if [ -z "${2}" ] ; then echo "Parameter for option --pxe-server-ip is missing" > /dev/stderr ; DO_EXIT="yes" ; fi
OTCI_PXE_SERVER_IP=${2}
shift
shift
;;
"--debian-mirror-addr")
if [ -z "${2}" ] ; then echo "Parameter for option --debian-mirror-addr is missing" > /dev/stderr ; DO_EXIT="yes" ; fi
OTCI_DEB_MIRROR_ADDR=${2}
shift
shift
;;
*)
;;
esac
done
if [ -z "${OTCI_PXE_SERVER_IP}" ] ; then
echo "No --pxe-server-ip given, using 192.168.100.1 as default." > /dev/stderr
OTCI_PXE_SERVER_IP=192.168.100.1
fi
if [ "${DO_EXIT}" = "yes" ] ; then
echo "Parameters not validated: will exit now!" > /dev/stderr
echo "Example call: ./build-image --pxe-server-ip 192.168.100.1 --debian-mirror-addr http://192.168.100.1:9999/debian" > /dev/stderr
exit 1
fi
# Manage ssh keys
if [ -e ./id_rsa.pub ] ; then
echo "Will use existing ./id_rsa.pub file"
else
echo "No ssh key found, generating one"
( echo "" ; echo "" ) | ssh-keygen -t rsa -f ./id_rsa
fi
mkdir -p config/includes.chroot/root/.ssh/
chmod 700 config/includes.chroot/root/.ssh/
cp id_rsa.pub config/includes.chroot/root/.ssh/authorized_keys
chmod 600 config/includes.chroot/root/.ssh/authorized_keys
mkdir -p config/includes.chroot/etc/network
echo "auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp" >config/includes.chroot/etc/network/interfaces
mkdir -p config/package-lists
echo "openssh-server
openssh-client
ntp
pciutils
tcpdump
net-tools
nmap
joe
wget
kbd" > config/package-lists/openstack.list.chroot
cp -auxf /usr/share/live/build/bootloaders config
lb clean
lb config -b netboot --bootappend-live "boot=live systemd.show_status=true components url=http://${OTCI_PXE_SERVER_IP} fetch=http://${OTCI_PXE_SERVER_IP}/tempest-ci/filesystem.squashfs" --net-root-path /var/lib/tempest-ci --net-root-server ${OTCI_PXE_SERVER_IP}
# Change the default mirror in the config
if [ -n "${OTCI_DEB_MIRROR_ADDR}" ] ; then
for i in LB_PARENT_MIRROR_BOOTSTRAP LB_PARENT_MIRROR_CHROOT LB_PARENT_MIRROR_DEBIAN_INSTALLER LB_MIRROR_BOOTSTRAP LB_MIRROR_CHROOT LB_MIRROR_DEBIAN_INSTALLER \
LB_PARENT_MIRROR_BINARY LB_MIRROR_BINARY ; do
sed -i 's|^'${i}'=.*|'${i}'="'${OTCI_DEB_MIRROR_ADDR}'"|' config/bootstrap
done
fi
sed -i 's/^LB_BOOTLOADERS=.*/LB_BOOTLOADERS="syslinux"/' config/binary
# Fix the default syslinux timeout to 5 seconds
sed -i "s/timeout 0/timeout 5/" config/bootloaders/isolinux/isolinux.cfg
sed -i "s/timeout 0/timeout 5/" config/bootloaders/pxelinux/pxelinux.cfg/default
sed -i "s/timeout 0/timeout 5/" config/bootloaders/syslinux/syslinux.cfg
sed -i "s/timeout 0/timeout 5/" config/bootloaders/extlinux/extlinux.conf
lb build
# Copy the tftp stuff
mkdir -p /var/lib/tempest-live-booter/tftp
cp -r tftpboot/* /var/lib/tempest-live-booter/tftp
mkdir -p /var/lib/tempest-live-booter/tftp/live
cp -auxf tftpboot/live/vmlinuz* tftpboot/live/initrd* /var/lib/tempest-live-booter/tftp/live
cp binary/live/filesystem.squashfs /var/lib/tempest-live-booter
|