Commit 96098c62 authored by OSAK Buildhauer's avatar OSAK Buildhauer

Generate grub config

parent 2d8e0983
*.iso
grub_target.cfg
#!/bin/bash
function extract_kernel() {
iso_file="$1"
loopback="$(mktemp)"
7z e -so "$iso_file" boot/grub/loopback.cfg > "$loopback"
grep -m 1 -o "linux.*vmlinuz" "$loopback" | awk '{ print $2 }'
rm "$loopback"
}
function extract_initrd() {
iso_file="$1"
loopback="$(mktemp)"
7z e -so "$iso_file" boot/grub/loopback.cfg > "$loopback"
grep -m 1 -o "initrd.*initrd\S*" "$loopback" | awk '{ print $2 }'
rm "$loopback"
}
function extract_release() {
iso_file="$1"
flavor="$(echo "$iso_file" | cut -d "-" -f 1)"
number="$(echo "$iso_file" | cut -d "-" -f 2)"
echo "${flavor^} $number" # ^ capitalizes 1st letter
}
function sed_grub_template() {
iso_file="$1"
distribution_grep="$2" # KDE / XFCE
sed_target="$3"
sed "s|__${distribution_grep}_KERNEL__|$(extract_kernel "$iso_file")|g" -i "$sed_target"
sed "s|__${distribution_grep}_INITRD__|$(extract_initrd "$iso_file")|g" -i "$sed_target"
sed "s|__${distribution_grep}_RELEASE__|$(extract_release "$iso_file")|g" -i "$sed_target"
sed "s|__${distribution_grep}_ISONAME__|$iso_file|g" -i "$sed_target"
}
kubuntu=kubuntu-18.04.1-desktop-amd64.iso
xubuntu=xubuntu-18.04.1-desktop-amd64.iso
grub_template="grub_template.cfg"
grub_target="grub_target.cfg"
cp "$grub_template" "$grub_target"
sed_grub_template "$kubuntu" "KDE" "$grub_target"
sed_grub_template "$xubuntu" "XFCE" "$grub_target"
if loadfont /boot/grub/font.pf2 ; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
fi
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
color yellow/black white/red
set pager=1
set gfxpayload=keep
function kde_LoadCasper {
loopback loop ($root)/${kde_isoname}
echo "Loading kernel"
linux (loop)__KDE_KERNEL__ boot=casper file=/isodevice/preseed/lip.seed ${cmdline} iso-scan/filename=/kubuntu.iso sysrq_always_enabled pstore.pstore_disable nosplash verbose --
echo "Loading initrd"
initrd (loop)__KDE_INITRD__
echo "Starting kernel"
}
function kde_menu {
menuentry "Empfohlen: ${kde_release} (deutsch)" {
set cmdline="debian-installer/language=de keyboard-configuration/layoutcode?=de"
kde_LoadCasper
}
menuentry "Recommended: ${kde_release} (english)" {
set cmdline=""
kde_LoadCasper
}
menuentry "${kde_release} (deutsch, failsafe)" {
set cmdline="debian-installer/locale=de_DE console-setup/layoutcode=de nomodeset noplymouth nosplash verbose text noacpi"
kde_LoadCasper
}
menuentry "${kde_release} (english, failsafe)" {
set cmdline="nomodeset noplymouth nosplash verbose text noacpi"
kde_LoadCasper
}
menuentry "${kde_release} (deutsch, ohne LIPNSA)" {
set cmdline="debian-installer/locale=de_DE console-setup/layoutcode=de fnord"
kde_LoadCasper
}
menuentry "${kde_release} (english, without LIPNSA)" {
set cmdline="fnord"
kde_LoadCasper
}
}
function xfce_LoadCasper {
loopback loop ($root)/${xfce_isoname}
echo "Loading kernel"
linux (loop)__XFCE_KERNEL__ boot=casper file=/isodevice/preseed/lip.seed ${cmdline} iso-scan/filename=/kubuntu.iso sysrq_always_enabled pstore.pstore_disable nosplash verbose --
echo "Loading initrd"
initrd (loop)__XFCE_INITRD__
echo "Starting kernel"
}
function xfce_menu {
menuentry "Empfohlen: ${xfce_release} (deutsch)" {
set cmdline="debian-installer/language=de keyboard-configuration/layoutcode?=de"
xfce_LoadCasper
}
menuentry "Recommended: ${xfce_release} (english)" {
set cmdline=""
xfce_LoadCasper
}
menuentry "${xfce_release} (deutsch, failsafe)" {
set cmdline="debian-installer/locale=de_DE console-setup/layoutcode=de nomodeset noplymouth nosplash verbose text noacpi"
xfce_LoadCasper
}
menuentry "${xfce_release} (english, failsafe)" {
set cmdline="nomodeset noplymouth nosplash verbose text noacpi"
xfce_LoadCasper
}
menuentry "${xfce_release} (deutsch, ohne LIPNSA)" {
set cmdline="debian-installer/locale=de_DE console-setup/layoutcode=de fnord"
xfce_LoadCasper
}
menuentry "${xfce_release} (english, without LIPNSA)" {
set cmdline="fnord"
xfce_LoadCasper
}
}
set kde_release="__KDE_RELEASE__"
set kde_isoname="__KDE_ISONAME__"
kde_menu
set xfce_release="__XFCE_RELEASE__"
set xfce_isoname="__XFCE_ISONAME__"
xfce_menu
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment