Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Distribution independent #2

Open
Diaoul opened this issue Jan 17, 2021 · 3 comments
Open

[Feature Request] Distribution independent #2

Diaoul opened this issue Jan 17, 2021 · 3 comments

Comments

@Diaoul
Copy link

Diaoul commented Jan 17, 2021

This is an neat script however the fact that it only runs with Ubuntu is huge constraint IMO. Would it be possible to make it independent of the underlying distribution?

@dannf
Copy link
Owner

dannf commented Jan 21, 2021

Sure, it's possible, but would require some work. The issue I see is getting copies of pxelinux.0 and ldlinux.c32 (is that even needed?) from somewhere. There is an unused download_pxelinux() function that can download a copy of pxelinux.0 from a d-i tree, but the problem there is that Ubuntu has dropped d-i support, so that tree won't be published by newer releases. The right answer might be to download the associated .deb files from a mirror and extract files from them manually. But for that we'd need to implement apt mirror parsing support. A hack might be to always download the version from bionic, since it still has quite a few years of support left.

One thing possibly worth considering is a --disable-bios flag, or similar, that only generates uefi artifacts. I don't think the uefi artifacts currently depend on any specific local files.

@Diaoul
Copy link
Author

Diaoul commented Jan 21, 2021

After some effort I have made a bash script that will prepare the files for the TFTP server and the webserver.

#!/bin/bash
set -euo pipefail

url='https://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.iso'
grub_url='http://archive.ubuntu.com/ubuntu/dists/focal/main/uefi/grub2-amd64/current/grubnetx64.efi.signed'
server='${pxe_default_server}'
tftp_root='/tftp'
iso=$(basename $url)

echo "Preparing for $iso"

# download the iso
if [ ! -f $iso ]; then
    echo "Download ISO..."
    curl -sfLo $iso $url
fi

# copy cloud-init files
mkdir -p www
echo "Copy iso and cloud-init files..."
cp -f $iso www/$iso
cp -f user-data.yaml www/user-data

# copy kernel and initramfs from iso
mkdir -p tftp
if [ ! -f tftp/initrd ] || [ ! -f tftp/vmlinuz ]; then
    echo "Copy kernel and initramfs..."
    mkdir mnt
    sudo mount -o ro www/$iso mnt/
    [ -f tftp/vmlinuz ] || cp -p mnt/casper/vmlinuz tftp/
    [ -f tftp/initrd ] || cp -p mnt/casper/initrd tftp/
    sudo umount mnt/
    rmdir mnt
fi

# download grub image
if [ ! -f tftp/pxelinux.0 ]; then
    echo "Download GRUB image..."
    curl -sfLo tftp/pxelinux.0 $grub_url
fi

# copy grub configuration
echo "Copy GRUB configuration..."
mkdir -p tftp/grub
sed -e "s|{{server}}|$server|g" \
    -e "s|{{root}}|$tftp_root|g" \
    -e "s|{{iso}}|$iso|g" \
    grub.cfg > tftp/grub/grub.cfg

echo "Done!"

Not as refined as your script but this is enough for my need. Feel free to close the issue.

@dannf
Copy link
Owner

dannf commented Jan 21, 2021

I think we should keep this open because it would be nice to not have to install Ubuntu before you can install Ubuntu :)

One other blocker here is that we'd need to remove the dependency on python3-distro-info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants