summaryrefslogtreecommitdiff
path: root/mkgrubcfg.sh
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2016-08-08 22:01:36 +0800
committerIru Cai <mytbk920423@gmail.com>2016-08-08 22:19:00 +0800
commit78b1d0d7b85b02b2ba7fe72227f6d62208b23086 (patch)
tree762d7eb00520384938cb4396575e475a48887eb2 /mkgrubcfg.sh
parentce3ca5abc315668969fdcec50eb0d2bc645f27dd (diff)
downloadliveusb-builder-78b1d0d7b85b02b2ba7fe72227f6d62208b23086.tar.xz
add gen_grubcfg() to generate GRUB config from entry file
Diffstat (limited to 'mkgrubcfg.sh')
-rwxr-xr-xmkgrubcfg.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/mkgrubcfg.sh b/mkgrubcfg.sh
new file mode 100755
index 0000000..4be770b
--- /dev/null
+++ b/mkgrubcfg.sh
@@ -0,0 +1,37 @@
+# generate GRUB menuentry
+# usage: UUID="$UUID" ISOFILE="$ISOFILE" ./mkgrubcfg.sh <entryfile>
+#
+# variables in entryfile:
+# - UUID: the UUID of the partition
+# - ISOFILE: the file name of iso
+#
+# parameters in entry file:
+# - TITLE: GRUB menu entry title
+# - KERNEL: path to kernel image
+# - INITRD: path to initramfs/initrd image
+# - OPTION: kernel command line
+# - X64: y/n, indicates whether it's 64-bit
+
+source "$1"
+
+if [ "$X64" = y ]; then
+ echo 'if cpuid -l; then'
+fi
+
+cat << EOF
+menuentry '$TITLE' {
+ linux $KERNEL $OPTION
+EOF
+
+for _initrd in "${INITRD[@]}"
+do
+ echo -e "\tinitrd $_initrd"
+done
+
+echo '}'
+
+if [ "$X64" = y ]; then
+ echo 'fi'
+fi
+
+echo