From a9204209a7d9cf574f83771ea42d45d7356254e2 Mon Sep 17 00:00:00 2001 From: toby Date: Mon, 25 Feb 2019 00:23:30 +0000 Subject: [PATCH] converting the whole start-me-up thingy to an actual deb pacakge for easier portability, also adding an example wit.ipxe file to work on kick-starts within VMs --- create_pxeinitrd.sh | 57 +------------------ debian-amd64/wit-pxeboot-amd64.install | 2 +- debian-arm64/wit-pxeboot-arm64.install | 1 - files/wit-amd64.ipxe | 77 ++++++++++++++++++++++++++ files/wit.ipxe | 68 ----------------------- 5 files changed, 80 insertions(+), 125 deletions(-) create mode 100644 files/wit-amd64.ipxe delete mode 100644 files/wit.ipxe diff --git a/create_pxeinitrd.sh b/create_pxeinitrd.sh index d5f94bd..d752647 100755 --- a/create_pxeinitrd.sh +++ b/create_pxeinitrd.sh @@ -17,6 +17,7 @@ RELEASE=${RELEASE:=unstable} FLAVOUR=${FLAVOUR:=debian} # Either 'debian' or 'ubuntu' INCLUDES=${INCLUDES:="openssh-server,init,curl,parted,xz-utils,vim,locales-all,less,dmidecode,iputils-ping,fping,tcpdump,rsync,ethtool,lldpd,iproute2,net-tools,sudo,gnupg,tcpdump,mtr-tiny,ifupdown,ipmitool,iptables,telnet,netcat,bridge-utils,vlan,ifstat,ncurses-term,wget,pciutils,dhcpcd5,python,efibootmgr,busybox-static,firmware-qlogic"} MIRROR=${MIRROR:="https://mirrors.wit.com/debian"} +DEBCORE_INCLUDES=${DEBCORE_INCLUDES:="wit-start-me-up"} fail() { @@ -66,6 +67,7 @@ echo 'deb https://mirrors.wit.com/debcore sid main experimental' >> $MNT_DIR/etc curl https://mirrors.wit.com/debcore/public.key | LANG=C DEBIAN_FRONTEND=noninteractive chroot $MNT_DIR apt-key add - LANG=C DEBIAN_FRONTEND=noninteractive chroot $MNT_DIR apt-get update +LANG=C DEBIAN_FRONTEND=noninteractive chroot $MNT_DIR apt-get install $DEBCORE_INCLUDES LANG=C DEBIAN_FRONTEND=noninteractive chroot $MNT_DIR apt-get clean cat /dev/null > $MNT_DIR/etc/machine-id @@ -73,55 +75,6 @@ cat /dev/null > $MNT_DIR/etc/machine-id mkdir -p $MNT_DIR/root/.ssh echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDd7rLlS1NmTpBr5KP5ryuA/euGD8I6uc2RCg4sCIlvH0FhEPb123QuMVImHi23ftVP61cKZXm8MlTtAoLHduYtGMHCkJWAAkiIpPetAP2KPIpuadtgIS8xuD/TCYjl0xNXLh0M1C7i7HOnTd8yr+3QNjUppyDdKjLvMQbPWZZTU5rt7CYoGlrxHjieCkq9jj8kRjRARUaAJ4DHEgMFUDIcq3JYluzzkgPK/JFwoq/IokVQCr5qfQRwr3SCkD4sIuGTj+J67uzabIr/xDBqlrMW3T+7YfY12ciHpijob+l7xESkJ+6Gxh56z8llBkGiVyh3UqnmW4MvfuAA/D3Dzhwr afrank@adams-mbp.lan > $MNT_DIR/root/.ssh/authorized_keys -cat < $MNT_DIR/etc/systemd/system/start-me-up.service -[Unit] -Description=WIT System Startup -Wants=network-online.target -After=network-online.target - -[Service] -Type=oneshot -ExecStart=/usr/local/bin/start_me_up.sh -RemainAfterExit=true -ExecStop=/usr/local/bin/shut_me_down.sh -StandardOutput=journal - -[Install] -WantedBy=multi-user.target -EOF - - -cat < $MNT_DIR/usr/local/bin/start_me_up.sh -#!/bin/bash -eval "kernel_args=( \$(cat /proc/cmdline) )" -for i in "\${kernel_args[@]}" - do - if [ \${i:0:4} = exec ] - then - export -- "\$i" - fi -done - -echo \$execstartup -eval \$execstartup -EOF - - -cat < $MNT_DIR/usr/local/bin/shut_me_down.sh -#!/bin/bash -eval "kernel_args=( \$(cat /proc/cmdline) )" -for i in "\${kernel_args[@]}" - do - if [ \${i:0:4} = exec ] - then - export -- "\$i" - fi -done - -echo \$execshutdown -eval \$execshutdown -EOF - cat <$MNT_DIR/etc/dhcpcd.conf hostname @@ -134,12 +87,6 @@ require dhcp_server_identifier EOF -chmod +x $MNT_DIR/usr/local/bin/start_me_up.sh -chmod +x $MNT_DIR/usr/local/bin/shut_me_down.sh - -chroot $MNT_DIR systemctl enable start-me-up || fail "failed to enable start-me-up" - - chroot $MNT_DIR usermod -p '$6$LmI1TuCG$YRTAdn/Ht7v1kNdkb8HFXV4S7Sau571DD3kaBWltX72OSo21P7ON9JRw4XepjsBQ0FzzBebfsdQ4YfH9M2CaN0' root chroot $MNT_DIR ssh-keygen -q -f /root/.ssh/id_rsa -C root@pxeboot -N "" diff --git a/debian-amd64/wit-pxeboot-amd64.install b/debian-amd64/wit-pxeboot-amd64.install index 6d0def5..3992804 100644 --- a/debian-amd64/wit-pxeboot-amd64.install +++ b/debian-amd64/wit-pxeboot-amd64.install @@ -1,4 +1,4 @@ files/kernel/* /srv/tftp/wit-pxeboot/ files/boot/* /srv/tftp/boot/ files/grub-addon-amd64.cfg /srv/tftp/boot/grub/ -files/wit.ipxe /srv/tftp/boot/ +files/wit-amd64.ipxe /srv/tftp/boot/ diff --git a/debian-arm64/wit-pxeboot-arm64.install b/debian-arm64/wit-pxeboot-arm64.install index f6636a4..6891d9b 100644 --- a/debian-arm64/wit-pxeboot-arm64.install +++ b/debian-arm64/wit-pxeboot-arm64.install @@ -1,4 +1,3 @@ files/kernel/* /srv/tftp/wit-pxeboot/ files/boot/* /srv/tftp/boot/ files/grub-addon-arm64.cfg /srv/tftp/boot/grub/ -files/wit.ipxe /srv/tftp/boot/ diff --git a/files/wit-amd64.ipxe b/files/wit-amd64.ipxe new file mode 100644 index 0000000..c7b5017 --- /dev/null +++ b/files/wit-amd64.ipxe @@ -0,0 +1,77 @@ +#!ipxe +set menu-timeout 5000 +set submenu-timeout ${menu-timeout} +set menu-default localboot + + +:start +menu iPXE boot menu +item --gap -- ------------------------------- PXE options ------------------------------- +item --key i install-amd64 AMD64 kickstart +item --key d debcore-amd64 AMD64 debcore boot (no changes on local drives) +item --gap -- ------------------------------ Local options ------------------------------ +item --key l localboot Exit iPXE and continue boot +item --key c config Configure settings +item --key s shell Drop to iPXE shell +item reboot Reboot computer +item --gap -- ------------------------------------------------------------------------------ +choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel +set menu-timeout 0 +goto ${selected} + + +:cancel +echo You cancelled the menu, dropping you to a shell + + +:shell +echo Type 'exit' to get the back to the menu +shell +set menu-timeout 0 +set submenu-timeout 0 +goto start + + +:failed +echo Booting failed, dropping to shell +goto shell + + +:reboot +reboot + + +:localboot +exit + + +:config +config +goto start + + +:back +set submenu-timeout 0 +clear submenu-default +goto start + + +############ MAIN MENU ITEMS ############ + +:install-amd64 +echo Kickstarting machine... I hope you know what you're doing. you have about 60 seconds to kill the machine if you don't +kernel /wit-pxeboot/vmlinuz-amd64 initrd=initramfs-amd64.gz console=tty0 console=ttyS0,115200n8 console=ttyS1,115200n8 console=ttyAMA0,115200n8 size=5000 execstartup="DEV=/dev/vda /usr/bin/create_local_install.sh" +initrd /wit-pxeboot/initramfs-amd64.gz +boot || goto failed +goto start + + +:debcore-amd64 +echo Booting Debcore from tftp +kernel /wit-pxeboot/vmlinuz-amd64 initrd=initramfs-amd64.gz console=tty0 console=ttyS0,115200n8 console=ttyS1,115200n8 console=ttyAMA0,115200n8 size=5000 +initrd /wit-pxeboot/initramfs-amd64.gz +boot || goto failed +goto start + + + diff --git a/files/wit.ipxe b/files/wit.ipxe deleted file mode 100644 index cf66073..0000000 --- a/files/wit.ipxe +++ /dev/null @@ -1,68 +0,0 @@ -#!ipxe -set menu-timeout 5000 -set submenu-timeout ${menu-timeout} -set menu-default localboot - - -:start -menu iPXE boot menu -item --gap -- ------------------------- Operating systems ------------------------------ -item --key d debcore Boot Debcore from tftp -item --key l localboot Exit iPXE and continue boot -item --gap -- ------------------------------ Options ----------------------------------- -item --key c config Configure settings -item --key s shell Drop to iPXE shell -item reboot Reboot computer -choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel -set menu-timeout 0 -goto ${selected} - - -:cancel -echo You cancelled the menu, dropping you to a shell - - -:shell -echo Type 'exit' to get the back to the menu -shell -set menu-timeout 0 -set submenu-timeout 0 -goto start - - -:failed -echo Booting failed, dropping to shell -goto shell - - -:reboot -reboot - - -:localboot -exit - - -:config -config -goto start - - -:back -set submenu-timeout 0 -clear submenu-default -goto start - - -############ MAIN MENU ITEMS ############ - - -:debcore -echo Booting Debcore from tftp -kernel /wit-pxeboot/vmlinuz-amd64 initrd=initramfs-amd64.gz console=tty0 console=ttyS0,115200n8 console=ttyS1,115200n8 console=ttyAMA0,115200n8 size=5000 -initrd /wit-pxeboot/initramfs-amd64.gz -boot || goto failed -goto start - - -