#!/bin/sh

# small script to add a dynebolic iso to grub2
# tested on ubuntu and debian
# no need to repartition
# doesn't changes data on HD

# FWIW, copyleft by Jaromil, GNU GPL v3

if [ -z $1 ]; then
    echo "usage: $0 full_path_to.iso"
    exit 1
fi

ISOPATH=$1

if ! [ -r $ISOPATH ]; then
    echo "Error: no iso found: $ISOPATH"
    exit 1
fi

echo "This program should be run as root."

cat <<EOF > /etc/grub.d/35_dynebolic
#!/bin/sh
exec tail -n +3 \$0
# This file adds a grub entry to boot into a dynebolic iso
menuentry "dyne:III - live dynebolic system" --class gnu-linux --class gnu --class os {
	search --set --file $ISOPATH
        loopback loop $ISOPATH
	root=(loop)
        linux /live/vmlinuz boot=live dyneiso=$ISOPATH noeject noprompt --
        initrd /live/initrd.img
}
EOF

chmod +x /etc/grub.d/35_dynebolic
update-grub2
