]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Allow an initrd script to be provided via genfsimg
authorMichael Brown <mcb30@ipxe.org>
Fri, 22 Jan 2021 18:33:51 +0000 (18:33 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 22 Jan 2021 18:34:47 +0000 (18:34 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/util/genfsimg

index b30ffe44f36aa851cbc466cb1c0054093d4ebe53..b9d5b3f44c5f0b4335eafb09a751c31f75ea1111 100755 (executable)
@@ -11,9 +11,10 @@ help() {
     echo "usage: ${0} [OPTIONS] foo.lkrn|foo.efi [bar.lkrn|bar.efi,...]"
     echo
     echo "where OPTIONS are:"
-    echo " -h       show this help"
-    echo " -o FILE  save image to file"
-    echo " -p PAD   pad filesystem (in kB)"
+    echo " -h         show this help"
+    echo " -o FILE    save image to file"
+    echo " -p PAD     pad filesystem (in kB)"
+    echo " -s SCRIPT  use executable script"
 }
 
 # Get hex byte from binary file
@@ -113,7 +114,8 @@ copy_syslinux_file() {
 #
 OUTFILE=
 PAD=0
-while getopts "hlo:p:" OPTION ; do
+SCRIPT=
+while getopts "hlo:p:s:" OPTION ; do
     case "${OPTION}" in
        h)
            help
@@ -125,6 +127,9 @@ while getopts "hlo:p:" OPTION ; do
        p)
            PAD="${OPTARG}"
            ;;
+       s)
+           SCRIPT="${OPTARG}"
+           ;;
        *)
            help
            exit 1
@@ -197,9 +202,15 @@ for FILENAME ; do
                echo "SAY iPXE boot image" > "${SYSLINUXCFG}"
                echo "TIMEOUT 30" >> "${SYSLINUXCFG}"
                echo "DEFAULT ${DESTFILE}" >> "${SYSLINUXCFG}"
+               if [ -n "${SCRIPT}" ] ; then
+                   cp "${SCRIPT}" "${BIOSDIR}/autoexec.ipxe"
+               fi
            fi
            echo "LABEL ${DESTFILE}" >> "${SYSLINUXCFG}"
            echo " KERNEL ${DESTFILE}" >> "${SYSLINUXCFG}"
+           if [ -n "${SCRIPT}" ] ; then
+               echo " APPEND initrd=autoexec.ipxe" >> "${SYSLINUXCFG}"
+           fi
            LKRN=1
            ;;
        *.efi)