Skip to content

Commit

Permalink
Use cdupdate.sh, remove squashfs modification and sudo needs (#8)
Browse files Browse the repository at this point in the history
Move modification logic from build.sh into cdupdate.sh
Include files via cpio instead, cdupdate.sh will see to correct modification.

This removes need for squashfs rebuild, which in turn removes need for sudo.
This is much quicker and cleaner

Relates to ASoft-se/Gentoo-HAI#8 and NiKiZe/Gentoo-iPXE#6
Depends on #6
  • Loading branch information
NiKiZe authored May 11, 2022
1 parent 2c04a8a commit 939f21b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ It lets you take control of the PXE host easily:

* The `cpio` command from `app-arch/cpio`
* The `gpg` command from `app-crypt/gnupg`
* The `unsquashfs` and `mksquashfs` command from `sys-fs/squashfs-tools`
* The `sudo` command from `app-admin/sudo`
* The `xz` command from `app-arch/xz-utils`
* The `isoinfo` command from `app-cdr/cdrtools`
* Your current user must be a sudoer with the right to execute any command
* You must have imported the 'Gentoo Linux Release Engineering (Automated Weekly Release Key)' GPG public key in your keyring `gpg --locate-key [email protected]`

## Environment variables and defaults
Expand All @@ -47,8 +45,8 @@ The default SSH root password is `gentoo-root`. This is the list of accepted env
* Install `sys-boot/syslinux` as it contains the necessary files:

```
$ sudo cp /usr/share/syslinux/ldlinux.c32 /pxe/
$ sudo cp /usr/share/syslinux/pxelinux.0 /pxe/
# cp /usr/share/syslinux/ldlinux.c32 /pxe/
# cp /usr/share/syslinux/pxelinux.0 /pxe/
```

* Create the `/pxe/pxelinux.cfg/` directory
Expand Down
26 changes: 9 additions & 17 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,19 @@ iso=iso/${iso}
isoinfo -R -i ${iso} -X -find -path /boot/gentoo && mv -vf boot/gentoo .
isoinfo -R -i ${iso} -X -find -path /image.squashfs
isoinfo -R -i ${iso} -X -find -path /boot/gentoo.igz

sudo unsquashfs -d squash -f image.squashfs
rm image.squashfs

sudo cp files/setup.start squash/etc/local.d/
sudo chmod +x squash/etc/local.d/setup.start

sudo mkdir -p squash/root/.ssh
if [ -f "${SSH_KEY_PATH}" ]; then
sudo cp "${SSH_KEY_PATH}" squash/root/.ssh/authorized_keys
sudo chmod 600 squash/root/.ssh/authorized_keys
fi

sudo mksquashfs squash/ image.squashfs
sudo rm -rf squash

(cat boot/gentoo.igz; (echo image.squashfs | cpio -H newc -o)) > gentoo.igz
sudo rm image.squashfs
rm image.squashfs
rm boot/gentoo.igz
rmdir boot

[ -f "${SSH_KEY_PATH}" ] && cp "${SSH_KEY_PATH}" files/authorized_keys
# append cdupdate.sh that do the online modification and other needed files
pushd files
chmod a+x cdupdate.sh
find . -print | cpio -H newc -o | xz --check=crc32 -vT0 >> ../gentoo.igz
[ -f authorized_keys ] && rm authorized_keys
popd

echo "All done:"
echo "---------"
echo " - PXE kernel file : gentoo"
Expand Down
19 changes: 19 additions & 0 deletions files/cdupdate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# we should be in newroot ${NEW_ROOT} and other nice things are unavailable
echo " Running cdupdate.sh in $(pwd)"
echo " Started as: $0 args: $*"

scriptpath=$(dirname $0)
echo " found scriptpath: ${scriptpath}"

set -x
cp ${scriptpath}/setup.start etc/local.d/
chmod +x etc/local.d/setup.start

if [ -f "${scriptpath}/authorized_keys" ]; then
mkdir -p root/.ssh
cp "${scriptpath}/authorized_keys" root/.ssh/authorized_keys
chmod 600 root/.ssh/authorized_keys
fi

set +x

0 comments on commit 939f21b

Please sign in to comment.