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

This commit is contained in:
toby 2019-02-25 00:23:30 +00:00
parent 31103471c7
commit a9204209a7
5 changed files with 80 additions and 125 deletions

View File

@ -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 <<EOF > $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 <<EOF > $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 <<EOF > $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 <<EOF >$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 ""

View File

@ -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/

View File

@ -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/

77
files/wit-amd64.ipxe Normal file
View File

@ -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

View File

@ -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