Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (39 sloc) 1.576 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/bin/bash
################################################################################
# Purpose: hackish script to generate netboot package without booting the system
################################################################################

if [ $# -lt 2 ] ; then
  echo "Usage: $0 <chroot> <output_file>" >&2
  exit 1
fi

set -u
set -e

CHROOT="${1}"
OUTPUT_FILE="${2}"

if ! [ -f "${CHROOT}/etc/grml_version" ] ; then
  echo "Error: could not read ${CHROOT}/etc/grml_version" >&2
  exit 1
fi

GRML_VERSION="$(awk '{print $1"_"$2}' ${CHROOT}/etc/grml_version)"

if ! [ -r "${CHROOT}/usr/lib/syslinux/pxelinux.0" ] ; then
  echo "Error: /usr/lib/syslinux/pxelinux.0 not found. Please install syslinux[-common." >&2
  exit 1
fi

OUTPUTDIR="$(mktemp -d)" || exit 1
WORKING_DIR="${OUTPUTDIR}/grml_netboot_package_${GRML_VERSION}/tftpboot/"
mkdir -p "$WORKING_DIR" || exit 2

cp "$CHROOT"/boot/vmlinuz-* "$WORKING_DIR"/vmlinuz
cp "$CHROOT"/boot/initrd.img-* "$WORKING_DIR"/initrd.img
cp "$CHROOT"/usr/lib/syslinux/pxelinux.0 "${WORKING_DIR}/pxelinux.0"

mkdir -p "${WORKING_DIR}/pxelinux.cfg"
cat > "${WORKING_DIR}/pxelinux.cfg/default" << EOF
default grml
label grml
kernel vmlinuz
append initrd=initrd.img root=/dev/nfs rw nfsroot=192.168.0.1:/live/image boot=live apm=power-off quiet nomce noprompt noeject vga=791
EOF

if tar -C "$OUTPUTDIR" -acf "${OUTPUT_FILE}" "grml_netboot_package_${GRML_VERSION}" ; then
  rm -rf "${OUTPUTDIR}"
  echo "Generated ${OUTPUT_FILE}"
fi

## END OF FILE #################################################################
Something went wrong with that request. Please try again.