#!/bin/bash #Definicion de variables # TODO: Pendiente Definir directorio base del 2FS OGBASEDIR=/var/lib/tftpboot/ogclient/ OGFSFILE=${OGBASEDIR}ogclient.img OGFSMOUNT=${OGBASEDIR}ogclientmount OGLIB=/opt/opengnsys/client/lib FSCLIENTSIZEMB=1000 PASSROOT=og SCRIPT=/root/configure.sh RUNME=$OGFSMOUNT$SCRIPT LASTDEBOOTSTRAP=http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.20_all.deb OGMUSTCOMPILE="http://www.informatica.us.es:8080/opengnsys/browser/trunk/client/engine/ToolsGNU.c?format=txt -O /root/ToolsGNU.c" OGFSLABEL=ogClient #/** # ogClientMount [str_program] #@brief Acceso al 2nd FS del cliente desde el Servidor Opengnsys #@param 1 Opciona: scripts o programa a ejecutar para automatizaciones #@return Si no hay parametros: login de acceso. #@return con un parametro: La salida del programa ejecutado #@exception #@note #@todo #@version 0.9 - Primera versión para OpenGnSys #@author Antonio J. Doblas Viso, Universidad de Málaga #@date 2010/02/15 #*/ ## function ogClientMount () { #TODO comprobar que OGFILE y OGFILEMOUNT existe. mount $OGFSFILE $OGFSMOUNT -o loop mount --bind /proc $OGFSMOUNT/proc mount --bind /sys $OGFSMOUNT/sys mount --bind /tmp $OGFSMOUNT/tmp mount --bind /dev $OGFSMOUNT/dev mount --bind /dev/pts $OGFSMOUNT/dev/pts [ $# = 0 ] && $(chroot $OGFSMOUNT /sbin/getty 38400 `tty`) [ $# = 1 ] && chroot $OGFSMOUNT $1 } #/** # ogClientUnmount #@brief Desmonta el 2nd FS del cliente desde el Servidor Opengnsys #@param #@return #@exception #@note #@todo #@version 0.9 - Primera versión para OpenGnSys #@author Antonio J. Doblas Viso, Universidad de Málaga #@date 2010/02/15 #*/ ## function ogClientUnmount () { cd /tmp umount -d -f -l $OGFSMOUNT/proc umount -d -f -l $OGFSMOUNT/sys umount -d -f -l $OGFSMOUNT/tmp umount -d -f -l $OGFSMOUNT/dev umount -d -f -l $OGFSMOUNT/dev/pts umount -d -f -l $OGFSMOUNT } function ogClientCheckVersion () { #TODO: configurar la version lucid #TODO: introducir un nuevo case para la vesion case $1 in jaunty|JAUNTY) export OGVERSION=jaunty exort OGRELEASE=2.6.28-11-generic ;; karmic|KARMIC) export OGVERSION=karmic export OGRELEASE=2.6.31-14-generic ;; lucid|LUCID) export OGVERSION=lucid export OGRELEASE=2.6.32-21-generic-pae ;; esac echo $OGVERSION $OGRELEASE } #/** # ogClientGenerator str_versionUbuntu str_release #@brief Crea el 2nd FS del cliente desde el Servidor Opengnsys #@param 1 Versión de ubuntu a generar, jaunty karmic #@return #@exception #@note #@todo #@version 0.9 - Primera versión para OpenGnSys #@author Antonio J. Doblas Viso, Universidad de Málaga #@date 2010/02/15 #*/ ## function ogClientGeneratorDebootstrap () { if [ $# != 2 ] then echo Debes introducir como argumento1: jaunty karmic lucid echo Debes introducir como argumento2: la release echo utiliza como entrada ogClientCheckVersion return fi OGVERSION=`echo $1` OGRELEASE=`echo $2` echo $OGVERSION $OGRELEASE pause # instalamos el ultimo debotstrap para permitir instalar versiones superiores a nuestro sistema apt-get install gdebi-core wget $LASTDEBOOTSTRAP gdebi -n debootstrap_1.0.20_all.deb #Creamos el directorio donde montaremos el disco virtual mkdir -p $OGFSMOUNT #Creamos el disco virtual con el filesystem del cliente. dd if=/dev/zero of=$OGFSFILE bs=1048576 count=$FSCLIENTSIZEMB mkfs.ext3 -b 4096 -L $OGFSLABEL $OGFSFILE -F #Montamos el dispositivo virtual en su punto de montaje. mount $OGFSFILE $OGFSMOUNT -o loop #TODO Comprobar arquitectura #Iniciamos la creación del sistema en el directorio de clientes. echo debootstrap --include=linux-image-$OGRELEASE --arch=i386 --components=main,universe $OGVERSION $OGFSMOUNT http://es.archive.ubuntu.com/ubuntu/ debootstrap --include=linux-image-$OGRELEASE --arch=i386 --components=main,universe $OGVERSION $OGFSMOUNT http://es.archive.ubuntu.com/ubuntu/ } ###### Funciones para los clientes offline function agregarOG { cd $NEWROOT mkdir -p opt/opengnsys cp -prv /opt/opengnsys/client/* $NEWROOT/opt/opengnsys echo "agregando OG al newinitrd" } function finalizarISO { cd $ANTERIORPWD mv $TMPINITRD/new-initrd.gz $DEST/initrdISO.gz if [ $LINUX ] ; then mv $TMPINITRD/linux $DEST/linuxISO fi } function CrearISO { mkdir -p tmp/iso/isolinux #cd tmp/iso/ cp -prv /usr/lib/syslinux/* tmp/iso/isolinux/ cp -prv /usr/share/gpxe/* tmp/iso/isolinux/ cp -prv /tmp/linux tmp/iso/isolinux/linuxISO cp -prv /tmp/initrd.gz tmp/iso/isolinux/ cp -prv /opt/opengnsys/client/og2ndFS tmp/iso/isolinux/ cat << FIN > tmp/iso/isolinux/isolinux.cfg DEFAULT menu.c32 PROMPT 0 ALLOWOPTIONS 1 MENU TITLE FuTuR3 Live Collection LABEL gpxe MENU LABEL gpxe KERNEL /clonezilla/live/vmlinuz1 APPEND initrd=/clonezilla/live/initrd1.img boot=live union=aufs noswap vga=788 ip=frommedia #default 0 #prompt 1 #timeout 100 #display mensaje.txt LABEL 0 MENU LABEL ogClient KERNEL linuxISO APPEND initrd=initrd.gz ro vga=788 irqpoll acpi=on boot=admin status=offline LABEL 1 MENU LABEL ogClient1 sin vga KERNEL linuxISO APPEND initrd=initrd.gz ro irqpoll acpi=on boot=admin status=offline LABEL 2 MENU LABEL ogClient2 sin irqpoll KERNEL linuxISO APPEND initrd=initrd.gz ro acpi=on boot=admin status=offline LABEL 3 MENU LABEL ogClient3 acpi=off KERNEL linuxISO APPEND initrd=initrd.gz ro acpi=off boot=admin status=offline #LABEL ogclient #KERNEL /ogclient/linuxISO #APPEND initrd=/ogclient/initrdISO.img #KERNEL linuxISO #APPEND initrd=initrdISO.img LABEL 4 MENU LABEL local localboot 0x80 append - label 5 MENU LABEL Network boot via gPXE lkrn KERNEL gpxe.lkrn label 5 MENU LABEL Network boot via gPXE usb KERNEL gpxe.usb label 5 MENU LABEL Network boot via gPXE pxe KERNEL gpxe.pxe label 5 MENU LABEL Network boot via gPXE iso KERNEL gpxe.iso FIN #### /tmp/iso# mkisofs -V ogClient -o ogClient.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -J -no-emul-boot -boot-load-size 4 -boot-info-table tmp/iso } function probarISO { #/tmp/iso qemu -m 256 -boot d -cdrom ogClient.iso }