Ok, this should do it. It checks if isoinfo exists, and warns about the partition format.
the "lz problem" is solved, as it now gets the name from the ISO. Thanks, oshunluvr
It's still in "testing" mode, it doesn't actually write /etc/grub.d/40_custom or update grub, so feel free to play with it. It still needs the service menu for the ISO name :·)
the "lz problem" is solved, as it now gets the name from the ISO. Thanks, oshunluvr
Code:
#!/bin/bash ########### This script will add an entry to your grub boot menu for the ISO selected by the Dolphin Service Menu ########## ########### It will not work if not called from it ########## ########### ########### To actually make it work, comment out the "echo "$grubentry" >>customentry.txt" line ########## ########### and uncomment the following one ########### ########### Do the same for the"ls -la" one ########### echo A couple of checks: FILE=$(which isoinfo) if [ -f "$FILE" ]; then echo "$FILE exist." $'\e[0;36m' "OK."$'\e[0;37m' else echo "isoinfo is" $'\e[0;31m' "not installed." $'\e[0;37m' "Please [sudo apt] install genisoimage and run this again.";exit fi echo part=$(df -P . | sed -n '$s/[[:blank:]].*//p');p1=${part:7:1};p2=${part:8:1};p3=$(tr abcdefghij 0123456789 <<< "$p1");p4="hd"$p3,$p2 echo The partition your ISO is on is $'\e[0;32m' $part $'\e[0;37m' echo "If this is"$'\e[0;31m' "not"$'\e[0;37m' "in /dev/sdxy (or /dev/hdxy) format (e.g. /dev/sda1 or /dev/hda1)" echo "the partition name will" $'\e[0;31m'"not be converted" $'\e[0;37m'"correctly to grub2 format" echo "You will have to manually edit /etc/grub.d/40_custom" echo echo isoentry="$1" lz=$(isoinfo -l -i $isoentry |grep -i initrd | awk '{ print substr($NF, 1, length($NF)-2)}' | tr '[A-Z]' '[a-z]') grubentry="$(cat <<-EOF # # #!/bin/sh exec tail -n +3 \$0 menuentry "New bootable ISO" { set isofile="$isoentry" loopback loop ($p4)\$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=\$isofile noprompt noeject toram initrd (loop)/casper/$lz } EOF )" #echo $grubentry #exit #echo $'\e[0;34m' #apt moo ##### this is just to make the script look prettier :·) echo $'\e[0;36m'Adding entry to /etc/grub.d/40_custom... sleep 1 #pkexec echo "$grubentry" >>/etc/grub.d/40_custom ## This is the actual line echo "$grubentry" >>~/.local/share/kservices5/ServiceMenus/customentry.txt ## This is the line for testing purposes :·) echo $'\e[0;36m'Done echo $'\e[0;36m'Entry added to /etc/grub.d/40_custom echo echo The added entry was: echo $'\e[0;37m' tail -10 ~/.local/share/kservices5/ServiceMenus/customentry.txt echo $'\e[0;36m' echo while true; do read -p "Does that look correct? y/n: " yn case $yn in [Nn]* ) echo Close the window to exit.;exit;; [Yy]* ) echo "OK. Let's update grub then."; break;; esac done echo echo while true; do read -p "Would you like to update grub? y/n: " yn case $yn in [Nn]* ) echo Close the window to exit.;exit;; [Yy]* ) echo OK.; break ;; esac done echo echo "Updating grub..." echo $'\e[0;37m' #pkexec update-grub ## This is the actual line ls -la ## This is the line for testing purposes :·) echo $'\e[0;36m' echo "Let's check. " echo "These are the last 24 lines of /boot/grub/grub.cfg:" echo $'\e[0;37m' tail -24 /boot/grub/grub.cfg echo $'\e[0;36m' echo "You should find an entry for 'New bootable ISO' in your grub menu that should boot the OS" echo echo Close the window to exit.
Comment