#!/bin/bash #
# grub
echo "set default=3" > /mnt/x/boot/grub/grub.cfg
echo "set timeout=3" >> /mnt/x/boot/grub/grub.cfg
echo "" >> /mnt/x/boot/grub/grub.cfg
echo "menuentry 'Boot from configfile'{" >> /mnt/x/boot/grub/grub.cfg
echo "configfile /boot/grub/configfile.cfg" >> /mnt/x/boot/grub/grub.cfg
echo "}" >> /mnt/x/boot/grub/grub.cfg
echo "" >> /mnt/x/boot/grub/grub.cfg
echo "menuentry 'Parted Magic'\{" >> /mnt/x/boot/grub/grub.cfg
echo "configfile /boot/grub/pmagic.cfg" >> /mnt/x/boot/grub/grub.cfg
echo "}" >> /mnt/x/boot/grub/grub.cfg
echo "" >> /mnt/x/boot/grub/grub.cfg
echo "menuentry 'Windows OS'{" >> /mnt/x/boot/grub/grub.cfg
echo "configfile /boot/grub/windows.cfg" >> /mnt/x/boot/grub/grub.cfg
echo "}" >> /mnt/x/boot/grub/grub.cfg

# windows
echo "set default=0" > /mnt/x/boot/grub/windows.cfg
echo "set timeout=3" >> /mnt/x/boot/grub/windows.cfg
echo "" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda1'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,1)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda2'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,2)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda3'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,3)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda4'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,4)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda5'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,5)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda6'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,6)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda7'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,7)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

echo "menuentry 'Windows OS /dev/sda8'{" >> /mnt/x/boot/grub/windows.cfg
echo "insmod ntfs" >> /mnt/x/boot/grub/windows.cfg
echo "set root='(hd0,8)'" >> /mnt/x/boot/grub/windows.cfg
echo "chainloader +1" >> /mnt/x/boot/grub/windows.cfg
echo "}" >> /mnt/x/boot/grub/windows.cfg

# configfile
echo "set default=0" > /mnt/x/boot/grub/configfile.cfg
echo "set timeout=3" >> /mnt/x/boot/grub/configfile.cfg
echo "" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile /boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda1'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,1)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda2'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,2)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda3'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,3)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda4'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,4)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda5'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,5)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda6'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,6)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda7'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,7)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

echo "menuentry 'Boot from configfile /dev/sda8'{" >> /mnt/x/boot/grub/configfile.cfg
echo "configfile (hd0,8)/boot/grub/grub.cfg" >> /mnt/x/boot/grub/configfile.cfg
echo "}" >> /mnt/x/boot/grub/configfile.cfg

mkdir -p /mnt/x/boot/iso

# pmagic
echo "set superusers="admin"" > /mnt/x/boot/grub/pmagic.cfg
echo "" >> /mnt/x/boot/grub/pmagic.cfg
echo "password admin admin" >> /mnt/x/boot/grub/pmagic.cfg
echo "password user pass" >> /mnt/x/boot/grub/pmagic.cfg
echo "" >> /mnt/x/boot/grub/pmagic.cfg
echo "set default=0" >> /mnt/x/boot/grub/pmagic.cfg
echo "set timeout=3" >> /mnt/x/boot/grub/pmagic.cfg
echo "" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic-6.7.iso" ];then
wget -O /mnt/x/boot/iso/pmagic-6.7.iso http://www.solmu.org/pub/iso/pmagic/pmagic-6.7.iso
fi

echo "menuentry 'Parted Magic (pmagic-6.7.iso)' --users admin{" > /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic-6.7.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= boot=live load_ramdisk=1 keymap=fi prompt_ramdisk=0 noeject noprompt" >> $
echo "initrd (loop)/pmagic/initramfs" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2012_10_10.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2012_10_10.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2012_10_10.iso
fi

echo "menuentry 'Parted Magic (pmagic_2012_10_10.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2012_10_10.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2013_05_01.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2013_05_01.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2013_05_01.iso
fi

echo "menuentry 'Parted Magic (pmagic_2013_05_01.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2013_05_01.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2013_08_01.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2013_08_01.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2013_08_01.iso
fi

echo "menuentry 'Parted Magic (pmagic_2013_08_01.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2013_08_01.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2015_05_04.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2015_05_04.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2015_05_04.iso
fi

echo "menuentry 'Parted Magic (pmagic_2015_05_04.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2015_05_04.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2016_07_12.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2016_07_12.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2016_07_12.iso
fi

echo "menuentry 'Parted Magic (pmagic_2016_07_12.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2016_07_12.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2017_09_05.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2017_09_05.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2017_09_05.iso
fi

echo "menuentry 'Parted Magic (pmagic_2017_09_05.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2017_09_05.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2018_08_06.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2018_08_06.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2018_08_06.iso
fi

echo "menuentry 'Parted Magic (pmagic_2018_08_06.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2018_08_06.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2019_09_03.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2019_09_03.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2019_09_03.iso
fi

echo "menuentry 'Parted Magic (pmagic_2019_09_03.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2019_09_03.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2020_08_23.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2020_08_23.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2020_08_23.iso
fi

echo "menuentry 'Parted Magic (pmagic_2020_08_23.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2020_08_23.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2021_08_30.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2021_08_30.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2021_08_30.iso
fi

echo "menuentry 'Parted Magic (pmagic_2021_08_30.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2021_08_30.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2022_09_04.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2022_09_04.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2022_09_04.iso
fi

echo "menuentry 'Parted Magic (pmagic_2022_09_04.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2022_09_04.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg


if [ ! -f "/mnt/x/boot/iso/pmagic_2023_08_22.iso" ];then
wget -O /mnt/x/boot/iso/pmagic_2023_08_22.iso http://www.solmu.org/pub/iso/pmagic/pmagic_2023_08_22.iso
fi

echo "menuentry 'Parted Magic (pmagic_2023_08_22.iso)' --users admin{" >> /mnt/x/boot/grub/pmagic.cfg
echo "set isofile="/boot/iso/pmagic_2023_08_22.iso"" >> /mnt/x/boot/grub/pmagic.cfg
echo "loopback loop " >> /mnt/x/boot/grub/pmagic.cfg
echo "linux (loop)/pmagic/bzImage iso_filename= edd=off load_ramdisk=1 prompt_ramdisk=0 rw keymap=fi loglevel=9 max_loop=256" >> /mnt/x/boot/grub/pmagic.cfg
echo "initrd (loop)/pmagic/initrd.img" >> /mnt/x/boot/grub/pmagic.cfg
echo "}" >> /mnt/x/boot/grub/pmagic.cfg