# TODO COMO ADMINISTRADOR o ROOT
# GNU/SCRIPT By the GALPon MiniNo team.

#Pasar solo en caso de querer actualizar la Ayuda
#wget -R index.html,index.html?C=D\;O=A,index.html?C=D\;O=D,index.html?C=M\;O=A,index.html?C=M\;O=D,index.html?C=N\;O=A,index.html?C=N\;O=D,index.html?C=S\;O=A,index.html?C=S\;O=D -c -r -nH -np --cut-dirs=3 $1 http://gruvi.galpon.org/arquivos/MiniNo/config-icewm/


# Para que salga el instalador en el menú de icewm, el splash y no de problemas el RESUME
mv /opt/instal/bk-instalarminino.sh /opt/instal/instalarminino.sh
cd /boot/grub
rm splash*
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/splash.xpm.gz
#cd /etc/initramfs-tools/conf.d
#rm resume

clear
echo -e "\033[31;47m     GENERADOR DE LIVECD     \033[0m"
echo ""
echo -e "\033[32mINSTALANDO PROGRAMAS NECESARIOS...\033[0m"
echo ""
sleep 4

apt-get -y --force-yes install lsof cloop-utils genromfs cramfsprogs mkisofs squashfs-tools rsync splashy splashy-themes
apt-get -y --force-yes remove uswsusp
apt-get clean
rm /etc/udev/rules.d/z25_persistent-net.rules
rm /etc/udev/rules.d/70-persistent-net.rules

cd /root
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/livebackup_1.5.0_i386.deb
dpkg -i livebackup_1.5.0_i386.deb; apt-get -f install
cd /usr/share/LiveBackup
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/kernel-image_2.6.24.7-lb-i386.tar.gz
cd /root
rm livebackup_1.5.0_i386.deb
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/LiveBackup.exclude
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/LiveBackup.cfg

cd /usr/bin
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/gen_init_cpio
chmod +x gen_init_cpio
cd /usr/lib/LiveBackup/scripts/
rm make_iso.sh
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/make_iso.sh
chmod +x make_iso.sh

export LB_CONFIG=/root/LiveBackup.cfg
cd /usr/lib/LiveBackup/scripts

clear
echo -e "\033[32mCREAMOS LA ESTRUCTURA BÁSICA DEL LIVECD. Responda Y.\033[0m"
sleep 4

./check_prerequisite.sh
clear
echo -e "\033[32mCOPIAMOS Y COMPRIMIMOS TODO EN FORMATO SQUASHFS.\033[0m"
echo -e "\033[32mResponda Y.\033[0m"
sleep 4
rm /boot/*.bak

./make_backup.sh

cd /root
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/menu.lst
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/splash.xpm.gz
cp menu.lst /usr/share/LiveBackup/master-GALPon_MiniNo/boot/grub/
cp splash.xpm.gz /usr/share/LiveBackup/master-GALPon_MiniNo/boot/grub/
wget http://gruvi.galpon.org/arquivos/MiniNo/EXTRAS/livebackup/rc.local
cp rc.local /etc/
chmod +x /etc/rc.local

cd /usr/lib/LiveBackup/scripts

clear
echo -e "\033[32mGENERAMOS UN INITRD ADECUADO. Responda Y.\033[0m"
sleep 4

./make_initrd.sh

clear
echo -e "\033[32mENSAMBLAMOS TODO EN FORMATO ISO. Responda Y.\033[0m"
sleep 4

./make_iso.sh

clear
echo -e "\033[31mLA IMAGEN ISO SE ENCUENTRA EN EL DIRECTORIO /tmp.\033[0m"
sleep 2
echo -e "\033[31mSi reinicias el ordenador...bye, bye archivo ISO =;-)\033[0m"
echo ""
#cambiado make_iso a más -iso-level porque decía que el límite era de 6 subdirectorios
#sudo -K para lo del timestamp

#Limpiando
echo -e "\033[33mLimpiamos el sistema de todos los archivos temporales utilizados\033[0m"
echo -e "\033[33my programas instalados. CTRL+C para cancelar.\033[0m"
sleep 3

apt-get remove cloop-utils genromfs cramfsprogs mkisofs rsync squashfs-tools syslinux mtools splashy splashy-themes livebackup
rm -r /usr/share/LiveBackup
cd /root
rm menu.lst
rm rc.local
rm LiveBackup.exclude
rm LiveBackup.cfg
rm splash.xpm.gz
