#!/bin/bash
if [ $(whoami) != "root" ];then
 echo "This script must be run as root, so it can mount ISO images on the filesystem during the building process."
 exit 1
fi
set -e
#multicd.sh 4.8
#Copyright (c) 2009 maybeway36
#DeLi, Austrumi, GeeXbox portions (C) PsynoKhi0
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.

# #Arguments:
# b -- don't include Balder
# m -- don't include Memtest86+
# v -- be verbose
# md5 / c -- include an MD5 checksum file (md5sum.txt)
# condeb -- "Conservative Debian": only copy live and install folders from Debian Live (no READMEs)
# modules -- Manually choose which of the original Slax modules to include (requires dialog)

#Changelog:
#v1.0 - first released version, with DSL, Puppy and GParted support
#v1.1 - added TinyMe support, added -quiet option to mkisofs
#v1.2 - added Slax support, added FreeDOS Balder image (downloaded from finnix.org during build process)
#v1.3 - now you can use includes to add more bootable fun!
#v1.4 - Ubuntu and Debian mini.iso netboot installers can now be added to the CD.
#v1.5 - Fedora 9's "boot.iso" aka "netinst.iso" can now be added to the CD. (March 30, 2008)
#v1.6 - Support for SliTaz, a 25MB (!) live CD, has been added. (April 1, 2008) (No, this isn't a joke)
#v1.6.1 - The script now prefers files from the installed "syslinux" deb package over downloading new ones.
#v1.7 - Support for SystemRescueCd has been added. I recommend using this insead of GParted if it fits on the disc.
#v1.8 - General bugfixes, support for the DBAN iso image added. (April 19, 2008)
#v1.8.1 - More bugfixes. (April 25, 2008)
#v1.9 - Updated default SYSLINUX version; Balder no longer downloaded by default. (May 6, 2008)
#v2.0 - Balder is now downloaded by default again; both it and Memtest86+ can be disabled on the command line. (May 9, 2008)
#v2.1 - Support for Feather Linux and Debian Live added. (May 23, 2008)
#v2.2 - Support for Super Grub Disk added, a few things cleaned up. (May 29, 2008)
#v2.3 - Added antiX and GRUB4DOS (a GRUB-like bootloader with some more features.) (June 7, 2008)
#v2.4 - Added Wolvix support (tested with Wolvix-cub) and changed the command-line options for the script. (June 11, 2008)
#v2.5 - You can now add as many floppy or hard disk images as you want, by giving them the extension ".mcd.img". (June 20, 2008)
#v2.6 - Reordered menu options; new feature to add additional Slax 6 modules. (June 30, 2008)
#v2.7 - Added support for Trinity Rescue Kit. TRK, GParted and antiX use submenus now. Changed misc floppy extension form .mcd.img to just .img. Super Grub Disk is now handled just like the other floppies, change its name to SuperGrubDisk.img if you use it. (July 12, 2008)
#v2.8 - Support added for openSUSE and Mandriva netboot installers. Also, you can include your own files on the CD by putting them in includes. (July 16, 2008)
#v2.9 - Another thing you can add now: the Arch Linux installer (ArchLive) Both "core" and "ftp" work. Also, more bug fixes. (July 25, 2008)
#v3.0 - Support added for NT Password and Registry Editor as well as Parted Magic. (July 30, 2008)
#v3.0.1 - Fixed syslinux downloading bug. (July 31, 2008)
#v3.1 - Added Ultimate boot CD support. This gives you a lot of utilities to choose from. (August 2, 2008)
#v3.2 - Added DeLi Linux support, written by PsynoKhi0. (August 8, 2008)
#v3.3 - Removed support for the old GParted Live CD and added support for the new one. Also, the TRK submenu now has a splash screen. (August 19, 2008)
#v3.4 - Fixed typos in the Mandriva syslinux code. Added EASEUS Disk Copy 2.0. DBAN now boots directly instead of with memdisk. There is now an option to add an md5sum file to the CD (-c). (August 22, 2008)
#v3.5 - Improved Debian Live support: almost all files from the ISO will be copied unless you use the "condeb" option. Added module choosing screen for Slax (activate with "modules" option; requires screen.) Updated antiX boot options to those of version 7.5. (August 27, 2008)
#v3.6 - Added support for RIPLinux (either regular or GRUB versions will work.) Also added support for BasicGNU, my own Ubuntu remaster (mostly for my own purposes.) (October 3, 2008)
#v3.6.1 - DSL files have been moved, so the DSL frugla install works now. (October 10, 2008)
#v3.7 - Added FreeDOS 1.0 suppert, Also, if the files "memtest" and/or "balder.imz" are in the current directory, multicd.sh will use these instead of downloading. (November 26, 2008)
#v3.8 - Reordered menu items. Removed BasicGNU. Added support for PING, a small CD for bacing up HD images locally or over a network. See http://ping.windowsdream.com/ for more information. (December 6, 2008)
#v3.9 - Added Clonezilla support. Allowed GParted Live to coexist with Debian Live. (December 24, 2008)
#v3.9.1 - Upgraded SYSLINUX version and fixed a bug. (December 26, 2008)
#v4.0 - Added new feature - disk images in the "games" folder are added under a submenu. .imz images are supported, both in the games folder and outside it. Balder is now downloaded from ibiblio. (January 18, 2009)
#v4.1 - Support added for NetbootCD. (If you use the NetbootCD+Slax iso, save it as netbootcd+slax.iso and the script will add Slax too.) Updated Memtest version. (January 25, 2009)
#v4.2 - Support added for Ubuntu (live CD) and Linux Mint. They can't be on the same disc, however (both use casper.) Also, the modules selector works with NetbootCD+Slax now. (February 2, 2009)
#v4.3 - Lots of new comments. "condeb" option removed to clean up code. Fixed a Slax bug. Added support for Knoppix 5 (only tested with the 5.3.1 Japanese CD so far - multicd will set English as the language.) (Feb 18, 2009)
#v4.4 - Added GeeXbox and Austrumi thanks to PsynoKhi0. I haven't tested them much so far, but with a couple fixes I made, they seem to boot fine. (Feb 22, 2009)
#v4.5 - Fixed a few bugs. Added an option to make Fedora install automatically from mirrors.kernel.org. Knoppix is now knoppix.iso - it worked with Knoppix 6 with no major modifications. Arch updated for version 2009.02. (March 29, 2009)
#v4.6 - Tiny Core Linux and the new NetbootCD added. "NetbootCD+Slax" removed. Quotes added to grep lines that check if ISOs are still mounted. (April 13, 2009)
#v4.7 - INSERT added. Updated SYSLINUX version. Moved games below GRUB4DOS on the menu. (May 14, 2009)
#v4.8 - SYSLINUX downloading changed from 3.80 to * (any), fixing a bug. NetbootCD moved above NTpasswd on the menu. Fixed Parted Magic bug. (June 21, 2009)

#Filenames:
#Ubuntu live CD		ubuntu.iso
#Linux Mint		linuxmint.iso
#Knoppix 5		knoppix5.iso
#Debian Live		binary.iso
#Ultimate Boot CD	ubcd.iso
#DSL			dsl.iso
#Tiny Core Linux	tinycore.iso
#Puppy			puppy.iso
#Feather		feather.iso
#SliTaz			slitaz.iso
#Austrumi		al.iso
#GeeXboX		gbox.iso
#Slax			slax.iso
#Slax modules		ANYTHING.lzm (you can have several of these)
#DeLi Linux		deli.iso
#TinyMe			tinyme.iso
#antiX			antix.iso
#Wolvix			wolvix.iso
#RIPLinux		riplinux.iso
#SystemRescueCd		sysrcd.iso
#Trinity Rescue Kit	trk.iso
#INSERT			insert.iso
#Parted Magic		pmagic.iso
#GParted		gparted.iso
#NetbootCD		netbootcd.iso
#NT Pass. & Reg. Editor	ntpasswd.iso
#EASEUS Disk Copy	diskcopy.iso
#Clonezilla		clonezilla.iso
#PING			ping.iso
#Debian netboot		debian-mini.iso
#Ubuntu netboot		ubuntu-mini.iso
#Fedora netboot		fedora-boot.iso
#openSUSE netboot	opensuse.iso
#Mandriva netboot	mandriva-boot.iso
#Arch Linux		arch.iso
#FreeDOS 1.0		fdbasecd.iso OR fdfullcd.iso
#Floppy images		ANYTHING.img or .imz (you can have several of these)
#Images with games	games/ANYTHING.img or .imz (will create a submenu)
#GRUB4DOS		grub.exe
#DBAN			dban.iso

#Additional files	includes/ (directory)

#Hint: You can combine multiple sub-100MB distros (such as DSL and Puppy) onto a pocket-size 200MB live CD! :)

if echo $* | grep -q "\bb\b";then
 BALDER=0
else
 BALDER=1
fi
if echo $* | grep -q "\bmd5\b";then
 MD5=1
else
 if echo $* | grep -q "\bc\b";then
  MD5=1
 else
  MD5=0
 fi
fi
if echo $* | grep -q "\bm\b";then
 MEMTEST=0
else
 MEMTEST=1
fi
if echo $* | grep -q "\bv\b";then
 VERBOSE=1
else
 VERBOSE=0
fi
if echo $* | grep -q "\bcondeb\b";then
 CONDEB=1
else
 CONDEB=0
fi
if echo $* | grep -q "\bmodules\b";then
 MODULES=1
else
 MODULES=0
fi

if [ $MODULES = 1 ];then
 if which dialog;then
  dialog --checklist "Slax modules to include:" 13 45 6 \
  002-xorg.lzm Xorg on \
  003-desktop.lzm KDE on \
  004-kdeapps.lzm "KDE applications" on \
  005-koffice.lzm "KDE Office" on \
  006-devel.lzm Development on \
  2> ./slaxlist0
  echo >> ./slaxlist0
  cat ./slaxlist0|sed -e 's/"//g' -e 's/ /\n/g'>./slaxlist
  rm ./slaxlist0
 else
  echo "Please install dialog to use the module selector."
  exit 1
 fi
fi

echo "List of boot options that will be included:"

if [ -f ubuntu.iso ];then
 echo "Ubuntu"
 UISO=1
else
 UISO=0
fi
if [ -f linuxmint.iso ];then
 echo "Linux Mint"
 LMISO=1
else
 LMISO=0
fi
if [ -f knoppix5.iso ];then
 echo "Knoppix 5"
 KISO=1
else
 KISO=0
fi
if [ -f binary.iso ];then
 echo "Debian Live (live-helper)"
 DLISO=1
else
 DLISO=0
fi
if [ -f ubcd.iso ];then
 echo "Ultimate Boot CD"
 UBISO=1
else
 UBISO=0
fi
if [ -f dsl.iso ];then
 echo "Damn Small Linux"
 DISO=1
else
 DISO=0
fi
if [ -f tinycore.iso ];then
 echo "Tiny Core Linux"
 TCISO=1
else
 TCISO=0
fi
#NOTE: Only use tinycore2.iso if you want 2 versions of Tiny Core on one CD.
if [ -f tinycore2.iso ];then
 echo "Tiny Core Linux 2"
 TC2ISO=1
else
 TC2ISO=0
fi
if [ -f puppy.iso ];then
 echo "Puppy Linux"
 PISO=1
else
 PISO=0
fi
if [ -f feather.iso ];then
 echo "Feather"
 FISO=1
else
 FISO=0
fi
if [ -f slitaz.iso ];then
 echo "SliTaz"
 STISO=1
else
 STISO=0
fi
if [ -f al.iso ];then
 echo "Austrumi"
 AUISO=1
else
 AUISO=0
fi
if [ -f gbox.iso ];then
 echo "GeeXboX"
 GBOXISO=1
else
 GBOXISO=0
fi
if [ -f slax.iso ];then
 echo "Slax"
 SISO=1
else
 SISO=0
fi
if [ -f deli.iso ];then
 echo "DeLi Linux"
 DELISO=1
else
 DELISO=0
fi
if [ -f tinyme.iso ];then
 echo "TinyMe"
 TISO=1
else
 TISO=0
fi
if [ -f antix.iso ];then
 echo "antiX"
 AISO=1
else
 AISO=0
fi
if [ -f wolvix.iso ];then
 echo "Wolvix"
 WISO=1
else
 WISO=0
fi
if [ -f riplinux.iso ];then
 echo "RIPLinuX"
 RIPISO=1
else
 RIPISO=0
fi
if [ -f sysrcd.iso ];then
 echo "SystemRescueCd"
 SRISO=1
else
 SRISO=0
fi
if [ -f trk.iso ];then
 echo "Trinity Rescue Kit"
 TRISO=1
else
 TRISO=0
fi
if [ -f insert.iso ];then
 echo "INSERT"
 IISO=1
else
 IISO=0
fi
if [ -f pmagic.iso ];then
 echo "Parted Magic"
 PMISO=1
else
 PMISO=0
fi
if [ -f gparted.iso ];then
 echo "GParted Live"
 GISO=1
else
 GISO=0
fi
if [ -f netbootcd.iso ];then
 echo "NetbootCD"
 NBISO=1
else
 NBISO=0
 NBISOSLAX=0
 NBISOTC=0
fi
if [ -f ntpasswd.iso ];then
 echo "Offline NT Password and Registry Editor"
 NTISO=1
else
 NTISO=0
fi
if [ -f diskcopy.iso ];then
 echo "EASEUS Disk Copy"
 DCISO=1
else
 if [ -f DC2.iso ];then
  ln -s DC2.iso diskcopy.iso
  echo "EASEUS Disk Copy (note: made link from DC2.iso to diskcopy.iso)"
  DCISO=1
 else
  DCISO=0
 fi
fi
if [ -f clonezilla.iso ];then
 echo "Clonezilla"
 CISO=1
else
 CISO=0
fi
if [ -f ping.iso ];then
 echo "PING (Partimage Is Not Ghost)"
 PIISO=1
else
 PIISO=0
fi
if [ -f debian-mini.iso ];then
 echo "Debian netboot installer"
 DiISO=1
else
 DiISO=0
fi
if [ -f ubuntu-mini.iso ];then
 echo "Ubuntu netboot installer"
 UiISO=1
else
 UiISO=0
fi
if [ -f fedora-boot.iso ];then
 echo "Fedora netboot installer"
 FNISO=1
else
 FNISO=0
fi
if [ -f opensuse.iso ];then
 echo "openSUSE netboot installer"
 OISO=1
else
 OISO=0
fi
if [ -f mandriva-boot.iso ];then
 echo "Mandriva netboot installer"
 MiISO=1
else
 MiISO=0
fi
if [ -f arch.iso ];then
 echo "Arch Linux"
 ALISO=1
else
 ALISO=0
fi
if [ -f fdfullcd.iso ];then
 echo "FreeDOS 1.0"
 FDISO=1
 FDNAME=fdfullcd.iso
else
 if [ -f fdbasecd.iso ];then
  echo "FreeDOS 1.0"
  FDISO=1
  FDNAME=fdbasecd.iso
 else
  FDISO=0
 fi
fi
for i in $( ls -1 *.im[g,z] 2> /dev/null | grep -v balder10.imz ); do
 echo $(echo $i|sed 's/\.im.//')
done
GAMES=0 #Will be changed if there are games
for i in $( ls -1 games/*.im[g,z] 2> /dev/null ); do
 echo Game: $(echo $i|sed 's/\.im.//'|sed 's/games\///')
 GAMES=1
done
if [ -f grub.exe ];then
 echo "GRUB4DOS"
 G4D=1
else
 G4D=0
fi
if [ -f dban.iso ];then
 echo "DBAN"
 DbISO=1
else
 DbISO=0
fi
if [ $BALDER = 1 ];then
 echo "Balder (FreeDOS)"
fi
if [ $MEMTEST = 1 ];then
 echo "Memtest86+"
fi

if [ $DbISO = 1 ] && [ $UBISO = 1 ];then
 echo
 echo "Note: Ultimate Boot CD includes DBAN, so it is not necessary alone as well."
fi
if [ $NTISO = 1 ] && [ $UBISO = 1 ];then
 echo
 echo "Note: UBCD includs NT Password & Registry Editor, so it is not necessary alone as well."
fi
if [ $UISO = 1 ] && [ $LMISO = 1 ];then
 echo
 echo "Ubuntu and Linux mint both use casper. They can't be on the same CD without"
 echo "initrd modifications, which this script does not support."
 echo "Ignoring linuxmint.iso."
 LMISO=0
fi

echo
echo "Continuing in 3 seconds - press Ctrl+C to cancel"
sleep 3

if [ -d multicd-working ];then
 rm -r multicd-working/*
else
 mkdir multicd-working
fi

#Make sure it exists, you need to put stuff there later
mkdir -p multicd-working/boot/isolinux

if [ $UISO = 1 ];then
 echo "Copying Ubuntu..."
 if [ ! -d ubuntu ];then
  mkdir ubuntu
 fi
 if grep -q "`pwd`/ubuntu" /etc/mtab ; then
  umount ubuntu
 fi
 mount -o loop ubuntu.iso ubuntu/
 cp -R ubuntu/casper multicd-working/ #Live system
 cp -R ubuntu/dists multicd-working/ #Other packages contained on CD
 cp -R ubuntu/pool multicd-working/ #Other packages contained on CD
 cp -R ubuntu/preseed multicd-working/ #Tells the installer what to install
 cp -R ubuntu/README.diskdefines multicd-working/ #Goes along with dists and pool
 cp -R ubuntu/.disk multicd-working/ #A few more helper files
 ln -s . multicd-working/ubuntu #Because the original disc had it
 umount ubuntu
 rmdir ubuntu
fi

if [ $LMISO = 1 ];then
 echo "Copying Linux Mint..."
 if [ ! -d linuxmint ];then
  mkdir linuxmint
 fi
 if grep -q "`pwd`/linuxmint" /etc/mtab ; then
  umount linuxmint
 fi
 mount -o loop linuxmint.iso linuxmint/
 cp -R linuxmint/casper multicd-working/ #Live system
 cp -R linuxmint/drivers multicd-working/ #Drivers added by the Mint team
 cp -R linuxmint/preseed multicd-working/ #Tells the installer what to install
 cp -R linuxmint/.disk multicd-working/ #A few more helper files
 umount linuxmint
 rmdir linuxmint
fi

if [ $KISO = 1 ];then
 echo "Copying Knoppix..."
 if [ ! -d knoppix5 ];then
  mkdir knoppix5
 fi
 if grep -q "`pwd`/knoppix5" /etc/mtab ; then
  umount knoppix5
 fi
 mount -o loop knoppix5.iso knoppix5/
 mkdir multicd-working/KNOPPIX5
 #Compressed filesystem and docs. We have to call it KNOPPIX5 because DSL uses KNOPPIX, and if we change that DSL's installer won't work.
 for i in $(ls knoppix5/KNOPPIX*|grep -v '^KNOPPIX2$');do
 	cp -r knoppix5/KNOPPIX/$i multicd-working/KNOPPIX5/
 done
 mkdir -p multicd-working/boot/knoppix5
 cp knoppix5/boot/isolinux/linux multicd-working/boot/knoppix5/linux
 cp knoppix5/boot/isolinux/minirt.gz multicd-working/boot/knoppix5/minirt.gz
 umount knoppix5
 rmdir knoppix5
fi

if [ $DLISO = 1 ];then
 echo "Copying Debian Live..."
 if [ ! -d binary2 ];then
  mkdir binary2
 fi
 if grep -q "`pwd`/binary2" /etc/mtab ; then
  umount binary2
 fi
 mount -o loop binary.iso binary2/
 cp binary2/isolinux/menu.cfg /tmp/menu.cfg #Copy the menu so we can read it later
 cp -r binary2/$i multicd-working/ #Basically copy everything
 umount binary2
 rmdir binary2
 rm multicd-working/live/memtest #We don't need this now; we'll get it later
fi

if [ $UBISO = 1 ];then
 echo "Copying Ultimate Boot CD..."
 if [ ! -d ubcd ];then
  mkdir ubcd
 fi
 if grep -q "`pwd`/ubcd" /etc/mtab ; then
  umount ubcd
 fi
 mount -o loop ubcd.iso ubcd/
 cp -r ubcd/dosapps multicd-working/ # These three
 cp -r ubcd/images multicd-working/ # should be
 cp -r ubcd/menus multicd-working/ # self-explanitory.
 cp -r ubcd/boot/* multicd-working/boot/ #Some boot files needed for UBCD
 cp ubcd/isolinux/sbm.cbt multicd-working/boot/isolinux/sbm.cbt #Smart Boot Manager
 umount ubcd
 rmdir ubcd
fi

if [ $DISO = 1 ];then
 echo "Copying DSL..."
 if [ ! -d dsl ];then
  mkdir dsl
 fi
 if grep -q "`pwd`/dsl" /etc/mtab ; then
  umount dsl
 fi
 mount -o loop dsl.iso dsl/
 mkdir multicd-working/KNOPPIX
 cp -R dsl/KNOPPIX/* multicd-working/KNOPPIX/ #Compressed filesystem. We put it here so DSL's installer can find it.
 cp dsl/boot/isolinux/linux24 multicd-working/boot/isolinux/linux24 #Kernel. See above.
 cp dsl/boot/isolinux/minirt24.gz multicd-working/boot/isolinux/minirt24.gz #Initial ramdisk. See above.
 umount dsl
 rmdir dsl
fi

if [ $TCISO = 1 ];then
 echo "Copying Tiny Core..."
 if [ ! -d tinycore ];then
  mkdir tinycore
 fi
 if grep -q "`pwd`/tinycore" /etc/mtab ; then
  umount tinycore
 fi
 mount -o loop tinycore.iso tinycore/
 mkdir multicd-working/boot/tinycore
 cp tinycore/boot/bzImage multicd-working/boot/tinycore/bzImage #Linux kernel
 cp tinycore/boot/tinycore.gz multicd-working/boot/tinycore/tinycore.gz #Entire Tiny Core image is in this file
 umount tinycore
 rmdir tinycore
fi

if [ $TC2ISO = 1 ];then
 echo "Copying Tiny Core 2..."
 if [ ! -d tinycore2 ];then
  mkdir tinycore2
 fi
 if grep -q "`pwd`/tinycore2" /etc/mtab ; then
  umount tinycore2
 fi
 mount -o loop tinycore2.iso tinycore2/
 mkdir multicd-working/boot/tinycore2
 cp tinycore2/boot/bzImage multicd-working/boot/tinycore2/bzImage #Linux kernel
 cp tinycore2/boot/tinycore.gz multicd-working/boot/tinycore2/tinycore.gz #Entire Tiny Core image is in this file
 umount tinycore2
 rmdir tinycore2
fi

if [ $PISO = 1 ];then
 echo "Copying Puppy..."
 if [ ! -d puppy ];then
  mkdir puppy
 fi
 if grep -q "`pwd`/puppy" /etc/mtab ; then
  umount puppy
 fi
 mount -o loop puppy.iso puppy/
 #Puppy files must be in the same place as on the original CD;
 #the installer would not work otherwise
 cp puppy/*.sfs multicd-working/
 cp puppy/vmlinuz multicd-working/vmlinuz
 cp puppy/initrd.gz multicd-working/initrd.gz
 umount puppy
 rmdir puppy
fi

if [ $FISO = 1 ];then
 echo "Copying Feather Linux..."
 if [ ! -d feather ];then
  mkdir feather
 fi
 if grep -q "`pwd`/feather" /etc/mtab ; then
  umount feather
 fi
 mount -o loop feather.iso feather/
 mkdir multicd-working/FEATHER
 cp -R feather/KNOPPIX/* multicd-working/FEATHER/ #Compressed filesystem
 mkdir multicd-working/boot/feather
 cp feather/boot/isolinux/linux24 multicd-working/boot/feather/linux24
 cp feather/boot/isolinux/minirt24.gz multicd-working/boot/feather/minirt24.gz
 umount feather
 rmdir feather
fi

if [ $STISO = 1 ];then
 echo "Copying SliTaz..."
 if [ ! -d slitaz ];then
  mkdir slitaz
 fi
 if grep -q "`pwd`/slitaz" /etc/mtab ; then
  umount slitaz
 fi
 mount -o loop slitaz.iso slitaz/
 mkdir -p multicd-working/boot/slitaz
 cp slitaz/boot/bzImage multicd-working/boot/slitaz/bzImage #Kernel
 cp slitaz/boot/rootfs.gz multicd-working/boot/slitaz/rootfs.gz #Root filesystem
 umount slitaz
 rmdir slitaz
fi

if [ $AUISO = 1 ];then
 echo "Copying Austrumi..."
 if [ -d austrumi ];then
  true
 else
  mkdir austrumi
 fi
 if grep -q "`pwd`/austrumi" /etc/mtab ; then
  umount austrumi
 fi
 mount -o loop al.iso austrumi/
 cp -r austrumi/austrumi multicd-working/ #This folder also has the kernel and initrd
 cp austrumi/boot/austrumi.fs multicd-working/boot/austrumi.fs
 cp austrumi/boot/austrumi.tgz multicd-working/boot/austrumi.tgz
 umount austrumi
 rmdir austrumi
fi

if [ $GBOXISO = 1 ];then
 echo "Copying GeeXboX..."
 if [ -d geexbox ];then
  true
 else
  mkdir geexbox
 fi
 if grep -q "`pwd`/geexbox" /etc/mtab ; then
  umount geexbox
 fi
 mount -o loop gbox.iso geexbox/
 cp -r geexbox/GEEXBOX multicd-working/ #Everything GeeXbox has is in one folder. :)
 umount geexbox
 rmdir geexbox
fi

if [ $SISO = 1 ];then
 echo "Copying Slax..."
 if [ ! -d slax ];then
  mkdir slax
 fi
 if grep -q "`pwd`/slax" /etc/mtab ; then
  umount slax
 fi
 mount -o loop slax.iso slax/
 if [ $MODULES = 1 ];then
 	mkdir multicd-working/slax
 	for i in `ls slax/slax|sed -e '/^base$/ d'`;do
 		cp -R slax/slax/$i multicd-working/slax/ #Copy everything but the base modules
 	done
 	mkdir multicd-working/slax/base
 	for i in `cat ./slaxlist`;do
 		cp slax/slax/base/$i multicd-working/slax/base/ #Copy only the modules you wanted
 	done
 	cp slax/slax/base/001-*.lzm multicd-working/slax/base/ #Don't forget the core module!
 	rm ./slaxlist
 else
 	cp -R slax/slax multicd-working/ #Copy everything
 fi
 mkdir -p multicd-working/boot/slax
 cp slax/boot/vmlinuz multicd-working/boot/slax/vmlinuz
 cp slax/boot/initrd.gz multicd-working/boot/slax/initrd.gz
 umount slax
 rmdir slax
fi

if [ "`ls -1 *.lzm 2> /dev/null;true`" != "" ] && [ $SISO = 1 ]; then echo "Copying Slax modules..."; fi

if [ $SISO = 1 ];then
 for i in `ls -1 *.lzm 2> /dev/null;true`; do
  cp $i multicd-working/slax/modules/ #Copy the .lzm module to the modules folder
  if [ $VERBOSE = 1 ];then
   echo \(Copied $i\)
  fi
 done
fi

if [ $DELISO = 1 ];then
 echo "Copying DeLi Linux..."
 if [ -d deli ];then
  true
 else
  mkdir deli
 fi
 if grep -q "`pwd`/deli" /etc/mtab ; then
  umount deli
 fi
 mount -o loop deli.iso deli/
 cp -r deli/isolinux multicd-working/ #Kernel and filesystem
 cp -r deli/pkg multicd-working/ #Packages
 umount deli
 rmdir deli
fi

if [ $TISO = 1 ];then
 echo "Copying TinyMe..."
 if [ ! -d tinyme ];then
  mkdir tinyme
 fi
 if grep -q "`pwd`/tinyme" /etc/mtab ; then
  umount tinyme
 fi
 mount -o loop tinyme.iso tinyme/
 cp tinyme/livecd.sqfs multicd-working/livecd.sqfs #Compressed filesystem
 mkdir -p multicd-working/boot/tinyme
 cp tinyme/isolinux/vmlinuz multicd-working/boot/tinyme/vmlinuz
 cp tinyme/isolinux/initrd.gz multicd-working/boot/tinyme/initrd.gz
 umount tinyme
 rmdir tinyme
fi

if [ $AISO = 1 ];then
 echo "Copying antiX..."
 if [ ! -d antix ];then
  mkdir antix
 fi
 if grep -q "`pwd`/antix" /etc/mtab ; then
  umount antix
 fi
 mount -o loop antix.iso antix/
 cp -r antix/mepis multicd-working/ #Everything in antiX but the kernel and initrd
 mkdir -p multicd-working/boot/antix
 cp antix/boot/vmlinuz multicd-working/boot/antix/vmlinuz #Kernel
 cp antix/boot/initrd.gz multicd-working/boot/antix/initrd.gz #Initrd
 umount antix
 rmdir antix
fi

if [ $WISO = 1 ];then
 echo "Copying Wolvix..."
 if [ ! -d wolvix ];then
  mkdir wolvix
 fi
 if grep -q "`pwd`/wolvix" /etc/mtab ; then
  umount wolvix
 fi
 mount -o loop wolvix.iso wolvix/
 cp -r wolvix/wolvix multicd-working/ #The Wolvix folder with all its files
 mkdir -p multicd-working/boot/wolvix
 #The kernel/initrd must be here for the installer
 cp wolvix/boot/vmlinuz multicd-working/boot/vmlinuz
 cp wolvix/boot/initrd.gz multicd-working/boot/initrd.gz
 umount wolvix
 rmdir wolvix
fi

if [ $RIPISO = 1 ];then
 echo "Copying RIPLinuX..."
 if [ ! -d riplinux ];then
  mkdir riplinux
 fi
 if grep -q "`pwd`/riplinux" /etc/mtab ; then
  umount riplinux
 fi
 mount -o loop riplinux.iso riplinux/
 mkdir -p multicd-working/boot/riplinux
 cp -r riplinux/boot/doc multicd-working/boot/ #Documentation
 cp -r riplinux/boot/grub4dos multicd-working/boot/riplinux/ #GRUB4DOS :)
 cp riplinux/boot/kernel multicd-working/boot/riplinux/kernel #32-bit kernel
 cp riplinux/boot/kernel64 multicd-working/boot/riplinux/kernel64 #64-bit kernel
 cp riplinux/boot/rootfs.cgz multicd-working/boot/riplinux/rootfs.cgz #Initrd
 perl -pi -e 's/\/boot\/kernel/\/boot\/riplinux\/kernel/g' multicd-working/boot/riplinux/grub4dos/menu.lst #Fix the menu.lst
 perl -pi -e 's/\/boot\/rootfs.cgz/\/boot\/riplinux\/rootfs.cgz/g' multicd-working/boot/riplinux/grub4dos/menu.lst #Fix it some more
 umount riplinux
 rmdir riplinux
fi

if [ $SRISO = 1 ];then
 echo "Copying SystemRescueCd..."
 if [ ! -d sysrcd ];then
  mkdir sysrcd
 fi
 if grep -q "`pwd`/sysrcd" /etc/mtab ; then
  umount sysrcd
 fi
 mount -o loop sysrcd.iso sysrcd/
 cp sysrcd/sysrcd.* multicd-working/ #Compressed filesystem
 mkdir multicd-working/boot/sysrcd
 cp sysrcd/isolinux/altker* multicd-working/boot/sysrcd/ #Kernels
 cp sysrcd/isolinux/rescue* multicd-working/boot/sysrcd/ #Kernels
 cp sysrcd/isolinux/initram.igz multicd-working/boot/sysrcd/initram.igz #Initrd
 umount sysrcd
 rmdir sysrcd
fi

if [ $TRISO = 1 ];then
 echo "Copying Trinity Rescue Kit..."
 if [ ! -d trinity ];then
  mkdir trinity
 fi
 if grep -q "`pwd`/trinity" /etc/mtab ; then
  umount trinity
 fi
 mount -o loop trk.iso trinity/
 cp -r trinity/trk3 multicd-working/ #TRK files
 mkdir multicd-working/boot/trinity
 cp trinity/kernel.trk multicd-working/boot/trinity/kernel.trk
 cp trinity/initrd.trk multicd-working/boot/trinity/initrd.trk
 cp trinity/bootlogo.jpg multicd-working/boot/isolinux/trklogo.jpg #Boot logo
 umount trinity
 rmdir trinity
fi

if [ $IISO = 1 ];then
 echo "Copying INSERT..."
 if [ ! -d insert ];then
  mkdir insert
 fi
 if grep -q "`pwd`/insert" /etc/mtab ; then
  umount insert
 fi
 mount -o loop insert.iso insert/
 cp -R insert/INSERT multicd-working/ #Compressed filesystem
 mkdir multicd-working/boot/insert
 cp insert/isolinux/vmlinuz multicd-working/boot/insert/vmlinuz
 cp insert/isolinux/miniroot.lz multicd-working/boot/insert/miniroot.lz
 umount insert
 rmdir insert
fi

if [ $PMISO = 1 ];then
 echo "Copying Parted Magic..."
 if [ ! -d pmagic ];then
  mkdir pmagic
 fi
 if grep -q "`pwd`/pmagic" /etc/mtab ; then
  umount pmagic
 fi
 mount -o loop pmagic.iso pmagic/
 #Sudo is needed b/c of weird permissions on 4.7 ISO for the initrd
 sudo cp -r pmagic/pmagic multicd-working/ #Compressed filesystem and kernel/initrd
 umount pmagic
 rmdir pmagic
fi

if [ $GISO = 1 ];then
 echo "Copying GParted Live..."
 if [ ! -d gparted ];then
  mkdir gparted
 fi
 if grep -q "`pwd`/gparted" /etc/mtab ; then
  umount gparted
 fi
 mount -o loop gparted.iso gparted/
 cp -R gparted/live multicd-working/boot/gparted #Compressed filesystem and kernel/initrd
 rm multicd-working/boot/gparted/memtest #Remember how we needed to do this with Debian Live? They use the same framework
 umount gparted
 rmdir gparted
fi

if [ $NBISO = 1 ];then
 echo "Copying NetbootCD..."
 if [ ! -d netbootcd ];then
  mkdir netbootcd
 fi
 if grep -q "`pwd`/netbootcd" /etc/mtab ; then
  umount netbootcd
 fi
 mount -o loop netbootcd.iso netbootcd/
 if [ -d netbootcd/slax ];then
  #Code for NetbootCD 2.x
  if [ $SISO = 1 ];then
   cp netbootcd/slax/modules/* multicd-working/slax/modules #NetbootCD-specific modules
   cp netbootcd/slax/optional/* multicd-working/slax/optional #NetbootCD-specific modules
   rm multicd-working/slax/base/001-core.lzm #NetbootCD has its own version in the modules folder
  else
   cp -R netbootcd/slax multicd-working/ #Copy it all, because there is no Slax on the CD
  fi
  mkdir -p multicd-working/boot/slax
  #The next 2 lines overwrite the Slax kernel; this is intentional. NBCD's kernel has kexec support.
  cp netbootcd/boot/vmlinuz multicd-working/boot/slax/vmlinuz
  cp netbootcd/boot/initrd.gz multicd-working/boot/slax/initrd.gz
  NBISOSLAX=1
  NBISOTC=0
 else
  #Code for NetbootCD 3.x
  mkdir -p multicd-working/boot/nbcd
  cp netbootcd/isolinux/kexec.bzI multicd-working/boot/nbcd/kexec.bzI #Just like Tiny Core kernel, but with support for kexec system call
  cp netbootcd/isolinux/nbinit3.gz multicd-working/boot/nbcd/nbinit3.gz #Slimmed down - no X11, FLTK, etc. Contains netbootcd data.
  NBISOTC=1
  NBISOSLAX=0
 fi
 umount netbootcd
 rmdir netbootcd
fi

if [ $NTISO = 1 ];then
 echo "Copying NT Password/Registry Editor..."
 if [ ! -d ntpasswd ];then
  mkdir ntpasswd
 fi
 if grep -q "`pwd`/ntpasswd" /etc/mtab ; then
  umount ntpasswd
 fi
 mount -o loop ntpasswd.iso ntpasswd/
 mkdir multicd-working/boot/ntpasswd
 cp ntpasswd/vmlinuz multicd-working/boot/ntpasswd/vmlinuz
 cp ntpasswd/initrd.cgz multicd-working/boot/ntpasswd/initrd.cgz
 cp ntpasswd/scsi.cgz multicd-working/boot/ntpasswd/scsi.cgz #Alternate initrd
 umount ntpasswd
 rmdir ntpasswd
fi

if [ $DCISO = 1 ];then
 echo "Copying EASEUS Disk Copy..."
 if [ ! -d diskcopy ];then
  mkdir diskcopy
 fi
 if grep -q "`pwd`/diskcopy" /etc/mtab ; then
  umount diskcopy
 fi
 mount -o loop diskcopy.iso diskcopy/
 mkdir -p multicd-working/boot/diskcopy
 cp diskcopy/boot/bzImage multicd-working/boot/diskcopy/bzImage
 cp diskcopy/boot/initrd.img multicd-working/boot/diskcopy/initrd.img
 umount diskcopy
 rmdir diskcopy
fi

if [ $CISO = 1 ];then
 echo "Copying Clonezilla..."
 if [ ! -d clonezilla ];then
  mkdir clonezilla
 fi
 if grep -q "`pwd`/clonezilla" /etc/mtab ; then
  umount clonezilla
 fi
 mount -o loop clonezilla.iso clonezilla/
 cp clonezilla/isolinux/ocswp.png multicd-working/boot/isolinux/ocswp.png #Boot menu logo
 cp -R clonezilla/live multicd-working/boot/clonezilla #Another Debian Live-based ISO
 umount clonezilla
 rmdir clonezilla
 rm multicd-working/boot/clonezilla/memtest multicd-working/boot/clonezilla/freedos.img #This is Balder which we will download later
fi

if [ $PIISO = 1 ];then
 echo "Copying PING..."
 if [ ! -d ping ];then
  mkdir ping
 fi
 if grep -q "`pwd`/ping" /etc/mtab ; then
  umount ping
 fi
 mount -o loop ping.iso ping/
 mkdir -p multicd-working/boot/ping
 cp ping/kernel multicd-working/boot/ping/kernel
 cp ping/initrd.gz multicd-working/boot/ping/initrd.gz
 umount ping
 rmdir ping
fi

if [ $DiISO = 1 ];then
 echo "Copying Debian netboot installer..."
 if [ ! -d debian-mini ];then
  mkdir debian-mini
 fi
 if grep -q "`pwd`/debian-mini" /etc/mtab ; then
  umount debian-mini
 fi
 mount -o loop debian-mini.iso debian-mini/
 mkdir multicd-working/boot/debian
 cp debian-mini/linux multicd-working/boot/debian/linux
 cp debian-mini/initrd.gz multicd-working/boot/debian/initrd.gz
 umount debian-mini
 rmdir debian-mini
fi

if [ $UiISO = 1 ];then
 echo "Copying Ubuntu netboot installer..."
 if [ ! -d ubuntu-mini ];then
  mkdir ubuntu-mini
 fi
 if grep -q "`pwd`/ubuntu-mini" /etc/mtab ; then
  umount ubuntu-mini
 fi
 mount -o loop ubuntu-mini.iso ubuntu-mini/
 mkdir multicd-working/boot/ubuntu
 cp ubuntu-mini/linux multicd-working/boot/ubuntu/linux
 cp ubuntu-mini/initrd.gz multicd-working/boot/ubuntu/initrd.gz
 umount ubuntu-mini
 rmdir ubuntu-mini
fi

if [ $FNISO = 1 ];then
 echo "Copying Fedora netboot installer..."
 if [ ! -d fedora-boot ];then
  mkdir fedora-boot
 fi
 if grep -q "`pwd`/fedora-boot" /etc/mtab ; then
  umount fedora-boot
 fi
 mount -o loop fedora-boot.iso fedora-boot/
 mkdir multicd-working/boot/fedora
 cp fedora-boot/isolinux/vmlinuz multicd-working/boot/fedora/vmlinuz
 cp fedora-boot/isolinux/initrd.img multicd-working/boot/fedora/initrd.img
 #Commenting out the below line will save about 100MB on the CD, but it will have to be downloaded when you install Fedora
 cp -R fedora-boot/images multicd-working/
 umount fedora-boot
 rmdir fedora-boot
fi

if [ $OISO = 1 ];then
 echo "Copying openSUSE netboot installer..."
 if [ ! -d opensuse ];then
  mkdir opensuse
 fi
 if grep -q "`pwd`/opensuse" /etc/mtab ; then
  umount opensuse
 fi
 mount -o loop opensuse.iso opensuse/
 mkdir multicd-working/boot/opensuse
 OPENSUSEVERSION=`awk '/^VERSION/ {print $2}' opensuse/content`
 cp opensuse/boot/i386/loader/linux multicd-working/boot/opensuse/linux
 cp opensuse/boot/i386/loader/initrd multicd-working/boot/opensuse/initrd
 umount opensuse
 rmdir opensuse
fi

if [ $MiISO = 1 ];then
 echo "Copying Mandriva netboot installer..."
 if [ ! -d mandriva-boot ];then
  mkdir mandriva-boot
 fi
 if grep -q "`pwd`/mandriva-boot" /etc/mtab ; then
  umount mandriva-boot
 fi
 mount -o loop mandriva-boot.iso mandriva-boot/
 mkdir multicd-working/boot/mandriva
 cp -r mandriva-boot/isolinux/alt0 multicd-working/boot/mandriva/
 cp -r mandriva-boot/isolinux/alt1 multicd-working/boot/mandriva/
 umount mandriva-boot
 rmdir mandriva-boot
fi

if [ $ALISO = 1 ];then
 echo "Copying Arch Linux..."
 if [ ! -d arch ];then
  mkdir arch
 fi
 if grep -q "`pwd`/arch" /etc/mtab ; then
  umount arch
 fi
 mount -o loop arch.iso arch/
 mkdir multicd-working/boot/arch
 cp arch/boot/vmlinuz26 multicd-working/boot/arch/vmlinuz26 #Kernel
 cp arch/boot/archiso_pata.img multicd-working/boot/arch/archiso_pata.img #initrd
 cp arch/boot/archiso_ide.img multicd-working/boot/arch/archiso_ide.img #Another initrd
 cp arch/*.sqfs multicd-working/ #Compressed filesystems
 cp arch/isomounts multicd-working/ #Text file
 #cp -r arch/addons multicd-working/ #Arch addons
 umount arch
 rmdir arch
fi

if [ $FDISO = 1 ];then
 echo "Copying FreeDOS..."
 if [ ! -d freedos ];then
  mkdir freedos
 fi
 if grep -q "`pwd`/freedos" /etc/mtab ; then
  umount freedos
 fi
 mount -o loop $FDNAME freedos/ #It might be fdbasecd or fdfullcd
 mkdir multicd-working/boot/freedos
 cp -r freedos/freedos multicd-working/ #Core directory with the packages
 cp freedos/setup.bat multicd-working/setup.bat #FreeDOS setup
 cp freedos/isolinux/data/fdboot.img multicd-working/boot/freedos/fdboot.img #Initial DOS boot image
 if [ -d freedos/fdos ];then
  cp -r freedos/fdos multicd-working/ #Live CD
 fi
 if [ -d freedos/gemapps ];then
  cp -r freedos/gemapps multicd-working/ #OpenGEM
 fi
 if [ -f freedos/gem.bat ];then
  cp -r freedos/gem.bat multicd-working/ #OpenGEM setup
 fi
 umount freedos
 rmdir freedos
fi

#The below chunk copies floppy images.
j="0"
for i in $( ls -1 *.im[g,z] 2> /dev/null | grep -v balder10.imz ); do
	echo -n Copying $(echo $i|sed 's/\.im.//')"... "
	cp $i multicd-working/boot/$j.img
	if [ $VERBOSE = 1 ];then
		echo "Saved as "$j".img."
	else
		echo
	fi
	j=$( expr $j + 1 )
done

#This chunk copies floppy images in the "games" folder. They will have their own submenu.
if [ $GAMES = 1 ];then
	k="0"
	mkdir -p multicd-working/boot/games
	for i in $( ls -1 games/*.im[g,z] 2> /dev/null ); do
		echo -n Copying $(echo $i|sed 's/\.im.//'|sed 's/games\///')"... "
		cp $i multicd-working/boot/games/$k.img
		if [ $VERBOSE = 1 ];then
			echo "Saved as games/"$k".img."
		else
			echo
		fi
		k=$( expr $k + 1 )
	done
fi

if [ $G4D = 1 ];then
 echo "Copying GRUB4DOS..."
 cp grub.exe multicd-working/boot/grub.exe #Easy!
fi

if [ $DbISO = 1 ];then
 echo "Copying DBAN..."
 if [ ! -d dban ];then
  mkdir dban
 fi
 if grep -q "`pwd`/dban" /etc/mtab ; then
  umount dban
 fi
 mount -o loop dban.iso dban/
 cp dban/dban*.ima /tmp/dban.ima #Get the floppy image from inside the CD image
 umount dban
 mount -o loop /tmp/dban.ima dban #Then mount that floppy image
 mkdir -p multicd-working/boot/dban1
 cp dban/kernel.bzi multicd-working/boot/dban1/kernel.bzi
 cp dban/initrd.gz multicd-working/boot/dban1/initrd.gz
 umount dban
 rmdir dban
fi

echo "Downloading SYSLINUX..."
if [ $VERBOSE != 0 ];then
 wget -O /tmp/syslinux.tar.gz ftp://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-*.tar.gz
else
 wget -qO /tmp/syslinux.tar.gz ftp://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-*.tar.gz
fi
if [ $? = 0 ];then
 echo "Unpacking and copying files..."
 tar -C /tmp -xzf /tmp/syslinux.tar.gz
 cp /tmp/syslinux-*/core/isolinux.bin multicd-working/boot/isolinux/
 cp /tmp/syslinux-*/memdisk/memdisk multicd-working/boot/isolinux/
 cp /tmp/syslinux-*/com32/menu/menu.c32 multicd-working/boot/isolinux/
 cp /tmp/syslinux-*/com32/menu/vesamenu.c32 multicd-working/boot/isolinux/
 cp /tmp/syslinux-*/com32/modules/chain.c32 multicd-working/boot/isolinux/
 rm -r /tmp/syslinux-*/ /tmp/syslinux.tar.gz
else
 echo "Downloading of SYSLINUX failed."
 exit 1
fi

if [ $MEMTEST = 1 ];then
 if [ -f memtest ];then
  cp memtest multicd-working/boot/memtest
 else
  echo "Downloading memtest86+ 2.11 from memtest.org..."
  if [ $VERBOSE != 0 ];then
   wget -O- http://www.memtest.org/download/2.11/memtest86+-2.11.bin.gz|gzip -cd>multicd-working/boot/memtest
  else
   wget -qO- http://www.memtest.org/download/2.11/memtest86+-2.11.bin.gz|gzip -cd>multicd-working/boot/memtest
  fi
 fi
fi

if [ $BALDER = 1 ];then
 if [ -f balder10.imz ];then
  cp balder10.imz multicd-working/boot/balder.imz
 else
  echo "Downloading Balder from finnix.org..."
  if [ $VERBOSE != 0 ];then
   wget -O multicd-working/boot/balder.imz http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/unofficial/balder/balder10.imz
  else
   wget -qO multicd-working/boot/balder.imz http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/unofficial/balder/balder10.imz
  fi
 fi
fi

echo "Writing isolinux.cfg..."

##BEGIN ISOLINUX MENU CODE##
#The ISOLINUX menu can be rearranged by moving blocks of this code around.
#Some boot options may be commented out. These are more rarely used; however, you may uncomment them in this script and they will be available on the final CD.

#BEGIN HEADER#
#Don't move this part. You can change the timeout and menu title, however.
cat > multicd-working/boot/isolinux/isolinux.cfg << "EOF"
DEFAULT menu.c32
TIMEOUT 0
PROMPT 0
menu title Welcome to GNU/Linux!
EOF
#END HEADER#

#BEGIN HD BOOT OPTION#
#If this bugs you, get rid of it.
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label local
menu label Boot from ^hard drive
kernel chain.c32
append hd0
EOF
#END HD BOOT OPTION#

#BEGIN UBUNTU ENTRY#
if [ $UISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label ubuntu-live
  menu label ^Try Ubuntu without any change to your computer
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash --
label ubuntu-live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.gz quiet splash --
EOF
fi
#END UBUNTU ENTRY#

#BEGIN LINUX MINT ENTRY#
if [ $LMISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label mint-live
  menu label ^Try Linux Mint without any change to your computer
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/mint.seed boot=casper initrd=/casper/initrd.gz quiet splash --
label mint-live-install
  menu label ^Install Linux Mint
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/mint.seed boot=casper only-ubiquity initrd=/casper/initrd.gz quiet splash --
EOF
fi
#END LINUX MINT ENTRY#

#BEGIN KNOPPIX 5 ENTRY#
if [ $KISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL knoppix5
MENU LABEL Knoppix 5
KERNEL /boot/knoppix5/linux
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/knoppix5/minirt.gz knoppix_dir=KNOPPIX5 nomce highres=off loglevel=0 libata.atapi_enabled=1 quiet SELINUX_INIT=NO nmi_watchdog=0 BOOT_IMAGE=knoppix

LABEL adriane5
MENU LABEL Adriane (Knoppix 5)
KERNEL /boot/knoppix5/linux
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=785 initrd=/boot/knoppix5/minirt.gz knoppix_dir=KNOPPIX5 nomce highres=off loglevel=0 libata.atapi_enabled=1 quiet SELINUX_INIT=NO nmi_watchdog=0 BOOT_IMAGE=adriane

LABEL knoppix5-2
MENU LABEL Knoppix 5 (boot to command line)
KERNEL /boot/knoppix5/linux
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/knoppix5/minirt.gz knoppix_dir=KNOPPIX5 nomce highres=off loglevel=0 libata.atapi_enabled=1 quiet SELINUX_INIT=NO nmi_watchdog=0 BOOT_IMAGE=knoppix 2
EOF
fi
#END KNOPPIX 5 ENTRY#

#BEGIN DEBIAN LIVE ENTRY#
if [ $DLISO = 1 ];then
cat /tmp/menu.cfg|grep -v memtest|grep -v "Memory test">>multicd-working/boot/isolinux/isolinux.cfg
rm /tmp/menu.cfg
fi
#END DEBIAN LIVE ENTRY#

#BEGIN ULTIMATE BOOT CD ENTRY#
if [ $UBISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label ubcd
menu label ^Ultimate Boot CD - Main menu
com32 menu.c32
append /menus/main.cfg
EOF
fi
#END ULTIMATE BOOT CD ENTRY#

#BEGIN DSL ENTRY#
if [ $DISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL dsl
MENU LABEL ^DSL
KERNEL /boot/isolinux/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/isolinux/minirt24.gz nomce noapic quiet BOOT_IMAGE=knoppix

LABEL dsl-toram
MENU LABEL DSL (load to RAM)
KERNEL /boot/isolinux/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/isolinux/minirt24.gz nomce noapic quiet toram BOOT_IMAGE=knoppix

LABEL dsl-2
MENU LABEL DSL (boot to command line)
KERNEL /boot/isolinux/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/isolinux/minirt24.gz nomce noapic quiet 2 BOOT_IMAGE=knoppix

#LABEL dsl-expert
#MENU LABEL DSL (expert mode)
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/isolinux/minirt24.gz nomce BOOT_IMAGE=expert

#LABEL dsl-fb1280x1024
#MENU LABEL DSL (1280x1024 framebuffer)
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=794 xmodule=fbdev initrd=/boot/isolinux/minirt24.gz nomce noapic quiet BOOT_IMAGE=knoppix

#LABEL dsl-fb1024x768
#MENU LABEL DSL (1024x768 framebuffer)
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 xmodule=fbdev initrd=/boot/isolinux/minirt24.gz nomce noapic quiet BOOT_IMAGE=knoppix

#LABEL dsl-fb800x600
#MENU LABEL DSL (800x600 framebuffer)
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=788 xmodule=fbdev initrd=/boot/isolinux/minirt24.gz nomce noapic quiet BOOT_IMAGE=knoppix

#LABEL dsl-lowram
#MENU LABEL DSL (for low RAM)
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=normal initrd=/boot/isolinux/minirt24.gz noscsi noideraid nosound nousb nofirewire noicons minimal nomce noapic noapm lowram quiet BOOT_IMAGE=knoppix

#LABEL dsl-install
#MENU LABEL Install DSL
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=normal initrd=/boot/isolinux/minirt24.gz noscsi noideraid nosound nofirewire legacy base norestore _install_ nomce noapic noapm quiet BOOT_IMAGE=knoppix

#LABEL dsl-failsafe
#MENU LABEL DSL (failsafe)
#KERNEL /boot/isolinux/linux24
#APPEND ramdisk_size=100000 init=/etc/init 2 lang=us vga=normal atapicd nosound noscsi nousb nopcmcia nofirewire noagp nomce nodhcp xmodule=vesa initrd=/boot/isolinux/minirt24.gz BOOT_IMAGE=knoppix base norestore legacy
EOF
fi
#END DSL ENTRY#

#BEGIN TINY CORE ENTRY#
if [ $TCISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label tinycore
menu label ^Tiny Core Linux
kernel /boot/tinycore/bzImage
append quiet initrd=/boot/tinycore/tinycore.gz
EOF
fi
if [ $TC2ISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label tinycore2
menu label ^Tiny Core Linux 2
kernel /boot/tinycore2/bzImage
append quiet initrd=/boot/tinycore2/tinycore.gz
EOF
fi
#END TINY CORE ENTRY#

#BEGIN PUPPY ENTRY#
if [ $PISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label puppy
menu label ^Puppy Linux
kernel /vmlinuz
append initrd=/initrd.gz pmedia=cd
#label puppy-nox
#menu label Puppy Linux (boot to command line)
#kernel /vmlinuz
#append initrd=/initrd.gz pmedia=cd pfix=nox
label puppy-noram
menu label Puppy Linux (don't load to RAM)
kernel /vmlinuz
append initrd=/initrd.gz pmedia=cd pfix=noram
EOF
fi
#END PUPPY ENTRY#

#BEGIN FEATHER ENTRY#
if [ $FISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL feather
MENU LABEL ^Feather Linux
KERNEL /boot/dsl/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/dsl/minirt24.gz knoppix_dir=FEATHER nomce quiet BOOT_IMAGE=knoppix
LABEL feather-toram
MENU LABEL Feather Linux (load to RAM)
KERNEL /boot/dsl/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/dsl/minirt24.gz knoppix_dir=FEATHER nomce quiet toram BOOT_IMAGE=knoppix
LABEL feather-2
MENU LABEL Feather Linux (boot to command line)
KERNEL /boot/dsl/linux24
APPEND ramdisk_size=100000 init=/etc/init lang=us apm=power-off vga=791 initrd=/boot/dsl/minirt24.gz knoppix_dir=FEATHER nomce quiet 2 BOOT_IMAGE=knoppix
EOF
fi
#END FEATHER ENTRY#

#BEGIN SLITAZ ENTRY#
if [ $STISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label slitaz
	menu label ^SliTaz GNU/Linux
	kernel /boot/slitaz/bzImage
	append initrd=/boot/slitaz/rootfs.gz rw root=/dev/null vga=normal
EOF
fi
#END SLITAZ ENTRY#

#BEGIN AUSTRUMI ENTRY#
if [ $AUISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label austrumilinux
	menu label ^Austrumi
	com32 vesamenu.c32
	append al.menu
EOF
cat > multicd-working/boot/isolinux/al.menu << "EOF"
DEFAULT /austrumi/vesamenu.c32
F1 /austrumi/message.msg
PROMPT 0
TIMEOUT 100
ONTIMEOUT austrumi
MENU TABMSG  AUSTRUMI
MENU AUTOBOOT Automatic boot in # second{,s}...
MENU BACKGROUND /austrumi/logo
MENU TITLE (F1 for more options)
MENU color title	1;36;44    #ffffffff #00000000 std
MENU color sel		7;37;40    #ffffffff #ffdaa520 all
MENU color hotsel	1;7;37;40  #ffffffff #ffdaa520 all

MENU WIDTH 70
MENU MARGIN 10
MENU PASSWORDMARGIN 3
MENU ROWS 10
MENU TABMSGROW 15
MENU CMDLINEROW 15
MENU ENDROW -1
MENU PASSWORDROW 11
MENU TIMEOUTROW 17
MENU HELPMSGROW 21
MENU HELPMSGENDROW -1
MENU HIDDENROW -2
MENU HSHIFT 12
MENU VSHIFT 6

LABEL austrumi
MENU LABEL ^1. Run from RAM / Eject CD
TEXT HELP
* Copyright (c) 2004-2009 Andrejs Meinerts
* http://cyti.latgola.lv/ruuni
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd

LABEL nocache
MENU LABEL ^2. Do not eject CD.
TEXT HELP
 Do not attempt to cache CD
 Run this if RAM is 128Mb or less.
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd nocache

LABEL emb_user
MENU LABEL ^3. Embedix User
TEXT HELP
 Login as Embedded User
 user:austrumi  pass:austrumi
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd emb_user

LABEL text
MENU LABEL ^4. Run text mode
TEXT HELP
 Run text mode, Xserver do not started.
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd text

LABEL lang_el
MENU LABEL ^5. Greek
TEXT HELP
  System locale set to Greek
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd lang_el

LABEL lang_en
MENU LABEL ^6. English
TEXT HELP
  System locale set to English
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd lang_en

LABEL lang_it
MENU LABEL ^7. Italian
TEXT HELP
  System locale set to Italian
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd lang_it

LABEL lang_lv
MENU LABEL ^8. Latvian
TEXT HELP
  System locale set to Latvian
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd lang_lv

LABEL lang_ru
MENU LABEL ^9. Russian
TEXT HELP
  System locale set to Russian
ENDTEXT
KERNEL /austrumi/bzImage
APPEND initrd=/austrumi/initrd.gz dolivecd lang_ru
EOF
fi
#END AUSTRUMI ENTRY#

#BEGIN GEEXBOX ENTRY#
if [ $GBOXISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label gbox
	menu label ^GeeXboX
	com32 vesamenu.c32
	append gbox.menu
EOF
cat > multicd-working/boot/isolinux/gbox.menu << "EOF"
PROMPT 0

TIMEOUT 20

MENU BACKGROUND /GEEXBOX/boot/splash.png
MENU TITLE Welcome to GeeXboX i386 (C) 2002-2009
MENU VSHIFT 11
MENU ROWS 6
MENU TABMSGROW 15
MENU CMDLINEROW 14
MENU HELPMSGROW 16
MENU TABMSG Press [Tab] to edit options, [F1] for boot options.
MENU COLOR sel 7;37;40 #e0000000 #fa833b all
MENU COLOR border 30;44 #00000000 #00000000 none

LABEL geexbox
  MENU LABEL Start GeeXboX ...
  KERNEL /GEEXBOX/boot/vmlinuz
  APPEND initrd=/GEEXBOX/boot/initrd.gz root=/dev/ram0 rw rdinit=linuxrc boot=cdrom lang=en remote=atiusb receiver=atiusb keymap=qwerty splash=silent vga=789 video=vesafb:ywrap,mtrr quiet

LABEL hdtv
  MENU DEFAULT
  MENU LABEL Start GeeXboX for HDTV ...
  KERNEL /GEEXBOX/boot/vmlinuz
  APPEND initrd=/GEEXBOX/boot/initrd.gz root=/dev/ram0 rw rdinit=linuxrc boot=cdrom lang=en remote=atiusb receiver=atiusb keymap=qwerty splash=silent vga=789 video=vesafb:ywrap,mtrr hdtv quiet

LABEL install
  MENU LABEL Install GeeXboX to disk ...
  KERNEL /GEEXBOX/boot/vmlinuz
  APPEND initrd=/GEEXBOX/boot/initrd.gz root=/dev/ram0 rw rdinit=linuxrc boot=cdrom lang=en remote=atiusb receiver=atiusb keymap=qwerty splash=silent vga=789 video=vesafb:ywrap,mtrr installator quiet

#CFG#LABEL configure
#CFG#  MENU LABEL Reconfigure a GeeXboX installation ...
#CFG#  KERNEL /GEEXBOX/boot/vmlinuz
#CFG#  APPEND initrd=/GEEXBOX/boot/initrd.gz root=/dev/ram0 rw rdinit=linuxrc boot=cdrom lang=en remote=atiusb receiver=atiusb keymap=qwerty splash=silent vga=789 video=vesafb:ywrap,mtrr configure

MENU SEPARATOR

LABEL debug
  MENU LABEL Start in debugging mode ...
  KERNEL /GEEXBOX/boot/vmlinuz
  APPEND initrd=/GEEXBOX/boot/initrd.gz root=/dev/ram0 rw rdinit=linuxrc boot=cdrom lang=en remote=atiusb receiver=atiusb keymap=qwerty splash=0 vga=789 video=vesafb:ywrap,mtrr debugging

LABEL hdtvdebug
  MENU LABEL Start HDTV edition in debugging mode ...
  KERNEL /GEEXBOX/boot/vmlinuz
  APPEND initrd=/GEEXBOX/boot/initrd.gz root=/dev/ram0 rw rdinit=linuxrc boot=cdrom lang=en remote=atiusb receiver=atiusb keymap=qwerty splash=0 vga=789 video=vesafb:ywrap,mtrr hdtv debugging

F1 help.msg #00000000
EOF
fi
#END GEEXBOX ENTRY#

#BEGIN SLAX ENTRY#
#Note: All Slax options are "Always Fresh," because Slax is running from CD
if [ $SISO = 1 ];then
if [ -f multicd-working/slax/base/002-xorg.lzm ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL xconf
MENU LABEL ^Slax Graphics mode (KDE)
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw autoexec=xconf;telinit~4

LABEL copy2ram
MENU LABEL Slax Graphics mode, Copy To RAM
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw copy2ram autoexec=xconf;telinit~4

LABEL startx
MENU LABEL Slax Graphics VESA mode
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw autoexec=telinit~4

LABEL slax
MENU LABEL Slax Text mode
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw
EOF
else
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL slax
MENU LABEL ^Slax Text mode
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw

LABEL slax2ram
MENU LABEL Slax Text mode, Copy To RAM
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw copy2ram
EOF
fi
fi
#END SLAX ENTRY#

#BEGIN DELI ENTRY#
if [ $DELISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label deli-ide
	menu label ^DeLi Linux
	kernel /isolinux/bzImage
	append initrd=/isolinux/initrd.gz load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=6464 rw root=/dev/ram

label deli-scsi
	menu label ^DeLi Linux - SCSI
	kernel /isolinux/scsi
	append initrd=/isolinux/initrd.gz load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=6464 rw root=/dev/ram
EOF
fi
#END DELI ENTRY

#BEGIN TINYME ENTRY#
if [ $TISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label LiveCD
    menu label ^TinyMe - LiveCD
    kernel /boot/tinyme/vmlinuz
    append livecd=livecd initrd=/boot/tinyme/initrd.gz root=/dev/rd/3 acpi=on vga=788 keyb=us splash=silent fstab=rw,noauto
label VideoSafeModeFBDev
    menu label TinyMe - VideoSafeModeFBDev
    kernel /boot/tinyme/vmlinuz
    append livecd=livecd initrd=/boot/tinyme/initrd.gz root=/dev/rd/3 acpi=on vga=788 keyb=us splash=silent fstab=rw,noauto framebuffer
label VideoSafeModeVesa
    menu label TinyMe - VideoSafeModeVesa
    kernel /boot/tinyme/vmlinuz
    append livecd=livecd initrd=/boot/tinyme/initrd.gz root=/dev/rd/3 acpi=on vga=788 keyb=us splash=silent fstab=rw,noauto vesa
label Safeboot
    menu label TinyMe - Safeboot
    kernel /boot/tinyme/vmlinuz
    append livecd=livecd initrd=/boot/tinyme/initrd.gz root=/dev/rd/3 acpi=off vga=normal keyb=us noapic nolapic noscsi nopcmcia
label Console
    menu label TinyMe - Console
    kernel /boot/tinyme/vmlinuz
    append livecd=livecd 3 initrd=/boot/tinyme/initrd.gz root=/dev/rd/3 acpi=on vga=788 keyb=us splash=silent fstab=rw,noauto
label Copy2ram
    menu label TinyMe - Copy2ram
    kernel /boot/tinyme/vmlinuz
    append livecd=livecd copy2ram initrd=/boot/tinyme/initrd.gz root=/dev/rd/3 acpi=on vga=788 keyb=us splash=silent fstab=rw,noauto splash=verbose
EOF
fi
#END TINYME ENTRY#

#BEGIN ANTIX ENTRY#
if [ $AISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label anitX
menu label ^antiX
com32 menu.c32
append antix.menu
EOF
cat > multicd-working/boot/isolinux/antix.menu << "EOF"
DEFAULT menu.c32
TIMEOUT 0
PROMPT 0
menu title AntiX Options

label  antiX-Default
menu label ^antiX-Default
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init quiet nosplash vga=791 aufs  initrd=/boot/antix/initrd.gz

label  antiX-Lite-noNet
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init quiet nosplash vga=791 aufs mean lean initrd=/boot/antix/initrd.gz

label  antiX-Vesa
menu label antiX-Vesa (display problem or virtualbox)
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init vga=normal quiet nosplash drvr=vesa aufs lean initrd=/boot/antix/initrd.gz

label  antiX-UltraLite-Vesa
menu label antiX-UltraLite-Vesa (Fast boot)
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init vga=normal quiet nosplash drvr=vesa aufs lean Xtralean initrd=/boot/antix/initrd.gz

label  antiX-Failsafe
menu label antiX-Failsafe (minimum options, small display)
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init quiet nosplash vga=normal nosound noapic noscsi nodma noapm nousb nopcmcia nofirewire noagp nomce nodhcp nodbus nocpufreq nobluetooth drvr=fbdev aufs res=800x600v initrd=/boot/antix/initrd.gz

label  antiX-60Hz
menu label antiX-60Hz (force monitor to 58-62 Hz)
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init vga=791 quiet nosplash vsync=58-62 aufs initrd=/boot/antix/initrd.gz

label  antiX-75Hz
menu label antiX-75Hz (force monitor to 73-77 Hz)
kernel /boot/antix/vmlinuz
append SELINUX_INIT=NO init=/etc/init vga=791 quiet nosplash vsync=73-77 aufs initrd=/boot/antix/initrd.gz

label back
menu label ^Back to main menu
com32 menu.c32
append isolinux.cfg
EOF
fi
#END ANTIX ENTRY#

#BEGIN WOLVIX ENTRY#
if [ $WISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label wolvix
menu label ^Wolvix GNU/Linux (login as root, password is toor)
kernel /boot/vmlinuz
append changes=wolvixsave.xfs max_loop=255 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw vga=791 splash=silent
EOF
fi
#END WOLVIX ENTRY#

#BEGIN RIPLINUX ENTRY#
if [ $RIPISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label riplinux
menu label ^RIPLinuX
com32 menu.c32
append riplinux.cfg
EOF
cat >> multicd-working/boot/isolinux/riplinux.cfg << "EOF"
DEFAULT menu.c32
PROMPT 0
MENU TITLE RIPLinuX v6.7

LABEL Boot Linux system! (32-bit kernel)
KERNEL /boot/riplinux/kernel
APPEND vga=normal initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system! (skip keymap prompt)
KERNEL /boot/riplinux/kernel
APPEND vga=normal nokeymap initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system to X! (32-bit kernel)
KERNEL /boot/riplinux/kernel
APPEND vga=normal xlogin initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system to X! (skip keymap prompt)
KERNEL /boot/riplinux/kernel
APPEND vga=normal xlogin nokeymap initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system! (64-bit kernel)
KERNEL /boot/riplinux/kernel64
APPEND vga=normal initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system! (skip keymap prompt)
KERNEL /boot/riplinux/kernel64
APPEND vga=normal nokeymap initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system to X! (64-bit kernel)
KERNEL /boot/riplinux/kernel64
APPEND vga=normal xlogin initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Boot Linux system to X! (skip keymap prompt)
KERNEL /boot/riplinux/kernel64
APPEND vga=normal xlogin nokeymap initrd=/boot/riplinux/rootfs.cgz root=/dev/ram0 rw

LABEL Edit and put Linux partition to boot! (32-bit kernel)
KERNEL /boot/riplinux/kernel
APPEND vga=normal ro root=/dev/XXXX

LABEL Edit and put Linux partition to boot! (64-bit kernel)
KERNEL /boot/riplinux/kernel64
APPEND vga=normal ro root=/dev/XXXX

LABEL Boot memory tester!
KERNEL /boot/memtest
APPEND -

LABEL Boot GRUB bootloader!
KERNEL /boot/riplinux/grub4dos/grub.exe
APPEND --config-file=(cd)/boot/riplinux/grub4dos/menu.lst

LABEL Boot MBR on first hard drive!
KERNEL chain.c32
APPEND hd0 0

LABEL Boot partition #1 on first hard drive!
KERNEL chain.c32
APPEND hd0 1

LABEL Boot partition #2 on first hard drive!
KERNEL chain.c32
APPEND hd0 2

LABEL Boot partition #3 on first hard drive!
KERNEL chain.c32
APPEND hd0 3

LABEL Boot partition #4 on first hard drive!
KERNEL chain.c32
APPEND hd0 4

LABEL Boot MBR on second hard drive!
KERNEL chain.c32
APPEND hd1 0

LABEL Boot partition #1 on second hard drive!
KERNEL chain.c32
APPEND hd1 1

LABEL Boot partition #2 on second hard drive!
KERNEL chain.c32
APPEND hd1 2

LABEL Boot partition #3 on second hard drive!
KERNEL chain.c32
APPEND hd1 3

LABEL Boot partition #4 on second hard drive!
KERNEL chain.c32
APPEND hd1 4

label back
menu label Back to main menu
com32 menu.c32
append isolinux.cfg
EOF
fi
#END RIPLINUX ENTRY#

#BEGIN SYSTEMRESCUECD ENTRY#
if [ $SRISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label rescuecd0
menu label ^SystemRescueCd 32-bit
kernel /boot/sysrcd/rescuecd
append initrd=/boot/sysrcd/initram.igz
label rescuecd1
menu label SystemRescueCd 64-bit
kernel /boot/sysrcd/rescue64
append initrd=/boot/sysrcd/initram.igz
label rescuecd2
menu label SystemRescueCd 32-bit (alternate kernel)
kernel /boot/sysrcd/altker32
append initrd=/boot/sysrcd/initram.igz video=ofonly
label rescuecd3
menu label SystemRescueCd 64-bit (alternate kernel)
kernel /boot/sysrcd/altker64
append initrd=/boot/sysrcd/initram.igz video=ofonly
label rescuecd-rootauto
menu label SysRCD: rescue installed Linux (root=auto; 32-bit)
kernel /boot/sysrcd/rescuecd
append initrd=/boot/sysrcd/initram.igz root=auto
EOF
fi
#END SYSTEMRESCUECD ENTRY#

#BEGIN TRINITY ENTRY#
if [ $TRISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label trk
menu label ^Trinity Rescue Kit
com32 vesamenu.c32
append trk.menu
EOF
cat > multicd-working/boot/isolinux/trk.menu << "EOF"
prompt 0

menu title     build 318
menu background trklogo.jpg
menu color tabmsg 37;40      #80ffffff #00000000
menu color hotsel 30;47      #40000000 #20ffffff
menu color sel 30;47      #40000000 #20ffffff
menu color scrollbar 30;47      #40000000 #20ffffff

MENU WIDTH 75
MENU MARGIN 5
MENU PASSWORDMARGIN 3
MENU ROWS 18
MENU TABMSGROW 22
MENU CMDLINEROW 22
MENU ENDROW 24
MENU PASSWORDROW 11
MENU TIMEOUTROW 23

label trk3
menu label Run ^Trinity Rescue Kit 3.3 (default)
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1

label trk3-1
menu label ^1 : TRK 3.3 as bootserver to boot other TRK clients
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 trkbootnet

label trk3-2
menu label ^2 : TRK 3.3 running from RAM (best >= 512mb, 256mb min)
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 trkinmem

label trk3-3
menu label ^3 : TRK 3.3 with bigger screenfont
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 normalfont

label trk3-4
menu label ^4 : TRK 3.3 in simple VGA mode (debugging of kernel output)
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=1 pci=conf1 splash=off

label trk3-5
kernel /boot/trinity/kernel.trk
menu label ^5 : TRK 3.3 with Belgian keyboard (see docs for other)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 keyb_be

label trk3-6
kernel /boot/trinity/kernel.trk
menu label ^6 : TRK 3.3 - Virusscan all drives (non interactive)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 virusscan

label trk3-7
kernel /boot/trinity/kernel.trk
menu label ^7 : TRK 3.3 - Try more pcmcia and usb nics (when not detected)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 pcmcia

label trk3-8
kernel /boot/trinity/kernel.trk
menu label ^8 : TRK 3.3 - Try more SCSI drivers (when disks not detected)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 scsidrv

label trk3-9
kernel /boot/trinity/kernel.trk
menu label ^9 : TRK 3.3 with a secure shell server enabled
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 sshd

label trk3-10
kernel /boot/trinity/kernel.trk
menu label ^10 : TRK 3.3 - Execute local scripts on harddrive of PC
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 locscr

label trk3-11
kernel /boot/trinity/kernel.trk
menu label 11: TRK 3.3 - ^Fileshare all drives, secured with user
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 smbsec

label trk3-12
kernel /boot/trinity/kernel.trk
menu label 11: TRK 3.3 - Fileshare all drives as ^guest, no security
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 smbguest


label trk3-0
kernel /boot/trinity/kernel.trk
menu label 13: TRK 3.3 - ^Single user mode
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 runlevel 1

label trk3-noacpi
kernel /boot/trinity/kernel.trk
menu label 14: TRK 3.3 - Acpi=off, noapic  PCI=^bios (Alternate boot 1)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose acpi=off noapic pci=bios

label trk3-pcinormal
kernel /boot/trinity/kernel.trk
menu label 15: TRK 3.3 - ^Acpi=off, noapic PCI=any (Alternate boot 2)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose acpi=off noapic

label trk3-pciconf1
kernel /boot/trinity/kernel.trk
menu label 16: TRK 3.3 - ^PCI=conf2 (Alternate boot 3)
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf2

label trk3-debug
menu label 17: TRK 3.3 - ^Verbose startup for debugging after initial bootfase
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 debugging

label trk3-18
menu label 18: TRK 3.3 - SSH server and run from ^RAM
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 sshd trkinmem

label trk3-19
menu label 19: TRK 3.3 - SSH server, run from RAM, act as a ^secure fileserver
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 sshd trkinmem smbsec

label trk3-20
menu label 20 : TRK 3.3 with ^proxyserver support enabled
kernel /boot/trinity/kernel.trk
append initrd=/boot/trinity/initrd.trk ramdisk_size=49152 root=/dev/ram0 vga=788 splash=verbose pci=conf1 proxy

label back
menu label ^Back to main menu
com32 menu.c32
append isolinux.cfg
EOF
fi
#END TRINITY ENTRY#

#BEGIN INSERT ENTRY#
if [ $IISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL insert
menu label ^INSERT
KERNEL /boot/insert/vmlinuz
APPEND ramdisk_size=100000 init=/etc/init lang=en apm=power-off vga=773 initrd=/boot/insert/miniroot.lz nomce noapic dma BOOT_IMAGE=insert
LABEL insert-txt
menu label INSERT (vga=normal)
KERNEL /boot/insert/vmlinuz
APPEND ramdisk_size=100000 init=/etc/init lang=en apm=power-off vga=normal initrd=/boot/insert/miniroot.lz nomce noapic dma BOOT_IMAGE=insert
LABEL expert
menu label INSERT (expert mode)
KERNEL /boot/insert/vmlinuz
APPEND ramdisk_size=100000 init=/etc/init lang=en apm=power-off vga=773 initrd=/boot/insert/miniroot.lz nomce noapic dma BOOT_IMAGE=expert
LABEL failsafe
menu label INSERT (failsafe)
KERNEL /boot/insert/vmlinuz
APPEND ramdisk_size=100000 init=/etc/init lang=en vga=normal atapicd nosound noapic noacpi pnpbios=off acpi=off nofstab noscsi nodma noapm nousb nopcmcia nofirewire noagp nomce nodhcp xmodule=vesa initrd=/boot/insert/miniroot.lz BOOT_IMAGE=insert
EOF
fi
#END INSERT ENTRY#

#BEGIN PARTED MAGIC ENTRY#
if [ $PMISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL normal
MENU LABEL ^Parted Magic: Default settings (Runs from RAM / Ejects CD)
KERNEL /pmagic/bzImage
APPEND noapic initrd=/pmagic/initrd root=/dev/ram0 init=/linuxrc keymap=us livecd vga=791 sleep=0 quiet ramdisk_size=25000

LABEL xvesa
MENU LABEL Parted Magic: Alternate graphical server
KERNEL /pmagic/bzImage
APPEND noapic initrd=/pmagic/initrd root=/dev/ram0 init=/linuxrc keymap=us livecd vga=791 sleep=0 quiet xvesa ramdisk_size=25000
EOF
fi
#END PARTED MAGIC ENTRY#

#BEGIN GPARTED ENTRY#
if [ $GISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label GParted Live
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL ^GParted Live (Default settings)
  # MENU PASSWD
  kernel /boot/gparted/vmlinuz1
  append initrd=/boot/gparted/initrd1.img boot=live union=aufs live-media-path=/boot/gparted noswap vga=788 ip=frommedia

label GParted Live (To RAM)
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL GParted Live (To RAM. Boot media can be removed later)
  # MENU PASSWD
  kernel /boot/gparted/vmlinuz1
  append initrd=/boot/gparted/initrd1.img boot=live union=aufs live-media-path=/boot/gparted noswap vga=788 toram ip=frommedia

label GParted Live without framebuffer
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL GParted Live (Safe graphic settings, vga=normal)
  # MENU PASSWD
  kernel /boot/gparted/vmlinuz1
  append initrd=/boot/gparted/initrd1.img boot=live union=aufs live-media-path=/boot/gparted noswap ip=frommedia vga=normal

label GParted Live failsafe mode
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL GParted Live (Failsafe mode)
  # MENU PASSWD
  kernel /boot/gparted/vmlinuz1
  append initrd=/boot/gparted/initrd1.img boot=live union=aufs live-media-path=/boot/gparted noswap acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip=frommedia vga=normal
EOF
fi
#END GPARTED ENTRY#

#BEGIN NETBOOTCD ENTRY#
if [ $NBISOSLAX = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL netbootcd
MENU LABEL ^NetbootCD 2.x
KERNEL /boot/slax/vmlinuz
APPEND initrd=/boot/slax/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw nohd load=netbootcd-startup.lzm noload=002;003;004;005;006
EOF
fi
if [ $NBISOTC = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL netbootcd
MENU LABEL ^NetbootCD
KERNEL /boot/nbcd/kexec.bzI
APPEND quiet initrd=/boot/nbcd/nbinit3.gz
EOF
fi
#END NETBOOTCD ENTRY#

#BEGIN NTPASSWD ENTRY#
if [ $NTISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label ntpasswd
menu label ^NT Offline Password & Registry Editor
kernel /boot/ntpasswd/vmlinuz
append rw vga=1 init=/linuxrc initrd=/boot/ntpasswd/initrd.cgz,/boot/ntpasswd/scsi.cgz
EOF
fi
#END NTPASSWD ENTRY#

#BEGIN DISK COPY ENTRY#
if [ $DCISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label diskcopy
menu label ^EASEUS Disk Copy
kernel /boot/diskcopy/bzImage
append initrd=/boot/diskcopy/initrd.img
EOF
fi
#END DISK COPY ENTRY#

#BEGIN CLONEZILLA ENTRY#
if [ $CISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label clonezilla
menu label ^Clonezilla
com32 vesamenu.c32
append clonezil.cfg
EOF
cat >> multicd-working/boot/isolinux/clonezil.cfg << "EOF"
# Created by generate-pxe-menu! Do NOT edit unless you know what you are doing! 
# Keep those comment "MENU DEFAULT" and "MENU HIDE"! Do NOT remove them.
# Note!!! If "serial" directive exists, it must be the first directive
default vesamenu.c32
timeout 300
prompt 0
noescape 1
MENU MARGIN 5
 MENU BACKGROUND ocswp.png
# Set the color for unselected menu item and timout message
 MENU COLOR UNSEL 7;32;41 #c0000090 #00000000
 MENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000
 MENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000
 MENU COLOR HELP 7;32;41 #c0000090 #00000000

# MENU MASTER PASSWD

say **********************************************************************
say Clonezilla, the OpenSource Clone System.
say NCHC Free Software Labs, Taiwan.
say clonezilla.sourceforge.net, clonezilla.nchc.org.tw
say THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! 
say **********************************************************************

# Allow client to edit the parameters
ALLOWOPTIONS 1

# simple menu title
MENU TITLE clonezilla.sourceforge.net, clonezilla.nchc.org.tw

# Since no network setting in the squashfs image, therefore if ip=frommedia, the network is disabled. That's what we want.
label Clonezilla live
  MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live (Default settings, VGA 1024x768)
  # MENU PASSWD
  kernel /boot/clonezilla/vmlinuz1
  append initrd=/boot/clonezilla/initrd1.img boot=live union=aufs live-media-path=/boot/clonezilla ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=791 ip=frommedia nolocales
  TEXT HELP
  * Clonezilla live version: 1.2.1-23. (C) 2003-2008, NCHC, Taiwan
  * Disclaimer: Clonezilla comes with ABSOLUTE NO WARRANTY
  ENDTEXT

label Clonezilla live 800x600
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live (Default settings, VGA 800x600)
  # MENU PASSWD
  kernel /boot/clonezilla/vmlinuz1
  append initrd=/boot/clonezilla/initrd1.img boot=live union=aufs live-media-path=/boot/clonezilla ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 ip=frommedia nolocales
  TEXT HELP
  VGA mode 800x600. OK for most of VGA cards.
  ENDTEXT

label Clonezilla live 640x480
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live (Default settings, VGA 640x480)
  # MENU PASSWD
  kernel /boot/clonezilla/vmlinuz1
  append initrd=/boot/clonezilla/initrd1.img boot=live union=aufs live-media-path=/boot/clonezilla ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=785 ip=frommedia nolocales
  TEXT HELP
  VGA mode 640x480. OK for most of VGA cards.
  ENDTEXT

label Clonezilla live (To RAM)
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live (To RAM. Boot media can be removed later)
  # MENU PASSWD
  kernel /boot/clonezilla/vmlinuz1
  append initrd=/boot/clonezilla/initrd1.img boot=live union=aufs live-media-path=/boot/clonezilla ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=791 toram ip=frommedia nolocales
  TEXT HELP
  All the programs will be copied to RAM, so you can
  remove boot media (CD or USB flash drive) later
  ENDTEXT

label Clonezilla live without framebuffer
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live (Safe graphic settings, vga=normal)
  # MENU PASSWD
  kernel /boot/clonezilla/vmlinuz1
  append initrd=/boot/clonezilla/initrd1.img boot=live union=aufs live-media-path=/boot/clonezilla ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" ip=frommedia nolocales vga=normal
  TEXT HELP
  Disable console frame buffer support
  ENDTEXT

label Clonezilla live failsafe mode
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live (Failsafe mode)
  # MENU PASSWD
  kernel /boot/clonezilla/vmlinuz1
  append initrd=/boot/clonezilla/initrd1.img boot=live union=aufs live-media-path=/boot/clonezilla ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip=frommedia nolocales vga=normal
  TEXT HELP
  acpi=off irqpoll noapic noapm nodma nomce nolapic 
  nosmp vga=normal
  ENDTEXT

label local
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Local operating system in harddrive (if available)
  # MENU PASSWD
  # 2 method to boot local device:
  # (1) For localboot 0, it is decided by boot order in BIOS, so uncomment the follow 1 line if you want this method:
  # localboot 0

  # (2) For chain.c32, you can assign the boot device.
  # Ref: extlinux.doc from syslinux
  # Syntax: APPEND [hd|fd]<number> [<partition>]
  # [<partition>] is optional.
  # Ex:
  # Second partition (2) on the first hard disk (hd0);
  # Linux would *typically* call this /dev/hda2 or /dev/sda2, then it's "APPEND hd0 2"
  #
  kernel chain.c32
  append hd0
  TEXT HELP
  Boot local OS from first hard disk if it's available
  ENDTEXT

# Note! *.bin is specially purpose for syslinux, 
# Do NOT use memtest.bin, use memtest instead of memtest.bin
label memtest
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Memory test using Memtest86+
  # MENU PASSWD
  kernel /boot/isoliux/memtest
  TEXT HELP
  Run memory test using Memtest86+
  ENDTEXT

label FreeDOS
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL FreeDOS
  # MENU PASSWD
  kernel memdisk
  append initrd=/boot/balder.imz
  TEXT HELP
  Run FreeDOS
  ENDTEXT

label etherboot
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Network boot via etherboot
  # MENU PASSWD
  kernel /boot/clonezilla/eb.zli
  TEXT HELP
  Run Etherbot to enable network (PXE) boot
  ENDTEXT

label gPXE
  # MENU DEFAULT
  # MENU HIDE
  MENU LABEL Network boot via gPXE
  # MENU PASSWD
  kernel /boot/clonezilla/gpxe.lkn
  TEXT HELP
  Run gPXE to enable network (PXE) boot
  ENDTEXT

label back
menu label Back to main menu
com32 menu.c32
append isolinux.cfg
EOF
fi
#END CLONEZILLA ENTRY#

#BEGIN PING ENTRY#
if [ $PIISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label ping
menu label ^PING (Partimage Is Not Ghost)
kernel /boot/ping/kernel
append vga=normal devfs=nomount pxe ramdisk_size=33000 load_ramdisk=1 init=/linuxrc prompt_ramdisk=0 initrd=/boot/ping/initrd.gz root=/dev/ram0 rw noapic nolapic lba combined_mode=libata ide0=noprobe nomce pci=nommconf pci=nomsi irqpoll
EOF
fi
#END PING ENTRY#

#BEGIN DEBIAN INSTALLER ENTRY#
if [ $DiISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL dinstall
menu label ^Install Debian
	kernel /boot/debian/linux
	append vga=normal initrd=/boot/debian/initrd.gz -- quiet 
LABEL dexpert
menu label Install Debian - expert mode
	kernel /boot/debian/linux
	append priority=low vga=normal initrd=/boot/debian/initrd.gz -- 
EOF
fi
#END DEBIAN INSTALLER ENTRY#

#BEGIN UBUNTU INSTALLER ENTRY#
if [ $UiISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
LABEL uinstall
menu label Install ^Ubuntu
	kernel /boot/ubuntu/linux
	append vga=normal initrd=/boot/ubuntu/initrd.gz -- 
LABEL ucli
menu label Install Ubuntu (CLI)
	kernel /boot/ubuntu/linux
	append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=/boot/ubuntu/initrd.gz -- 

LABEL uexpert
menu label Install Ubuntu - expert mode
	kernel /boot/ubuntu/linux
	append priority=low vga=normal initrd=/boot/ubuntu/initrd.gz -- 
LABEL ucli-expert
menu label Install Ubuntu (CLI) - expert mode
	kernel /boot/ubuntu/linux
	append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false priority=low vga=normal initrd=/boot/ubuntu/initrd.gz -- 
EOF
fi
#END UBUNTU INSTALLER ENTRY#

#BEGIN FEDORA INSTALLER ENTRY#
if [ $FNISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label flinux
  #TIP: If you change the method= entry in the append line, you can change the mirror and version installed.
  menu label ^Install Fedora from mirrors.kernel.org (Fedora 10 only)
  kernel /boot/fedora/vmlinuz
  append initrd=/boot/fedora/initrd.img method=http://mirrors.kernel.org/fedora/releases/10/Fedora/i386/os
label flinux
  menu label ^Install or upgrade Fedora from another mirror
  kernel /boot/fedora/vmlinuz
  append initrd=/boot/fedora/initrd.img
label ftext
  menu label Install or upgrade Fedora (text mode)
  kernel /boot/fedora/vmlinuz
  append initrd=/boot/fedora/initrd.img text
label frescue
  menu label Rescue installed Fedora system
  kernel /boot/fedora/vmlinuz
  append initrd=/boot/fedora/initrd.img rescue
EOF
fi
#END FEDORA INSTALLER ENTRY#

#BEGIN OPENSUSE INSTALLER ENTRY#
if [ $OISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label opensuse-kernel
  menu label Install ^openSUSE (from mirrors.kernel.org)
  kernel /boot/opensuse/linux
EOF
echo "  append initrd=/boot/opensuse/initrd splash=silent showopts install=ftp://mirrors.kernel.org/opensuse/distribution/"$OPENSUSEVERSION"/repo/oss" >> multicd-working/boot/isolinux/isolinux.cfg
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label opensuse
  menu label Install openSUSE (specify mirror)
  kernel /boot/opensuse/linux
  append initrd=/boot/opensuse/initrd splash=silent showopts
label opensuse-repair
  menu label Repair an installed openSUSE system
  kernel /boot/opensuse/linux
  append initrd=/boot/opensuse/initrd splash=silent repair=1 showopts
label opensuse-rescue
  menu label openSUSE rescue system
  kernel /boot/opensuse/linux
  append initrd=/boot/opensuse/initrd splash=silent rescue=1 showopts
EOF
fi
#END OPENSUSE INSTALLER ENTRY#

#BEGIN MANDRIVA INSTALLER ENTRY#
if [ $MiISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label alt0
  menu label Install ^Mandriva
  kernel /boot/mandriva/alt0/vmlinuz
  append initrd=/boot/mandriva/alt0/all.rdz  vga=788 splash=silent
label alt0-vgahi
  menu label Install Mandriva (hi-res installer)
  kernel /boot/mandriva/alt0/vmlinuz
  append initrd=/boot/mandriva/alt0/all.rdz  vga=791
label alt0-text
  menu label Install Mandriva (text-mode installer)
  kernel /boot/mandriva/alt0/vmlinuz
  append initrd=/boot/mandriva/alt0/all.rdz  text
label alt1
  menu label Install Mandriva (server kernel)
  kernel /boot/mandriva/alt1/vmlinuz
  append initrd=/boot/mandriva/alt1/all.rdz vga=788 splash=silent
EOF
fi
#END MANDRIVA INSTALLER ENTRY#

#BEGIN ARCH FTP CD ENTRY#
if [ $ALISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label arch
menu label Boot ^ArchLive
kernel /boot/arch/vmlinuz26
append lang=en locale=en_US.UTF-8 usbdelay=5 ramdisk_size=75% initrd=/boot/arch/archiso_pata.img

label arch-ide
menu label Boot ArchLive [legacy IDE]
kernel /boot/arch/vmlinuz26
append lang=en locale=en_US.UTF-8 usbdelay=5 ramdisk_size=75% ide-legacy initrd=/boot/arch/archiso_ide.img
EOF
fi
#END ARCH FTP CD ENTRY#

#BEGIN FREEDOS ENTRY#
if [ $FDISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label fdos
menu label ^FreeDOS 1.0
kernel memdisk
append initrd=/boot/freedos/fdboot.img
EOF
fi
#END FREEDOS ENTRY#

#BEGIN DISK IMAGE ENTRY#
j="0"
for i in $( ls -1 *.im[g,z] 2> /dev/null | grep -v balder10.imz ); do
  BASICNAME=$(echo $i|sed 's/\.im.//')
  echo label $BASICNAME >> multicd-working/boot/isolinux/isolinux.cfg
  echo kernel memdisk >> multicd-working/boot/isolinux/isolinux.cfg
  echo append initrd=/boot/$j.img >> multicd-working/boot/isolinux/isolinux.cfg
  j=$( expr $j + 1 )
done
#END DISK IMAGE ENTRY#

#BEGIN GRUB4DOS ENTRY#
if [ $G4D = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label grub4dos
menu label ^GRUB4DOS
kernel /boot/grub.exe
EOF
else
if [ $RIPISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label grub4dos
menu label ^GRUB4DOS
kernel /boot/riplinux/grub4dos/grub.exe
EOF
fi
fi
#END GRUB4DOS ENTRY#

#BEGIN GAMES ENTRY#
if [ $GAMES = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label games
menu label ^Games on disk images
com32 menu.c32
append games.cfg
EOF
fi
#END GAMES ENTRY#

#BEGIN DBAN ENTRY#
if [ $DbISO = 1 ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
#Most of the DBAN options are hidden on the menu because they're so dangerous.
#You can comment the "menu hide" line and they will appear as seperate boot options on the menu.

LABEL  dban
MENU LABEL ^DBAN
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe" silent

LABEL  autonuke
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe --autonuke" silent

LABEL  dod
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe --autonuke --method dod522022m" silent

LABEL  dod3pass
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe --autonuke --method dod3pass" silent

LABEL  dodshort
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe --autonuke --method dodshort" silent

LABEL  gutmann
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe --autonuke --method gutmann" silent

LABEL  ops2
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe --autonuke --method ops2" silent

LABEL  paranoid
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe --autonuke --method prng --rounds 8 --verify all" silent

LABEL  prng
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe --autonuke --method prng --rounds 8" silent

LABEL  quick
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe --autonuke --method quick" silent

LABEL  zero
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe --autonuke --method zero" silent

LABEL  nofloppy
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe" floppy=0,16,cmos

LABEL  nosilent
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe"

LABEL  noverify
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc quiet nuke="dwipe --verify off"

LABEL  debug
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="exec ash" debug

LABEL  shell
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="exec ash"

LABEL  verbose
MENU HIDE
KERNEL /boot/dban1/kernel.bzi
APPEND initrd=/boot/dban1/initrd.gz root=/dev/ram0 init=/rc nuke="dwipe --method quick"
EOF
fi
#END DBAN ENTRY#

#BEGIN BALDER ENTRY#
if [ -f multicd-working/boot/balder.imz ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label dos
menu label ^Balder (FreeDOS)
kernel memdisk
append initrd=/boot/balder.imz
EOF
fi
#END BALDER ENTRY#

#BEGIN MEMTEST ENTRY#
if [ -f multicd-working/boot/memtest ];then
cat >> multicd-working/boot/isolinux/isolinux.cfg << "EOF"
label memtest
menu label ^Memtest86+ v2.01
kernel /boot/memtest
EOF
fi
#END MEMTEST ENTRY#
##END ISOLINUX MENU CODE##

if [ $GAMES = 1 ];then
k="0"
cat > multicd-working/boot/isolinux/games.cfg << "EOF"
default menu.c32
timeout 300

menu title "Choose a game to play:"
EOF
for i in $( ls -1 games/*.im[g,z] 2> /dev/null ); do
  BASICNAME=$(echo $i|sed 's/\.im.//'|sed 's/games\///')
  echo label $BASICNAME >> multicd-working/boot/isolinux/games.cfg
  echo kernel memdisk >> multicd-working/boot/isolinux/games.cfg
  echo append initrd=/boot/games/$k.img >> multicd-working/boot/isolinux/games.cfg
  k=$( expr $k + 1 )
done
cat >> multicd-working/boot/isolinux/games.cfg << "EOF"
label back
menu label Back to main menu
com32 menu.c32
append isolinux.cfg
EOF
fi

if [ -d includes ];then
 echo "Copying includes..."
 cp -r includes/* multicd-working/
fi

if [ $MD5 = 1 ];then
 echo "Generating MD5 checksums..."
 if [ $VERBOSE != 0 ];then
  find multicd-working/ -type f -not -name md5sum.txt -not -name boot.cat -not -name isolinux.bin \
  -exec md5sum '{}' \; | sed 's/multicd-working\///g' | tee multicd-working/md5sum.txt
 else
  find multicd-working/ -type f -not -name md5sum.txt -not -name boot.cat -not -name isolinux.bin\
  -exec md5sum '{}' \; | sed 's/multicd-working\///g' > multicd-working/md5sum.txt
 fi
fi

if which genisoimage > /dev/null;then
 GENERATOR="genisoimage"
elif which mkisofs > /dev/null;then
 GENERATOR="mkisofs"
else
 echo "Neither genisoimage nor mkisofs was found."
 exit 1
fi
if [ $TRISO = 1 ];then
 ISOLABEL=TRK_3.3
else
 ISOLABEL=GNULinux
fi
echo "Building CD image..."
if [ $VERBOSE != 0 ];then
 $GENERATOR -o multicd.iso \
 -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
 -no-emul-boot -boot-load-size 4 -boot-info-table \
 -r -J -l -V "$ISOLABEL" multicd-working/
else
 $GENERATOR -o multicd.iso \
 -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
 -no-emul-boot -boot-load-size 4 -boot-info-table \
 -r -J -l -quiet -V "$ISOLABEL" multicd-working/
fi
rm -r multicd-working/
chmod 666 multicd.iso
