Compare commits

...

2 Commits

Author SHA1 Message Date
pedro a59968a9a0 pxe: allow personalization of boot menus 2024-09-27 18:02:37 -03:00
pedro 07e581c847 pxe: more sudo cmds to fix 2024-09-27 18:02:19 -03:00
1 changed files with 16 additions and 29 deletions

View File

@ -46,14 +46,14 @@ backup_file() {
install_nfs() { install_nfs() {
# append live directory, which is expected by the debian live env # append live directory, which is expected by the debian live env
mkdir -p "${nfs_path}/live" ${SUDO} mkdir -p "${nfs_path}/live"
mkdir -p "${nfs_path}/snapshots" ${SUDO} mkdir -p "${nfs_path}/snapshots"
# debian live nfs path is readonly, do a trick # debian live nfs path is readonly, do a trick
# to make snapshots subdir readwrite # to make snapshots subdir readwrite
if ! grep -q "/snapshots" /proc/mounts; then if ! grep -q "/snapshots" /proc/mounts; then
mkdir -p "/snapshots" ${SUDO} mkdir -p "/snapshots"
mount --bind "${nfs_path}/snapshots" "/snapshots" ${SUDO} mount --bind "${nfs_path}/snapshots" "/snapshots"
fi fi
backup_file /etc/exports backup_file /etc/exports
@ -74,7 +74,7 @@ END
if [ ! -f "${nfs_path}/settings.ini" ]; then if [ ! -f "${nfs_path}/settings.ini" ]; then
if [ -f "settings.ini" ]; then if [ -f "settings.ini" ]; then
cp settings.ini "${nfs_path}/settings.ini" ${SUDO} cp settings.ini "${nfs_path}/settings.ini"
else else
echo "ERROR: $(pwd)/settings.ini does not exist yet, cannot read config from there. You can take inspiration with file $(pwd)/settings.ini.example" echo "ERROR: $(pwd)/settings.ini does not exist yet, cannot read config from there. You can take inspiration with file $(pwd)/settings.ini.example"
exit 1 exit 1
@ -100,13 +100,13 @@ END
install_netboot() { install_netboot() {
# if you want to refresh install, remove or move dir # if you want to refresh install, remove or move dir
if [ ! -d "${tftp_path}" ] || [ "${FORCE:-}" ]; then if [ ! -d "${tftp_path}" ] || [ "${FORCE:-}" ]; then
mkdir -p "${tftp_path}/pxelinux.cfg" ${SUDO} mkdir -p "${tftp_path}/pxelinux.cfg"
cd "${tftp_path}"
if [ ! -f "${tftp_path}/netboot.tar.gz" ]; then if [ ! -f "${tftp_path}/netboot.tar.gz" ]; then
wget http://ftp.debian.org/debian/dists/${VERSION_CODENAME}/main/installer-amd64/current/images/netboot/netboot.tar.gz url="http://ftp.debian.org/debian/dists/${VERSION_CODENAME}/main/installer-amd64/current/images/netboot/netboot.tar.gz"
tar xvf netboot.tar.gz || true ${SUDO} wget -P "${tftp_path}" "${url}"
rm -rf "${tftp_path}/pxelinux.cfg" ${SUDO} tar xvf "${tftp_path}/netboot.tar.gz" -C "${tftp_path}"
mkdir -p "${tftp_path}/pxelinux.cfg" ${SUDO} rm -rf "${tftp_path}/pxelinux.cfg"
${SUDO} mkdir -p "${tftp_path}/pxelinux.cfg"
fi fi
${SUDO} cp -fv "${PXE_DIR}/../iso/staging/live/vmlinuz" "${tftp_path}/" ${SUDO} cp -fv "${PXE_DIR}/../iso/staging/live/vmlinuz" "${tftp_path}/"
@ -114,24 +114,10 @@ install_netboot() {
${SUDO} cp /usr/lib/syslinux/memdisk "${tftp_path}/" ${SUDO} cp /usr/lib/syslinux/memdisk "${tftp_path}/"
${SUDO} cp /usr/lib/syslinux/modules/bios/* "${tftp_path}/" ${SUDO} cp /usr/lib/syslinux/modules/bios/* "${tftp_path}/"
${SUDO} tee "${tftp_path}/pxelinux.cfg/default" <<END envsubst < ./pxe-menu.cfg | ${SUDO} tee "${tftp_path}/pxelinux.cfg/default"
DEFAULT menu.c32
PROMPT 0
TIMEOUT 50
ONTIMEOUT wb
MENU TITLE PXE Boot Menu
LABEL wb
MENU LABEL Boot Workbench
KERNEL vmlinuz
INITRD initrd
APPEND ip=dhcp netboot=nfs nfsroot=${server_ip}:${nfs_path}/ boot=live text forcepae
END
cd -
fi fi
rsync -av "${PXE_DIR}/../iso/staging/live/filesystem.squashfs" "${nfs_path}/live/" ${SUDO} rsync -av "${PXE_DIR}/../iso/staging/live/filesystem.squashfs" "${nfs_path}/live/"
} }
init_config() { init_config() {
@ -151,8 +137,9 @@ init_config() {
fi fi
VERSION_CODENAME="${VERSION_CODENAME:-bookworm}" VERSION_CODENAME="${VERSION_CODENAME:-bookworm}"
tftp_path="${tftp_path:-/srv/pxe-tftp}" tftp_path="${tftp_path:-/srv/pxe-tftp}"
server_ip="${server_ip}" # vars used in envsubst require to be exported:
nfs_path="${nfs_path:-/srv/pxe-nfs}" export server_ip="${server_ip}"
export nfs_path="${nfs_path:-/srv/pxe-nfs}"
} }
main() { main() {