diff --git a/mklive.sh.in b/mklive.sh.in index cf2aff0..19e63d3 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -78,7 +78,8 @@ Options: -o Output file name for the ISO image (auto if unset). -p "pkg pkgN ..." Install additional packages into the ISO image. -I Include directory structure under given path into rootfs - + -H Add scripts in given directory as startup hooks to the init + procedure. -C "cmdline args" Add additional kernel command line arguments. -T "title" Modify the bootloader title. -K Do not remove builddir. @@ -181,6 +182,13 @@ cleanup_rootfs() { rm -r $ROOTFS/usr/lib/dracut/modules.d/01autoinstaller } +setup_init_hooks() { + hooks_dir=/usr/local/custom-scripts/ + mkdir -p ${ROOTFS}${hooks_dir} + find $HOOKS_DIRECTORY -mindepth 1 -maxdepth 1 -exec cp -rfpPv {} ${ROOTFS}${hooks_dir} \; + echo 'find '${hooks_dir}' -type f -executable -exec {} \;' >> $ROOTFS/etc/rc.local +} + generate_isolinux_boot() { cp -f $SYSLINUX_DATADIR/isolinux.bin "$ISOLINUX_DIR" cp -f $SYSLINUX_DATADIR/ldlinux.c32 "$ISOLINUX_DIR" @@ -296,7 +304,7 @@ generate_iso_image() { # # main() # -while getopts "a:b:r:c:C:T:Kk:l:i:I:s:S:o:p:h" opt; do +while getopts "a:b:r:c:C:T:Kk:l:i:I:H:s:S:o:p:h" opt; do case $opt in a) BASE_ARCH="$OPTARG";; b) BASE_SYSTEM_PKG="$OPTARG";; @@ -306,7 +314,8 @@ while getopts "a:b:r:c:C:T:Kk:l:i:I:s:S:o:p:h" opt; do k) KEYMAP="$OPTARG";; l) LOCALE="$OPTARG";; i) INITRAMFS_COMPRESSION="$OPTARG";; - I) INCLUDE_DIRECTORY="$OPTARG";; + I) INCLUDE_DIRECTORY=$(cd "$OPTARG" && pwd);; + H) HOOKS_DIRECTORY=$(cd "$OPTARG" && pwd);; s) SQUASHFS_COMPRESSION="$OPTARG";; S) ROOTFS_FREESIZE="$OPTARG";; o) OUTPUT_FILE="$OPTARG";; @@ -359,7 +368,8 @@ GRUB_DIR="$BOOT_DIR/grub" ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg" CURRENT_STEP=0 STEP_COUNT=9 -[ -n "${INCLUDE_DIRECTORY}" ] && ((STEP_COUNT=STEP_COUNT+1)) +[ -n "${INCLUDE_DIRECTORY}" ] && STEP_COUNT=$((STEP_COUNT+1)) +[ -n "${HOOKS_DIRECTORY}" ] && STEP_COUNT=$((STEP_COUNT+1)) : ${SYSLINUX_DATADIR:=$VOIDHOSTDIR/usr/share/syslinux} : ${GRUB_DATADIR:=$VOIDHOSTDIR/usr/share/grub} @@ -412,6 +422,9 @@ generate_grub_efi_boot print_step "Cleaning up rootfs..." cleanup_rootfs +print_step "Creating startup hooks..." +setup_init_hooks + print_step "Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..." generate_squashfs