#!/bin/bash

VERSION=1.0;
#  **********************************
# *     sxolinux creator script      *
# *  	  based on melux 1.0	     *
# *  ubuntu iso customization script *
# *			  	     *
# *     Author: Dimitris Kalamaras   *
# *   Free to use under GPL3 licence *
# *     http://dimitris.apeiro.gr    *
#  **********************************




loop='./loop/';
work='./work/';
squash='./work/casper/filesystem.squashfs';  # DON'T CHANGE THIS!
new_squash_dir='./squashdir/';


# STEP 1: SPECIFY PACKAGES TO ADD HERE! (hint: use synaptic to find more packages and apt-cache rdepends to see what depends on them)

build_packages='build-essential';
desktop_packages='vlc ttf-liberation inkscape njam amsn luckybackup winbind-'; 
multimedia_packages='gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse  gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-ffmpeg libavcodec-unstripped-52 gstreamer0.10-pitfdll libdvdread4 ffmpeg ffmpeg2theora';
math_packages='ygraph  lybniz ';
download_packages='wine flashplugin-installer unrar winbind-';
greek_packages='language-support-el language-pack-el myspell-dictionary-el language-pack-gnome-el';
edu_packages='kig kalgebra kalzium kbruch kmplot kgeography gperiodic stellarium kstars kturtle marble step  ghemical tuxpaint gcompris bkchem jclic winbind-'
all_gr_edu_packages='gym-anglika-a-c gym-anglika-archarioi-a-c  gym-fysiki-agogi-a-c  gym-gallika-a-c gym-germanika-a-c  gym-irodotou-a-b gym-istoria-a-c gym-omirika-epi-a-b  gym-pliroforiki-a-c gym-thriskeftika-a-c  gym-viologia-a-c ';
gr_edu_packages='gym-anglika-archarioi-a-c  gym-irodotou-a-b gym-istoria-a-c gym-omirika-epi-a-b  gym-pliroforiki-a-c gym-viologia-a-c winbind-';


mce_packages='';


#
# THAT'S ALL. JUST RELAX WHILE WE ARE MAKING YOUR CUSTOM UBUNTU ISO!!! 
#



red='\E[1;31m';
green='\E[1;32m';
black='\E[1;37;38m';
white='e[1;37m';
normal='tput sgr0';






echo    -e $red '  **********************************';
echo -n -e $red ' * ';$normal;echo -n "     sxolinux creator $VERSION       ";echo -e $red '*';
echo -n -e $red ' * ';$normal;echo -n 'ubuntu iso customization script ';echo -e $red '*';
echo -n -e $red ' * ';$normal;echo -n ' author:    Dimitris Kalamaras  ';echo -e $red '*';
echo -n -e $red ' * ';$normal;echo -n ' free to use under GPL3 licence ';echo -e $red '*';
echo -n -e $red ' * ';$normal;echo -n '   http://dimitris.apeiro.gr    ';echo -e $red '*';
echo    -e $red '  **********************************';



echo -n -e $black'checking mksquashfs   ...'; $normal;
if [ -f /usr/bin/mksquashfs ]; then
	echo -e $green 'OK'; $normal;
	
else
	echo -e $red 'mksquashfs not found! Installing package...';
	sudo apt-get install squashfs-tools dpkg-dev
fi



echo -n -e $black'checking for bzr      ...'; $normal;
if [ -f /usr/bin/bzr ]; then
        echo -e $green 'OK'; $normal;

else
        echo -e $red 'bzr vcs not found! Installing package...';
        sudo apt-get install bzr 
fi

echo -n -e $black'checking for mkbootmsg...'; $normal;
if [ -f /usr/bin/mkbootmsg ]; then
        echo -e $green 'OK'; $normal;

else
        echo -e $red 'mkbootmsg not found. Installing...   ...';
        sudo apt-get install gfxboot
fi



echo -n -e $black'unmounting old mounts ...'; $normal;
mounted=`mount | grep $new_squash_dir | awk '{ print $3 }' `;
for i in $mounted; do
	sleep 1;
        sudo umount $i;
done
echo -e $green 'OK'; $normal;

dir=`pwd`/;
echo    -e $black'new base dir    ...' $red 'The original Ubuntu iso should be here!'; $normal; 
echo $dir;


echo    -e $black'entering base dir     ...' $dir; $normal;
cd $dir;

release=`lsb_release -sc`;
echo  -e $black'using ubuntu release  ...' $red  $release; $normal;


newubuntu='sxolinux';
echo   -e $black'using new iso name    ...' $red $newubuntu; $normal;

echo    -e $black'enter version        ...'; $normal;
read version;
newubuntu=$newubuntu-$version;

echo   -e $black'using new iso name    ...' $red $newubuntu; $normal;



echo  -e $black'downloading files     ...'; $normal;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux.html &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinuxtools.desktop &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinuxhelp.desktop &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinuxbooks.desktop &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux-background.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/start-here.svg &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/start-here48.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/start-here32.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/start-here24.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/start-here22.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/start-here16.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/splash-639.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/splash-640.pcx &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/usplash-theme-ubuntu.so &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux-logo-text.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/%gconf-tree.xml  &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux-usplash-1024.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux-usplash-800.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux-usplash-1365.png &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/16_ubuntu-artwork &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/16_ubuntu-wallpapers  &> /dev/null;
wget http://nicomedia.math.upatras.gr/~oxy/sxolinux/sxolinux-doc-artwork.tar.gz &> /dev/null;

echo  -e $black'downloading gfxboot   ...'; $normal;
if [ -d ./gfxboot-theme-ubuntu ]; then
	echo "Target directory \"gfxboot-theme-ubuntu\" already exists.";
else
	bzr get http://bazaar.launchpad.net/~ubuntu-core-dev/gfxboot-theme-ubuntu/mainline gfxboot-theme-ubuntu || echo "Failed to fetch gfxboot-theme-ubuntu"
fi

echo -n -e $black'preparing sources.list...'; $normal;

echo "deb http://security.ubuntu.com/ubuntu $release-security main restricted" > ./sources.list
echo "deb http://archive.ubuntu.com/ubuntu $release-updates main restricted" >> ./sources.list;
echo "deb http://archive.ubuntu.com/ubuntu/ $release main restricted universe multiverse" >> ./sources.list

PPA='ts.sch.gr';
echo "deb http://ppa.launchpad.net/$PPA/ppa/ubuntu $release main" >> ./sxolinux-maintainers.list
echo "deb-src http://ppa.launchpad.net/$PPA/ppa/ubuntu $release main" >> ./sxolinux-maintainers.list

PPA='alkisg';
echo "deb http://ppa.launchpad.net/$PPA/ppa/ubuntu $release main" >> ./sxolinux-maintainers.list
echo "deb-src http://ppa.launchpad.net/$PPA/ppa/ubuntu $release  main" >> ./sxolinux-maintainers.list

echo "deb http://ts.sch.gr/repo stable main" >> ./sxolinux-maintainers.list

echo "deb http://ppa.launchpad.net/luckybackup-maintainers/ppa/ubuntu $release main"  >> ./sxolinux-maintainers.list

echo "deb http://ppa.launchpad.net/tweenk/ppa/ubuntu $release main"  >> ./sxolinux-maintainers.list
echo "deb-src http://ppa.launchpad.net/tweenk/ppa/ubuntu $release main"  >> ./sxolinux-maintainers.list

echo "deb http://ppa.launchpad.net/gnome-colors-packagers/ppa/ubuntu $release  main" >> ./sxolinux-maintainers.list
echo "deb-src http://ppa.launchpad.net/gnome-colors-packagers/ppa/ubuntu $release  main" >> ./sxolinux-maintainers.list


sleep 1;
echo -e $green 'OK'; $normal;



echo -n -e $black'checking loop dir     ...'; $normal;
sleep 1;
if [ -d $loop ]; then
	echo -e $green 'OK'; $normal;
	sudo umount $loop &> /dev/null;
else
	echo -e $red 'creating dir'; $normal;
	mkdir $loop;
fi



orig=`ls *.iso | grep ubuntu-`;
echo -n -e $black'mounting original iso ...'; 
sleep 1;
if [ -f $orig ]; then
	sudo mount -o loop $orig $loop
        echo -e $green 'OK';
else
        echo -e $red 'iso not found!';
	echo -e $black'bye!';
	exit;
fi



echo -n -e $black'checking working dir  ...';
sleep 1;
if [ -d $work ]; then
        #sudo rm -rf $work;
        size=`sudo du -h -s  $work  | awk '{print $1}'`;
        echo -e $green 'OK. Warning: work dir exists. Contents: ' $size;
else
        echo -e $red 'creating work dir';
        mkdir $work;
fi


echo -n -e $black'copying original iso  ...';
#sleep 1;
sudo rsync -avx --progress $loop $work &> /dev/null;
echo -e $green 'OK';

echo -n -e $black'unmount original iso  ...';
sleep 1;
sudo umount $loop;
echo -e $green 'OK';



echo -n -e $black'mounting squash file  ...';
sleep 1;
if [ -f $squash ]; then
        sudo mount -t squashfs -o loop  $squash $loop &> /dev/null;
	echo -e $green 'OK';
else
        echo -e $red 'cannot find filesystem.squashfs!';
        echo -e $black'bye!';
        exit;
fi



echo -n -e $black'checking new_squashdir...';
sleep 1;
if [ -d $new_squash_dir ]; then
       #sudo rm -rf $new_squash_dir;
	size=`sudo du -h -s  $new_squash_dir  | awk '{print $1}'`;
	echo -e $green 'OK. Warning: $new_squash_dir exists. Contents: ' $size;
	is_squash=1;
else
        echo -e $red 'creating new squash dir';
        mkdir $new_squash_dir;
	is_squash=0;
fi



case $is_squash in
	1)
		echo -e $black'continuing            ...';
	;;
	0)
		echo -n -e $black'copying orig squashfs ...';
		sudo rsync -av --progress $loop $new_squash_dir &> /dev/null;
		size=`sudo du -h -s  $new_squash_dir  | awk '{print $1}'`;
		echo -e $green 'OK. Copied over: ' $size ;
	;;
esac

echo -n -e $black'unmount orig squashfs ...';
sleep 1;
sudo umount $loop;
echo -e $green 'OK';



echo -n -e $black'mounting dev > squash ...';
if [ -d $new_squash_dir ]; then
	sudo mount  -t proc none $new_squash_dir/proc &> /dev/null;
        sudo mount --bind /dev $new_squash_dir/dev &> /dev/null;
      	sudo mount --bind /var/run/dbus/ $new_squash_dir/var/run/dbus/ ;
	sudo mount --bind /dev/pts $new_squash_dir/dev/pts
	echo -e $green 'OK';
else
        echo -e $red 'cannot bind /dev!';
        echo -e $black'bye!';
        exit;
fi



echo -n -e $black'copying resolv.conf   ...';
if [ -f $new_squash_dir/etc/resolv.conf.orig ]; then
        sudo cp /etc/resolv.conf $new_squash_dir/etc/
else
	if [ -f $new_squash_dir/etc/resolv.conf ]; then
		sudo mv $new_squash_dir/etc/resolv.conf $new_squash_dir/etc/resolv.conf.orig
	fi
        sudo cp /etc/resolv.conf $new_squash_dir/etc/ 
	
fi

echo -e $green 'OK';

dns=`sudo cat $new_squash_dir/etc/resolv.conf | grep name | awk '{ print $2 }'`;
echo    -e $black'using this dns server ...' $green $dns;



echo    -e $black'chrooting: list chroot...'; $normal;
echo " ";
sudo chroot $new_squash_dir/ ls


echo " ";
echo -n -e $black'adding new repos      ...';
if [ -f $new_squash_dir/etc/apt/sources.list.orig ]; then
	sudo mv ./sources.list $new_squash_dir/etc/apt/
	sudo mv ./sxolinux-maintainers.list $new_squash_dir/etc/apt/sources.list.d/
	echo -e $green 'OK';$normal;
else
	sudo cp $new_squash_dir/etc/apt/sources.list $new_squash_dir/etc/apt/sources.list.orig
	sudo mv ./sources.list $new_squash_dir/etc/apt/
	sudo mv ./sxolinux-maintainers.list $new_squash_dir/etc/apt/sources.list.d/
	echo -e $green 'COPIED';$normal;
fi

echo " ";
echo    -e $black'chrooting: adding keys...'; $normal;
KEY='03AFA832';
sudo chroot $new_squash_dir/ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com $KEY &> /dev/null;
echo -e $green '.';$normal;
KEY='BC9CDA31';
sudo chroot $new_squash_dir/ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com $KEY &> /dev/null;  
echo -e $green '.';$normal;
KEY='2d79f61be8d31a30';
sudo chroot $new_squash_dir/ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com $KEY &> /dev/null;
echo -e $green '.OK';$normal;


echo " ";
echo  -n  -e $black'chrooting: update     ...'; $normal;
sudo chroot $new_squash_dir/ apt-get update &> /dev/null;
echo -e $green 'OK';$normal;

echo " ";
echo   -e $black'chrooting: removing not needed language packages    ...'; $normal;
sudo chroot $new_squash_dir/   apt-get -y --force-yes purge `dpkg -l language-pack-* | grep -v language-pack-el | grep -v language-pack-en | grep -v language-pack-gnome-en | grep -v language-pack-gnome-el | grep -v kde | grep -v Status | grep -v "Name" | grep -v "\Ό\ν\ο\μ\α" | awk '{print $2}'` &> /dev/null;
echo -e $green 'OK';$normal;

echo " ";
echo    -e $black'chrooting: installing essential/restricted packages ...';$normal;
#sudo chroot $new_squash_dir/ apt-get  -y --force-yes install  $build_packages 
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install  $desktop_packages 
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install  $multimedia_packages  
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install $math_packages  
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install $edu_packages 
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install  $gr_edu_packages;
sudo chroot $new_squash_dir/ apt-get -y --force-yes install  $download_packages;



echo " ";
echo    -e $black'chrooting:  removing unnecessary packages          ...';$normal;
sudo  chroot $new_squash_dir/ apt-get  -y --force-yes purge winbind ekiga gcc evolution ubuntu-docs qcad ubuntu-desktop+
sudo  chroot $new_squash_dir/ apt-get  -y --force-yes autoremove
echo " ";
echo    -e $black'chrooting: adding greek language packages          ...';$normal;
sudo chroot $new_squash_dir/ apt-get -y --force-yes install $greek_packages;

echo " ";
echo    -e $black'chrooting: adding sxolinux font packages           ...';$normal;
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install gnome-icon-theme-gartoon-redux
sudo chroot $new_squash_dir/ apt-get  -y --force-yes install   gnome-colors 


echo " ";
echo    -e $black'chrooting: copying new wallpaper,logos,usplash     ...';$normal;

sudo cp -f sxolinux-background.png $new_squash_dir/usr/share/backgrounds/
sudo cp -f usplash-theme-ubuntu.so $new_squash_dir/usr/lib/usplash/
sudo cp -f %gconf-tree.xml $new_squash_dir/var/lib/gconf/debian.defaults/
sudo cp -f 16_ubuntu-wallpapers  $new_squash_dir/usr/share/gconf/defaults/
sudo cp -f 16_ubuntu-artwork  $new_squash_dir/usr/share/gconf/defaults/
sudo  chroot $new_squash_dir/ update-alternatives --install /usr/lib/usplash/usplash-artwork.so usplash-artwork.so /usr/lib/usplash/usplash-theme-ubuntu.so 10
sudo chroot $new_squash_dir/ update-alternatives --config usplash-artwork.so
sudo chroot $new_squash_dir/ update-initramfs -c


sudo cp -f $new_squash_dir/usr/share/icons/GartoonRedux/scalable/apps/web-browser.svg $new_squash_dir/usr/share/icons/GartoonRedux/scalable/apps/firefox.svg




echo " ";
echo    -e $black'chrooting: copying new desktop files               ...';$normal;
sudo rm -f  $new_squash_dir/etc/skel/examples.desktop
sudo mkdir $new_squash_dir/etc/skel/Desktop/
sudo cp -f *.desktop  $new_squash_dir/etc/skel/Desktop/
sudo cp -f sxolinux-logo-text.png $new_squash_dir/usr/share/sxolinux-help/.img/
sudo cp -f *.html  $new_squash_dir/usr/share/sxolinux-help/
sudo cp -f *.svg  $new_squash_dir/usr/share/icons/Human/scalable/places/
sudo cp -f start-here22.png $new_squash_dir/usr/share/icons/Human/22x22/places/start-here.png
sudo cp -f start-here24.png $new_squash_dir/usr/share/icons/Human/24x24/places/start-here.png
sudo cp -f start-here48.png $new_squash_dir/usr/share/icons/Human/48x48/places/start-here.png

sudo cp -f *.svg  $new_squash_dir/usr/share/icons/GartoonRedux/scalable/places/
sudo cp -f start-here22.png $new_squash_dir/usr/share/icons/GartoonRedux/22x22/places/start-here.png
sudo cp -f start-here24.png $new_squash_dir/usr/share/icons/GartoonRedux/24x24/places/start-here.png
sudo cp -f start-here32.png $new_squash_dir/usr/share/icons/GartoonRedux/32x32/places/start-here.png
sudo cp -f start-here16.png $new_squash_dir/usr/share/icons/GartoonRedux/16x16/places/start-here.png
sudo rm -f $new_squash_dir/usr/share/icons/GartoonRedux/fix-logo.pl



echo " ";
echo    -e $black'chrooting: creating directories                    ...';$normal;
	
sudo mkdir $new_squash_dir/usr/share/sxolinux-books/
sudo mkdir $new_squash_dir/usr/share/sxolinux-tools/
tar zxfv sxolinux-doc-artwork.tar.gz 
sudo mv sxolinux-artwork $new_squash_dir/usr/share/
sudo mv sxolinux-docs $new_squash_dir/usr/share/

sudo rm -rf $new_squash_dir/usr/share/ubuntu-artwork/

sudo rm -f $new_squash_dir/etc/alternatives/firefox-homepage 
sudo ln -s  $new_squash_dir/usr/share/ubuntu-artwork/home/firefox-index.html $new_squash_dir/etc/alternatives/firefox-homepage

echo " ";
echo    -e $black'chrooting: copying PDF school books                ...';$normal;
sudo cp -R books/* $new_squash_dir/usr/share/sxolinux-books/



echo " ";
echo    -e $black'chrooting: copying tools                           ...';$normal;
sudo cp -R tools/* $new_squash_dir/usr/share/sxolinux-tools/




echo " ";
echo -n -e $black'cleaning squash dir   ...';$normal;
sudo chroot $new_squash_dir/ apt-get clean
echo -e $green 'OK';$normal;


echo " ";
echo -n -e $black'removing temp files   ...';$normal;
sudo chroot $new_squash_dir/ mv /etc/resolv.conf.orig /etc/resolv.conf
#sudo chroot $new_squash_dir/ mv /etc/apt/sources.list.orig /etc/apt/sources.list


if [ -f $new_squash_dir/etc/apt/sources.list.orig ]; then
	echo -e $red 'FAIL!';$normal;
else
	echo -e $green 'OK';$normal;	
fi

echo " ";
echo -n -e $black'updating squash file  ...';$normal;
sudo chroot $new_squash_dir dpkg-query -W --showformat='${Package} ${Version}\n' | grep -v deinstall > filesystem.manifest
sudo mv ./filesystem.manifest $work/casper/
echo -e $green 'OK';$normal;


echo " ";
echo -n -e $black'umounting .proc fs    ...';$normal;
sleep 1;
sudo umount $new_squash_dir/proc/ &> /dev/null;
if [ -d $new_squash_dir/proc/kcore ]; then
	echo -n -e $red 'Trying again...';$normal;
	sleep 2;
	sudo umount $new_squash_dir/proc/
	if [ -d $new_squash_dir/proc/kcore ]; then
		echo -e $red '.....ERROR!';$normal;
	else 
		echo -e $green '.....OK';$normal;
	fi
else
	echo -e $green 'OK';$normal;	
fi

echo " ";
echo -n -e $black'creating sed script   ...';$normal;
echo "/casper/d" > ./sedscript 
echo "/libdebian-installer4/d" >> ./sedscript
echo "/os-prober/d" >> ./sedscript
echo "/ubiquity/d" >> ./sedscript
echo "/ubuntu-live/d" >> ./sedscript
echo "/user-setup/d" >> ./sedscript
echo -e $green 'OK';$normal;

echo -n -e $black'executing the script  ...';$normal
sudo sed -f ./sedscript < $work/casper/filesystem.manifest > filesystem.manifest-desktop
sudo mv filesystem.manifest-desktop $work/casper/
echo -e $green 'OK';$normal;


echo " ";
echo -n -e $black'making new squashfs   ...';$normal;
sudo mksquashfs $new_squash_dir/ $work/casper/filesystem.squashfs -noappend
echo -e $green 'OK';$normal;


echo " ";
echo    -e $black'chrooting: making and copying new gfxboot files    ...';$normal;
cd gfxboot-theme-ubuntu
make DEFAULT_LANG=el
cd ..
sudo cp -af gfxboot-theme-ubuntu/boot/* "$work/isolinux/" || echo "Error while copying gfxboot files"



echo " ";
echo    -e $black'chrooting: copying sxolinux gfxboot images         ...';$normal;
sudo cp -f splash-639.png $work/isolinux/splash.png
sudo cp -f splash-640.pcx $work/isolinux/splash.pcx


echo " ";
echo    -e $black'chrooting: updating isolinux help files            ...';$normal;

sudo perl -p -i.bak -e s/"Ubuntu"/"Sxolinux"/g $work/isolinux/*.cfg
sudo perl -p -i.bak -e s/"Ubuntu"/"Sxolinux"/g $work/isolinux/*.tr 
sudo perl -p -i.bak -e s/"Ubuntu"/"Sxolinux"/g $work/isolinux/*.hlp
sudo rm -f $work/isolinux/*.bak


echo "el" >> lang
sudo cp -f lang $work/isolinux/


echo " ";
echo -n -e $black'entering working dir  ...';$normal;
cd $work;
echo -e $green 'OK';$normal;

echo " ";
echo -n -e $black'updating md5sums file ...';$normal;

sudo rm -f md5sum.txt
sudo find . -type f -print0 | xargs -0 md5sum > md5sum.txt
echo -e $green 'OK';$normal


echo " ";
echo -n -e $black'creating NEW ISO!!!   ...';$normal;
sudo mkisofs -r -v -V "UbuntuNew" -cache-inodes -J -l  -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -publisher "Dimitris Kalamaras" -p "dimitris.kalamaras@gmail.com"  -o ../$newubuntu.iso .

cd ..

if [ -f $newubuntu.iso ]; then
        echo -e $green 'OK';$normal;
else
	echo -e $red 'Sorry. I failed to make the iso....';$normal;
fi

# make all sane!
tput sgr0
rm -f *.png  el.*  en.*  16_*  *.svg  *.so  *.desktop *.pcx *.html sedscript* %gconf*  lang
rm -rf  gfxboot-theme-ubuntu/

echo ' ' ;
echo -e $black'bye!';$normal;

