# Super Grub Disk - autoiso.cfg # Copyright (C) 2009,2010,2011,2012,2013,2014,2015 Adrian Gibanel Lopez. # # Super Grub Disk is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Super Grub Disk is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Super Grub Disk. If not, see . set option_title=$"Bootable ISOs"" "$"(in /boot-isos or /boot/boot-isos)" function pathname { insmod regexp ; regexp -s 2:"$2" '^(\(.*\))?(/.*)$' "$1"; rmmod regexp; } function devname { insmod regexp ; regexp -s "$2" '^(\(.*\)).*$' "$1"; rmmod regexp; } function loopback_iso_entry { realdev="$1" isopath="$2" loopdev="$3" if test -f /boot/grub/loopback.cfg; then cfgpath=/boot/grub/loopback.cfg elif test -f /grub/loopback.cfg; then cfgpath=/grub/loopback.cfg else return 1; fi echo loopback.cfg $isopath: yes menuentry "${finaloption_tab_str}${isopath} (${realdev}) GRUB Loopback Config" "$realdev" "$isopath" "$cfgpath" { set device="$2" set iso_path="$3" set cfg_path="$4" export iso_path set loopname=loopdev_cfg while [ -d "(${loopname})/" ]; do set loopname=${loopname}_2 done loopback $loopname "${device}${iso_path}" set root="(${loopname})" configfile $cfg_path loopback -d $loopname } return 0 } function grml_iso_entry { realdev="$1" isopath="$2" loopdev="$3" result=1 for dir in /boot/grml /boot/grmlsmall /boot/grmlmedium; do if ! test -f ${dir}/linux26 -a -f ${dir}/initrd.gz; then continue; fi echo grml $isopath: yes result=0 menuentry "${finaloption_tab_str}GRML Linux (${realdev}${isopath})" \ "$realdev" "$isopath" "$dir" { set device="$2" set isopath="$3" set grmldir="$4" loopback loopdev_grml "${device}${isopath}" set root=(loopdev_grml) linux $grmldir/linux26 findiso="$isopath" apm=power-off quiet \ boot=live nomce initrd $grmldir/initrd.gz loopback -d loopdev_grml } done return $result } function pmagic_iso_entry { realdev="$1" isopath="$2" loopdev="$3" if ! test -f /pmagic/bzImage -a -f /pmagic/initramfs; then return 1; fi echo pmagic $isopath: yes menuentry "${finaloption_tab_str}Parted Magic (${realdev}${isopath})" "$realdev" "$isopath" { set device="$2" set isopath="$3" loopback loopdev_pmagic "${device}${isopath}" set root=(loopdev_pmagic) linux /pmagic/bzImage iso_filename="$isopath" edd=off noapic \ load_ramdisk=1 prompt_ramdisk=0 rw sleep=10 loglevel=0 \ keymap=$langcode initrd /pmagic/initramfs loopback -d loopdev_pmagic } return 0 } function sidux_iso_entry { realdev="$1" isopath="$2" loopdev="$3" result=1 for kernel in /boot/vmlinuz-*-sidux-*; do if ! test -f "$kernel"; then continue; fi insmod regexp regexp -s 1:v1 -s 2:v2 '/boot/vmlinuz-(.*)-sidux-(.*)' "$kernel" rmmod regexp initrd="/boot/initrd.img-$v1-sidux-$v2" if ! test -f "$initrd"; then continue; fi result=0 echo sidux $isopath: yes menuentry "${finaloption_tab_str}Sidux vmlinux-$v1-sidux-$v2 (${realdev}${isopath})" "$realdev" "$isopath" "$kernel" "$initrd" { set device="$2" set isopath="$3" set kernel="$4" set initrd="$5" loopback loopdev_sidux "${device}${isopath}" set root=(loopdev_sidux) linux $kernel fromiso=$isopath boot=fll quiet initrd $initrd loopback -d loopdev_sidux } done return $result } function slax_iso_entry { realdev="$1" isopath="$2" loopdev="$3" if ! test -f /boot/vmlinuz -a -f /boot/initrd.gz; then return 1; fi echo slax $isopath: yes menuentry "${finaloption_tab_str}Slax Linux (${realdev}${isopath})" "$realdev" "$isopath" { set device="$2" set isopath="$3" loopback loopdev_slax "${device}${isopath}" set root=(loopdev_slax) linux /boot/vmlinuz from=$isopath ramdisk_size=6666 root=/dev/ram0 rw initrd /boot/initrd.gz loopback -d loopdev_slax } return 0 } function tinycore_iso_entry { realdev="$1" isopath="$2" loopdev="$3" if ! test -f /boot/bzImage -a -f /boot/tinycore.gz; then return 1; fi echo tinycore $isopath: yes menuentry "${finaloption_tab_str}Tinycore Linux (${realdev}${isopath})" "$realdev" "$isopath" { set device="$2" set isopath="$3" loopback loopdev_tiny "${device}${isopath}" set root=(loopdev_tiny) linux /boot/bzImage initrd /boot/tinycore.gz loopback -d loopdev_tiny } return 0 } function casper_iso_entry { realdev="$1" isopath="$2" loopdev="$3" if ! test -f /casper/vmlinuz; then return 1; fi initrd= for f in /casper/initrd.*z; do if ! test -f "$f"; then continue; fi pathname "$f" initrd done if test -z "$initrd"; then return 1; fi echo casper $isopath: yes menuentry "${finaloption_tab_str}Casper based Linux (${realdev}${isopath})" "$realdev" "$isopath" "$initrd" { set device="$2" set isopath="$3" set initrd="$4" loopback loopdev_casper "${device}${isopath}" set root=(loopdev_casper) linux /casper/vmlinuz boot=casper iso-scan/filename="$isopath" quiet splash noprompt keyb="$langcode" \ debian-installer/language="$langcode" console-setup/layoutcode?="$langcode" -- initrd $initrd loopback -d loopdev_casper } return 0 } function scan_isos { isodirs="$*" update_sg2d_devices for dev in ${sg2d_devices}; do getdevice iso_device $dev for dir in $isodirs; do for file in \ (${iso_device})/${dir}/*.iso \ (${iso_device})/${dir}/*.ISO \ ; do if ! test -f "$file"; then continue; fi pathname $file isopath if test -z "$dev" -o -z "$isopath"; then continue; fi if ! loopback loopdev_scan "$file"; then continue; fi saved_root=$root set root=(loopdev_scan) if loopback_iso_entry $dev $isopath (loopdev_scan); then true; elif grml_iso_entry $dev $isopath (loopdev_scan); then true; elif pmagic_iso_entry $dev $isopath (loopdev_scan); then true; elif sidux_iso_entry $dev $isopath (loopdev_scan); then true; elif slax_iso_entry $dev $isopath (loopdev_scan); then true; elif tinycore_iso_entry $dev $isopath (loopdev_scan); then true; elif casper_iso_entry $dev $isopath (loopdev_scan); then true; else true; fi set root=$saved_root loopback -d loopdev_scan done done done return 0 } function run_option { source "${sg2d_directory}/tools.cfg" langcode="$lang" insmod regexp scan_isos boot-isos boot/boot-isos bootisos boot/bootisos BOOTISOS /BOOT/BOOTISOS rmmod regexp }