summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions.sh8
-rwxr-xr-xmkgrubcfg.sh37
2 files changed, 45 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh
index 4e97511..8c83cb3 100644
--- a/functions.sh
+++ b/functions.sh
@@ -34,6 +34,14 @@ process_distro() {
ISOMNT="/media/$ISOFILE"
}
+gen_grubcfg() {
+ local entry
+ for entry in "distro/$1/entry"*
+ do
+ UUID="$UUID" ISOFILE="$ISOFILE" ./mkgrubcfg.sh "$entry"
+ done
+}
+
download_iso() {
mkdir -p isofiles
for url in ${mirrorlist[@]}
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