27 lines
902 B
Bash
27 lines
902 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -o errexit -o nounset -o pipefail -o xtrace
|
||
|
|
||
|
declare -r MOUNTDIR="$(mktemp -d)"
|
||
|
|
||
|
cleanstep1() {
|
||
|
rm -r "${MOUNTDIR}"
|
||
|
}
|
||
|
trap cleanstep1 EXIT
|
||
|
|
||
|
mount -t ext4 -o noexec,nosuid,nodev,rootcontext=system_u:object_r:container_file_t:s0 LABEL=fcos_images "${MOUNTDIR}"
|
||
|
|
||
|
cleanstep2() {
|
||
|
umount -f "${MOUNTDIR}"
|
||
|
cleanstep1
|
||
|
}
|
||
|
trap cleanstep2 EXIT
|
||
|
|
||
|
declare -r KERNEL_FILE="$(basename "$(ls -1 "${MOUNTDIR}"/fedora-coreos-*-live-kernel-x86_64)")"
|
||
|
declare -r INITRAMFS_FILE="$(basename "$(ls -1 "${MOUNTDIR}"/fedora-coreos-*-live-initramfs.x86_64.img)")"
|
||
|
declare -r ROOTFS_FILE="$(basename "$(ls -1 "${MOUNTDIR}"/fedora-coreos-*-live-rootfs.x86_64.img)")"
|
||
|
|
||
|
echo "dhcp-option=encap:129,1,\"${KERNEL_FILE}\"" > /root/dhcp/dhcp-options
|
||
|
echo "dhcp-option=encap:129,2,\"${INITRAMFS_FILE}\"" >> /root/dhcp/dhcp-options
|
||
|
echo "dhcp-option=encap:129,3,\"${ROOTFS_FILE}\"" >> /root/dhcp/dhcp-options
|