diff options
author | ramon <ramongomez@us.es> | 2011-12-22 13:38:11 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2011-12-22 13:38:11 +0000 |
commit | c3c7cb3ae6f6600223111a572050f34f2df6fa71 (patch) | |
tree | 96fce1db6bf64fee2845d3a48abcbe07d9937562 /client | |
parent | 4caea352de0d0a19d4e0a2e2dd04980dd28e6be0 (diff) |
Congelar versión 1.0.2 en tags/opengnsys-1.0.2 (modifica #446).opengnsys-1.0.2
git-svn-id: https://opengnsys.es/svn/tags/opengnsys-1.0.2@2405 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client')
104 files changed, 3489 insertions, 3195 deletions
diff --git a/client/boot-tools/INSTALL.es.txt b/client/boot-tools/INSTALL.es.txt index d39e798d..7c580934 100644 --- a/client/boot-tools/INSTALL.es.txt +++ b/client/boot-tools/INSTALL.es.txt @@ -2,9 +2,15 @@ OpenGnSys Client boot-tools INSTALL.es.txt ============================================ +Advertencia previa: +----------------------------- +- No usar este instalador en un sistema OpenGnNys en producción. +- Se puede ejecutar este script desde un sistema Ubuntu 10.04, 11.04 +- Mas información http://www.opengnsys.es/wiki/ClienteInitrdDSGenerarloV1.0.2 + + Requisitos iniciales -------------------- - - Utilizar el usuario "root" para ejecutar el proceso de generación del cliente. - Comprobar la conexión a Internet, sobre todo si usas proxy (el hecho de que funcione apt-get no significa que tengas el proxy configurado). @@ -12,35 +18,30 @@ Requisitos iniciales Proceso de instalación ---------------------- -0. Si ya tenemos configurado TFTP, renombrar el directorio /var/lib/tftpboot/ogclient. -1. Descargar del Subversion las herramientas del cliente -2. Ejecutar el instalador: - +#0. Si ya tenemos configurado TFTP, renombrar el directorio /var/lib/tftpboot/ogclient. mv /opt/opengnsys/tftpboot/ogclient /opt/opengnsys/tftpboot/ogclient-old; -svn checkout http://www.opengnsys.es/svn/trunk/client /tmp/opengnsys_installer/opengnsys; + +#1. Descargar del Subversion las herramientas del cliente +apt-get install subversion wget +svn checkout http://www.opengnsys.es/svn/branches/version1.0/client /tmp/opengnsys_installer/opengnsys/client/; +svn checkout http://www.opengnsys.es/svn/branches/version2/ /tmp/opengnsys_installer/opengnsys2; find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null; -/tmp/opengnsys_installer/opengnsys/client/boot-tools/ogClientGeneratorV2.sh; +#2. Ejecutar el instalador: +/tmp/opengnsys_installer/opengnsys/client/boot-tools/boottoolsgenerator.sh; -NOTAS: -- el proceso tardará un buen rato, dependiendo de nuestras circustancias. -- crea un kernel, initrd, ogclient.img en /var/lib/tftpboot/ogclient -- el ogclient.img es el Segundo sistema de archivos en formato fichero bloques emulando a disco con partición primaria. -- el ogclient.sqfs es el Segundo sistema de archivos (partición primaria del img) en formato squashfs. Se usará con el parámetro og2nd=sqfs -- los logs de instalación estarán en /tmp/opengnsys_installation.log -NOTA ACLARATORIA: $OGSCRITPS(reboot,poweroff) antes de /sbin/{reboot,poweroff} Descripción de la estrucutra de boot-tools ------------------------------------------ - INSTALL.es.txt este mismo archivo. -- ogInstaller.lib son todas las funciones del instalador oficial de OpenGnSys. - Algunas de ellas son utilizadas en la generación del cliente - (crear ticket para separar las funciones necesarias). -- ogClientManager.lib son las funicones especificas para la instalacion del cliente; - están escritas en orden de que son llamadas por el instalador. -- ogClientGeneratorV2.sh es el guión de ejecución del isntalador. - +- boottollsgenerator.sh proceso de generación del sistema operativo opengnsys. +- boottoolsfunctions.lib libreria complementaria del boottolsgenerator.sh +- includes/ directorio con ficheros específicos para incluir en la distribución. + + + + diff --git a/client/boot-tools/boottoolsfunctions.lib b/client/boot-tools/boottoolsfunctions.lib new file mode 100644 index 00000000..2f7aff65 --- /dev/null +++ b/client/boot-tools/boottoolsfunctions.lib @@ -0,0 +1,518 @@ +#!/bin/bash +#/** +#@file boottoolsfunctions.lib +#@brief Librería o clase Boot-Tools +#@class Boot-Tools +#@brief Funciones para generar un sistema operativo cliente para opengnsys +#@version 0.9 +#@warning License: GNU GPLv3+ +#*/ + + +# btGetVariables: define las constantes a utilizar +# Autor: Antonio J. Doblas Viso. Universidad de Málaga. +function btogGetVar() +{ + +export BTSVNBOOTTOOLS=/tmp/opengnsys_installer/opengnsys/client/boot-tools +export BTSVNSHARE=/tmp/opengnsys_installer/opengnsys/client/shared +export BTSVNENGINE=/tmp/opengnsys_installer/opengnsys/client/engine + +export BTSVNOG2=/tmp/opengnsys_installer/opengnsys2 + +export BTTARGETDIR=/var/lib/tftpboot/ogclient/ +export BTROOTFSIMG=${BTTARGETDIR}ogclient.img +export BTROOTFSMNT=${BTTARGETDIR}ogclientmount +# tamaño maximo limitado por schroot 2GB +export BTVIRTUALDISKSIZE=2000 +export BTROOTFSIMGLABEL=ogClient + +export LOG_FILE=/tmp/boot-tools_installation.log + +NAMEISOCLIENT=`cat /tmp/opengnsys_info_rootfs` +NAMEHOSTCLIENT=`cat /tmp/opengnsys_chroot` + +export NAMEISOCLIENT +export NAMEHOSTCLIENT +} + + +# btGetOsInfo: detecta la version del host, para tenerla de referencia en el boot-tools a generar. +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +function btogGetOsInfo () +{ + case $1 in + lenny|LENNY) + export OSDISTRIB=debian + export OSCODENAME=lenny + export OSRELEASE="2.6.28-11-generic" + export OSARCH=i386 + export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " + ;; + lucid|LUCID) + export OSDISTRIB=ubuntu + export OSCODENAME=lucid + export OSRELEASE="2.6.32-21-generic-pae" + export OSARCH=i386 + export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " + ;; + host | HOST | *) + export OSDISTRIB=$(lsb_release -i | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null + export OSCODENAME=$(cat /etc/lsb-release | grep CODENAME | awk -F= '{print $NF}') + export OSRELEASE=$(uname -a | awk '{print $3}') + uname -a | grep x86_64 > /dev/null && export OSARCH=amd64 || export OSARCH=i386 + export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" + ;; + esac + echo $OSDISTRIB:$OSCODENAME:$OSRELEASE:$OSARCH:$OSHTTP +} + +# btogSetFsVirtual: Crea y formatea el fichero - disco duro virtual +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +# error code return 2 +function btogSetFsVirtual () +{ + +local RERROR DISKLOOP PARTLOOP #return code error + +#Dependencias. +[ -z "$BTROOTFSIMG" ] && btogGetVar + +echoAndLog "$FUNCNAME(): Creación y formateo del disco virtual $BTVIRTUALDISKSIZE MB " + +#Desmontamos el dispositivo virtual +mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT +mount | grep $BTROOTFSMNTT && umount $BTROOTFSMNT + +#echo "$FUNCNAME(): Creando el directorio donde se montará el disco virtual $BTROOTFSMNT" +mkdir -p $BTROOTFSMNT + +if [ $? -ne 0 ] +then + errorAndLog "$FUNCNAME(): Creando directorio $BTROOTFSMNT : ERROR" + return 1 +fi + +# Permisos para el usuario opengnsys. +chown -R root:opengnsys $BTTARGETDIR + +#echo "$FUNCNAME(): Creando el disco virtual con tamaño máximo de $BTVIRTUALDISKSIZE MB" +dd if=/dev/zero of=$BTROOTFSIMG bs=1048576 count=$BTVIRTUALDISKSIZE + #qemu-img create $BTROOTFSIMG 3G + #dd if=/dev/zero of=$BTROOTFSIMG bs=1k count=$OGCLIENTSIZEKB # necesita 500MB + +if [ $? -ne 0 ] +then + errorAndLog "$FUNCNAME(): Creando el disco virtual con tamaño maxima $BTVIRTUALDISKSIZE MB : ERROR" + return 2 +fi + +# Particionamos el disco virtual con una sola particion primaria. +DISKLOOP=$(losetup -f) +#TODO: si no DISKLOOP error +losetup $DISKLOOP $BTROOTFSIMG +#echo "$FUNCNAME(): particiondo el disco virtual - $DISKLOOP - con una particion primaria" +echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk $DISKLOOP + + +#echoAndLog "$FUNCNAME(): Liberamos Desmontando $DISKLOOP despues del particionado " +losetup -d $DISKLOOP +if [ $? -ne 0 ] +then + errorAndLog "$FUNCNAME(): Liberando disco virtual despues del particionado: ERROR" + return 2 +fi + + +PARTLOOP=$(losetup -f) +#echo "$FUNCNAME(): Formateando la particion principal $PARTLOOP" +losetup -o 32256 $PARTLOOP $BTROOTFSIMG && mkfs.ext3 -b 4096 -L $BTROOTFSIMGLABEL $PARTLOOP +if [ $? -ne 0 ] +then + errorAndLog "$FUNCNAME(): Formateando la particion principal del disco virtual: ERROR" + return 2 +fi +#echoAndLog "$FUNCNAME(): Desmontando $PARTLOOP despues del formateo " +losetup -d $PARTLOOP +if [ $? -ne 0 ] +then + errorAndLog "$FUNCNAME(): Liberando la particion virtual despues del formateo: ERROR" + return 2 +else + echoAndLog "$FUNCNAME(): $BTROOTFSIMG $BTVIRTUALDISKSIZE MB : OK" +fi +} + + +# btogSetfsBase: Genera el sistema root base con debootstrap +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +# error code return 3 +function btogSetFsBase () +{ + +# Dependencias +[ -z "$OSCODENAME" ] && btogGetOsInfo + +echoAndLog "$FUNCNAME: Iniciando la generación del sistema de archivos " + +#Montamos el dispositivo virtual en su punto de montaje. +mount | grep $BTROOTFSMNT || mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 +mount | grep $BTROOTFSMNT && echoAndLog "$FUNCNAME: mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 OK " || errorAndLog "$FUNCNAME: mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 : FAILURE " + +debootstrap --arch=$OSARCH --components=main,universe ${OSCODENAME} ${BTROOTFSMNT} ${OSHTTP} + + +if [ $? -ne 0 ]; then + errorAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $BTROOTFSMNT $OSHTTP : ha fallado!" + mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT + return 3 +else + echoAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $BTROOTFSMNT $OSHTTP : ok" + mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT + return 0 +fi + sleep 5 + +##preubas revisar OSRELEASE +#debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe ${OSCODENAME} ${OGCLIENTMOUNT} ${OSHTTP} +#debootstrap --include=linux-image-${OSRELEASE} --arch=i386 --variant=minbase $OSVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ +#debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ +#echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ +} + +#btogSetFsAcces: habilita el acceso al sistema root del cliente con schroot +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +function btogSetFsAccess() +{ +echoAndLog "$FUNCNAME: Iniciando la configuración del schroot " +cp /etc/schroot/schroot.conf /etc/schroot/schroot.conf.`getDateTime` +cat << EOF > /etc/schroot/schroot.conf +[IMGogclient] +type=loopback +file=/var/lib/tftpboot/ogclient/ogclient.img +description=ogclient ubuntu luc IMGi +#priority=1 +users=root +groups=root +root-groups=root +mount-options=-o offset=32256 +root-users=root +EOF + +cp /etc/schroot/mount-defaults /etc/schroot/mount-defaults.`getDateTime` +cat << EOF > /etc/schroot/mount-defaults +# mount.defaults: static file system information for chroots. +# Note that the mount point will be prefixed by the chroot path +# (CHROOT_PATH) +# +# <file system> <mount point> <type> <options> <dump> <pass> +proc /proc proc defaults 0 0 +#procbususb /proc/bus/usb usbfs defaults 0 0 +#/dev /dev none rw,bind 0 0 +/dev/pts /dev/pts none rw,bind 0 0 +/dev/shm /dev/shm none rw,bind 0 0 +#/home /home none rw,bind 0 0 +/tmp /tmp none rw,bind 0 0 +EOF + +rm /etc/schroot/setup.d/*chrootname + +echoAndLog "$FUNCNAME: Finalizado: OK " +return 0 +} + + + +#btogFsInitr genera un initrd. +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +function btogFsInitrd () +{ +#DEPENDENCIAS +[ -z "$BTROOTFSIMG" ] && btogGetVar +[ -z "$OSCODENAME" ] && btogGetOsInfo + +cd / +schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsInitrdGenerate.sh +echo "cp /tmp/*-${OSRELEASE} ${BTTARGETDIR}" +cp /tmp/*-${OSRELEASE} ${BTTARGETDIR} +#Creando copias de las version oginitr y ogvmlinux previas +TIMEMOD=`date +%Y%m%d-%H%M%S` +[ -f $BTTARGETDIR/oginitrd.img ] && mv $BTTARGETDIR/oginitrd.img $BTTARGETDIR/oginitrd.img.$TIMEMOD; mv $BTTARGETDIR/oginitrd.img.sum $BTTARGETDIR/oginitrd.img.sum.$TIMEMOD +[ -f $BTTARGETDIR/ogvmlinuz ] && mv $BTTARGETDIR/ogvmlinuz $BTTARGETDIR/ogvmlinuz.$TIMEMOD; mv $BTTARGETDIR/ogvmlinuz.sum $BTTARGETDIR/ogvmlinuz.sum.$TIMEMOD + +#copiando +cp /tmp/initrd.img-${OSRELEASE} ${BTTARGETDIR}/oginitrd.img +cp /tmp/vmlinuz-${OSRELEASE} ${BTTARGETDIR}/ogvmlinuz +#generamos md5 del kernel y del initrd. +DATASUM=`md5sum "${BTTARGETDIR}/oginitrd.img" | cut -f1 -d" "` +echo $DATASUM > ${BTTARGETDIR}/oginitrd.img.sum +DATASUM=`md5sum "${BTTARGETDIR}/ogvmlinuz" | cut -f1 -d" "` +echo $DATASUM > ${BTTARGETDIR}/ogvmlinuz.sum +#Damos permisos +cd - +chmod -R 755 $BTTARGETDIR +} + +#btogFsSqfs convierte el sistema root en sqfs +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +function btogFsSqfs () +{ +#Dependencias. +[ -z "$BTROOTFSIMG" ] && btogGetVar +[ -z "$OSCODENAME" ] && btogGetOsInfo + +echoAndLog "$FUNCNAME: Iniciando la creación del sistema de archivos en sqfs " +# si ya existe un sqfs lo renombramos +[ -f $BTTARGETDIR/ogclient.sqfs ] && mv $BTTARGETDIR/ogclient.sqfs $BTTARGETDIR/ogclient.sqfs.`date +%Y%m%d-%H%M%S` +mount | grep $BTROOTFSMNT || mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256 +mksquashfs $BTROOTFSMNT $BTTARGETDIR/ogclient.sqfs +mount | grep $BTROOTFSMNT && umount $BTROOTFSMNT +chmod 744 $BTTARGETDIR/ogclient.sqfs +DATASUM=`md5sum "${BTTARGETDIR}/ogclient.sqfs" | cut -f1 -d" "` +echo $DATASUM > ${BTTARGETDIR}/ogclient.sqfs.sum +} + + + + + +# btogIsoGenerator genera la iso del cliente +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +function btogIsoGenerator { +#Dependencias. +#[ -z "$BTROOTFSIMG" ] && btogGetVar +btogGetVar +#Preparamos los gestores de arranque +mkdir -p /tmp/iso/isolinux +cp -prv /usr/lib/syslinux/* /tmp/iso/isolinux/ +cp -prv /usr/share/gpxe/* /tmp/iso/isolinux/ + +cat << FIN > /tmp/iso/isolinux/isolinux.cfg +DEFAULT menu.c32 +PROMPT 0 +ALLOWOPTIONS 1 + +MENU TITLE OpenGnsys ${NAMEISOCLIENT} + +LABEL gpxe +MENU LABEL gpxe +KERNEL /clonezilla/live/vmlinuz1 +APPEND initrd=/clonezilla/live/initrd1.img boot=live union=aufs noswap vga=788 ip=frommedia + +LABEL 0 +MENU LABEL ogClient vga irqpool acpi ogdebug ip:none +KERNEL /ogclient/linuxISO +APPEND initrd=/ogclient/oginitrd.img ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none + +LABEL 1 +MENU LABEL ogClient irqpoll acpi ip:none +KERNEL /ogclient/linuxISO +APPEND initrd=/ogclient/oginitrd.img ro irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=none + +LABEL 2 +MENU LABEL ogClient acpi debug ip=dhcp +KERNEL /ogclient/linuxISO +APPEND initrd=/ogclient/oginitrd.img ro acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=dhcp + +LABEL 3 +MENU LABEL ogClient ip=dhcp +KERNEL /ogclient/linuxISO +APPEND initrd=/ogclient/oginitrd.img ro acpi=off boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=dhcp + +LABEL 4 +MENU LABEL local +localboot 0x80 +append - + +label 5 +MENU LABEL Network boot via gPXE lkrn +KERNEL gpxe.lkrn + +label 6 +MENU LABEL Network boot via gPXE usb +KERNEL gpxe.usb + +label 7 +MENU LABEL Network boot via gPXE pxe +KERNEL gpxe.pxe + +label 8 +MENU LABEL Network boot via gPXE iso +KERNEL gpxe.iso +FIN + + + + +# preparamos el directorio boot-tools. +mkdir -p /tmp/iso/ogclient +cp ${BTTARGETDIR}/ogclient.sqfs /tmp/iso/ogclient/ +cp ${BTTARGETDIR}/ogclient.sqfs.sum /tmp/iso/ogclient/ +cp ${BTTARGETDIR}/ogvmlinuz /tmp/iso/ogclient/ +cp ${BTTARGETDIR}/ogvmlinuz.sum /tmp/iso/ogclient/ +cp ${BTTARGETDIR}/ogvmlinuz /tmp/iso/ogclient/linuxISO +cp ${BTTARGETDIR}/ogvmlinuz.sum /tmp/iso/ogclient/linuxISO.sum +cp ${BTTARGETDIR}/oginitrd.img /tmp/iso/ogclient/ +cp ${BTTARGETDIR}/oginitrd.img.sum /tmp/iso/ogclient/ +#el ogclienteToISO debe tener una copia del ogvmlinuz como linuxISO +#cp -prv /var/lib/tftpboot/ogclientToIso/* /tmp/iso/ogclient + +cd /tmp +#TIMEMOD=`date +%Y%m%d-%H%M%S` +####Generamos la iso +echo "mkisofs -V ogClient -o ${NAMEISOCLIENT}.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -J -no-emul-boot -boot-load-size 4 -boot-info-table /tmp/iso" +mkisofs -V ogClient -o ${NAMEISOCLIENT}.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -J -no-emul-boot -boot-load-size 4 -boot-info-table /tmp/iso +##Generamos el md5 +DATASUM=`md5sum ${NAMEISOCLIENT}.iso | cut -f1 -d" "` +echo $DATASUM > ${NAMEISOCLIENT}.iso.sum + +mv /tmp/${NAMEISOCLIENT}.iso /var/lib/tftpboot/ogclient/ +mv /tmp/${NAMEISOCLIENT}.iso.sum /var/lib/tftpboot/ogclient/ + + +### vi /etc/grub.d/40_custom +## +#menuentry "og cache " { +#set root=(hd0,4) +#linux /ogvmlinuz ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none +#initrd /oginitrd.img +#} + +} + + +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +function btogIsoTest { +#/tmp/iso +qemu -m 256 -boot d -cdrom ogClient.iso +} + + + + +function getDateTime() +{ + echo `date +%Y%m%d-%H%M%S` +} + +# Escribe a fichero y muestra por pantalla +function echoAndLog() +{ + echo $1 + FECHAHORA=`getDateTime` + echo "$FECHAHORA;$SSH_CLIENT;$1" >> $LOG_FILE +} + +function errorAndLog() +{ + echo "ERROR: $1" + FECHAHORA=`getDateTime` + echo "$FECHAHORA;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE +} + + + + + + + + + + +############### No usados en el instalador, solo en actualizaciones. +#/** +# 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 | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 + mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc + mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys + mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp + mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev + mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts + + + [ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`) + [ $# = 1 ] && chroot $OGCLIENTMOUNT $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 + echo "desmontando cliente espere" + sleep 5 + mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount + mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount + mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount + mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount + mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount + mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount + #-d -f -l + +} diff --git a/client/boot-tools/boottoolsgenerator.sh b/client/boot-tools/boottoolsgenerator.sh new file mode 100755 index 00000000..70a77355 --- /dev/null +++ b/client/boot-tools/boottoolsgenerator.sh @@ -0,0 +1,134 @@ +#!/bin/bash +#@file boottoolsgenerator.sh +#@brief Script generación del sistema opertativo cliente OpenGnSys +#@warning +#@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0 - Compatibilidad OpengGnsys X. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011/08/03 +#*/ + + #mkdir -p /tmp/opengnsys_installer/opengnsys; + #mkdir -p /tmp/opengnsys_installer/opengnsys2; + #cp -prv /home/administrador/workspace/OpenGnsys/branches/version2/* /tmp/opengnsys_installer/opengnsys2/; + #cp -prv /home/administrador/workspace/OpenGnsys/branches/version1.0/client/ /tmp/opengnsys_installer/opengnsys/; +#find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null; + + +#Variables +TYPECLIENT=host +WORKDIR=/tmp/opengnsys_installer +INSTALL_TARGET=/opt/opengnsys +PROGRAMDIR=$(readlink -e $(dirname "$0")) + +# Solo ejecutable por usuario root +if [ "$(whoami)" != 'root' ] +then + echo "ERROR: this program must run under root privileges!!" + exit 1 +fi + +for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done +for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done +for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done + + + +#funciones especificas del cliente. +source $PROGRAMDIR/boottoolsfunctions.lib + + +echoAndLog "OpenGnSys CLIENT installation begins at $(date)" + +########################################################################## +## FASE 1 - Instalación de software adicional. +cat /etc/apt/sources.list | grep "http://free.nchc.org.tw/drbl-core" || echo "deb http://free.nchc.org.tw/drbl-core drbl stable " >> /etc/apt/sources.list +apt-get update +apt-get -y --force-yes install debootstrap subversion schroot squashfs-tools syslinux genisoimage gpxe qemu + +##### FASE 2 - Asignación de variables +#obtenemos las variables necesarias y la información del host. +btogGetVar && btogGetOsInfo + +############# FASE 3: Creación del Sistema raiz RootFS (Segundo Sistema archivos (img)) +##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. +file $BTROOTFSIMG | grep "partition 1: ID=0x83" +if [ $? == 1 ] +then + btogSetFsVirtual || exit 2 +fi +#3.2 generamos el Sistema de archivos con debootstrap +schroot -p -c IMGogclient -- touch /tmp/ogclientOK +if [ -f /tmp/ogclientOK ] +then + rm /tmp/ogclientOK +else + btogSetFsBase || exit 3 +fi + +# FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot +cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess + +# FASE 5: Incorporando con ficheros OG el sistema raiz rootfs +cp -prv ${BTSVNBOOTTOOLS}/includes/usr/bin/* /tmp/ +chmod 777 /tmp/boot-tools/*.sh +schroot -p -c IMGogclient -- /tmp/boot-tools/boottoolsFsOpengnsys.sh + +# FASE6: Instalacion de software +# 6.1 instalacion de software con apt-get +#cp /etc/apt/sources.list /tmp +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh + + +# 6.2 compilación de software. +cd / +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh + +cd - + +#Fase 7. Personalizando + +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh + + +### 7.1 incorporamos la clave publica del servidor +cd / +ssh-keygen -q -f /root/.ssh/id_rsa -N "" +cp /root/.ssh/id_rsa.pub /tmp +schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh +cd - +### 7.2 y la del propio cliente. +schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh + +## 7.3 configuramos los locales. +schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh + +for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done +for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done +for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done + + + + + +#Fase 7. Generando la ISO. +#7.1 el initrd +btogFsInitrd + + +#7.2 Convertivos el sistema raiz img en formato sqfs +btogFsSqfs +#7.3 Generamos la iso +btogIsoGenerator + + +# Mostrar sumario de la instalación e instrucciones de post-instalación. +installationSummary + +echoAndLog "OpenGnSys installation finished at $(date)" + + + diff --git a/client/boot-tools/clientstructure/etc/initramfs-tools/scripts/ogfunctions b/client/boot-tools/clientstructure/etc/initramfs-tools/scripts/ogfunctions deleted file mode 100644 index 16539dd6..00000000 --- a/client/boot-tools/clientstructure/etc/initramfs-tools/scripts/ogfunctions +++ /dev/null @@ -1,479 +0,0 @@ -#@file ogfunctions.lib -#@brief Librería o clase para la generación del 1erFS -#@class client -#@brief Funciones para la generación del primers sistema (initrd) -#@version 0.91 -#@warning License: GNU GPLv3+ - - - - -ogExportKernelParameters () -{ - GLOBAL="cat /proc/cmdline" - for i in `${GLOBAL}` - do - echo $i | grep "=" > /dev/null && export $i - done -return 0 -} - -ogExportVarEnvironment () -{ - export CFGINITRD="/tmp/initrd.cfg" - echo "puntos de accesos al servidor ogprotocol=nfs" >> $CFGINITRD - export NFSROOTBOOT="/var/lib/tftpboot" && echo "NFSROOTBOOT=$NFSROOTBOOT" >> $CFGINITRD - export NFSCLIENTDIR="/opt/opengnsys/client" && echo "NFSCLIENDIR=$NFSCLIENTDIR" >> $CFGINITRD - export NFSLOGDIR="/opt/opengnsys/log/clients" && echo "NFSLOGDIR=$NFSLOGDIR" >> $CFGINITRD - export NFSIMGDIR="/opt/opengnsys/images" && echo "NFSIMGDIR=$NFSIMGDIR" >> $CFGINITRD - echo "puntos de accesos al servidor ogprotocol=smb" >> $CFGINITRD - export SMBROOTBOOT="tftpboot" && echo "SMBROOTBOOT=$SMBROOTBOOT" >> $CFGINITRD - export SMBCLIENTDIR="ogclient" && echo "SMBCLIENTDIR=$SMBCLIENTDIR" >> $CFGINITRD - export SMBLOGDIR="oglog" && echo "SMBLOGDIR=$SMBLOGDIR" >> $CFGINITRD - export SMBIMGDIR="ogimages" && echo "SMBIMGDIR=$SMBIMGDIR" >> $CFGINITRD - - echo "puntos de montaje local para los contenedores" >> $CFGINITRD - export LOCALROOTBOOT="/opt/og2fs/tftpboot" && echo "LOCALROOTBOOT=$LOCALROOTBOOT" >> $CFGINITRD - export LOCALCLIENTDIR="/opt/opengnsys" && echo "LOCALCLIENTDIR=$LOCALCLIENTDIR" >> $CFGINITRD - export LOCALLOGDIR="/opt/opengnsys/log" && echo "LOCALLOGDIR=$LOCALLOGDIR" >> $CFGINITRD - export LOCALIMGDIR="/opt/opengnsys/images" && echo "LOCALIMGDIR=$LOCALIMGDIR" >> $CFGINITRD - - echo "puntos de montajes para realizar la integración unionfs entre el initrd y el sistema root" >> $CFGINITRD - #punto de montaje donde se accede al 2nd FS mediante loop - export LOCALROOTIMG="/opt/og2fs/2ndfs" && echo "LOCALROOTIMG=$LOCALROOTIMG" >> $CFGINITRD - #punto de montaje para unionfs - export LOCALROOTRAM="/opt/og2fs/1stfs" && echo "LOCALROOTRAM=$LOCALROOTRAM" >> $CFGINITRD - #punto de union entreo LOCALROOTIMG y LOCALROOTRAM - export LOCALROOTUNION="/opt/og2fs/unionfs" && echo "LOCALROOTUNION=$LOCALROOTUNION" >> $CFGINITRD - ##INFORMACION DE OTRAS VARIABLES OBTENDIAS EN OTRAS FUNCIONES. - #ogGetROOTSERVER() ip del servidor pxe, valor obtenido automaticamente desde dhcpd. - #IPV4DDR - #IPV4BROADCAST - #IPV4NETMASK - #IPV4GATEWAY - #DNS0 DNS1 - #HOSTNAME - #ROOTSERVER #ip del servidor pxe que ha servido el kernel - #REPOSERVER=ogrepo -> ogConectROOTSERVER() ip del servidor de images para separar serviicios. - return 0 -} - -ogConfigureRamfs () -{ - mkdir -p $LOCALROOTBOOT - mkdir -p $LOCALROOTIMG - mkdir -p $LOCALROOTRAM - mkdir -p $LOCALROOTUNION -} - -ogLoadNetModule () -{ - #cargando netmodule - if [ -n "$ognetmodule" ] - then - echo "Cargando modulo de red $netmodule" - insmod `find /lib/modules/ -name ${netmodule}*` - fi -} - - -ogPostConfigureFS() -{ - # configuramos el /etc/hostname. - echo $HOSTNAME > /etc/hostname - - #configuramos el /etc/hosts - echo "127.0.0.1 localhost" > /etc/hosts - echo "$IPV4ADDR $HOSTNAME" >> /etc/hosts - - #configuramos el host.conf - echo "order hosts,bind" > /etc/host.conf - echo "multi on" >> /etc/host.conf - - # configuramos el /etc/networks - #read -e NETIP NETDEFAULT <<<$(route -n | grep eth0 | awk -F" " '{print $1}') - NETIP=$(route -n | grep eth0 | awk -F" " '{print $1}') && NETIP=$(echo $NETIP | cut -f1 -d" ") - echo "default 0.0.0.0" > /etc/networks - echo "loopback 127.0.0.0" >> /etc/networks - echo "link-local 169.254.0.0" >> /etc/networks - echo "localnet $NETIP" >> /etc/networks - #route - - #enlace si iniciamos desde ogprotocolo=local { cdrom, usb, cache } . - # monta el raiz del dispositivo local en /opt/og2fs/tftpboot - acceso al fichero .sqfs - # y monta el sistema root sqfs en /opt/og2fs/2ndfs - [ "$LOCALMEDIA" == "CACHE" ] && ln -s /opt/og2fs/tftpboot /opt/opengnsys/cache - [ "$ogprotocol" == "local" ] && ln -s /opt/og2fs/2ndfs/opt/opengnsys/* /opt/opengnsys/ - - -} - - - - -ogGetROOTSERVER () -{ - # get nfs root from dhcp - if [ "x${NFSROOT}" = "xauto" ]; then - # check if server ip is part of dhcp root-path - if [ "${ROOTPATH#*:}" = "${ROOTPATH}" ]; then - NFSROOT=${ROOTSERVER}:${ROOTPATH} - else - NFSROOT=${ROOTPATH} - fi - - # nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] - elif [ -n "${NFSROOT}" ]; then - # nfs options are an optional arg - if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then - NFSOPTS="-o ${NFSROOT#*,}" - fi - NFSROOT=${NFSROOT%%,*} - if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then - NFSROOT=${ROOTSERVER}:${NFSROOT} - fi - fi - export ROOTSERVER - echo "ROOTSERVER=$ROOTSERVER" >> $CFGINITRD -return 0 -} - -ogConectROOTSERVER () -{ -local OPTIONS -#params a detectar -if [ $ogrepo ] -then - # Validar si la ip es correcta - ROOTREPO=$ogrepo -else - ROOTREPO=$ROOTSERVER -fi - -case "$ogprotocol" in - local) - echo "Montar imagen del sistema root desde dispositivo local" - for i in $(blkid /dev/s* | grep ogClient | awk -F: '{print $2}' | tr -d \"); do export $i; done - mount -t $TYPE LABEL=$LABEL $LOCALROOTBOOT - if [ $? != 0 ] - then - mount -t reiserfs LABEL=CACHE $LOCALROOTBOOT - export LOCALMEDIA=CACHE - fi - ;; - httfs) - echo "protocolo httfs aun no soportado" - ;; - sshfs) - echo "protocolo sshfs aun no soportado" - ;; - smb) - echo "Preparando conexión con el Repositorio $ROOTSERVER por $ogprotocol" - OPTIONS=" -o user=opengnsys,pass=og" - mount.cifs //${ROOTSERVER}/${SMBCLIENTDIR} $LOCALCLIENTDIR $OPTIONS - mount.cifs //${ROOTSERVER}/${SMBLOGDIR} $LOCALLOGDIR $OPTIONS - mount.cifs //${ROOTSERVER}/${SMBROOTBOOT} $LOCALROOTBOOT $OPTIONS - mount.cifs //${ROOTREPO}/${SMBIMGDIR} $LOCALIMGDIR ${OPTIONS},ro - ;; - nfs) - echo "Preparando conexión con el Repositorio $ROOTSERVER por $ogprotocol" - nfsmount -o nolock,ro $ROOTSERVER:$NFSCLIENTDIR $LOCALCLIENTDIR - nfsmount -o nolock $ROOTSERVER:$NFSLOGDIR $LOCALLOGDIR - nfsmount -o nolock $ROOTSERVER:$NFSROOTBOOT $LOCALROOTBOOT - nfsmount -o nolock,ro $ROOTREPO:$NFSIMGDIR $LOCALIMGDIR - ;; -esac -} - -ogMerge2ndFile() -{ -if [ -f $LOCALROOTBOOT/ogclient/ogclient.sqfs ] -then - cat /proc/mounts > /tmp/mtab.preunion - if [ "$og2nd" == "img" ] - then - #para acceder al img - losetup /dev/loop0 $LOCALROOTBOOT/ogclient/ogclient.img -o 32256 - mount /dev/loop0 $LOCALROOTIMG - else - ## para acceder al squashfs - mount $LOCALROOTBOOT/ogclient/ogclient.sqfs $LOCALROOTIMG -t squashfs -o loop - fi - for i in etc var lib bin sbin usr root boot; do - unionmount $i - done - cat /tmp/mtab.preunion > /etc/mtab -else - echo "Fichero imagen del cliente no encontrado" - return 1 -fi -} - - -unionmount() -{ - tmpdir=/$1 #dir - FUSE_OPT="-o default_permissions -o allow_other -o use_ino -o nonempty -o suid" - UNION_OPT="-o cow -o noinitgroups" - UBIN="unionfs-fuse" - #UPATH="/unionfs" - #LOCALROOTIMG="/opt/og2fs/2ndfs" - #LOCALROOTRAM="/opt/og2fs/1stfs" #/unionfs/host #punto de montaje para unionfs - #LOCALROOTUNION=/opt/og2fs/unionfs/" #/unionfs/union #punto de union entreo LOCALROOTIMG y LOCALROOTRAM - #mkdir -p $LOCALROOTRAM #/unionfs/host - #mkdir -p $LOCALROOTUNION #/unionfs/union - mkdir -p $LOCALROOTRAM$tmpdir - #mount --bind /$tmpdir $LOCALROOTRAM$tmpdir - U1STDIR="${LOCALROOTRAM}${tmpdir}=RW" - U2NDDIR="${LOCALROOTIMG}${tmpdir}=RO" - UNIONDIR=$LOCALROOTUNION$tmpdir - mkdir -p $UNIONDIR - $UBIN $FUSE_OPT $UNION_OPT ${U1STDIR}:${U2NDDIR} $UNIONDIR - mount --bind $UNIONDIR $tmpdir -} - - -unionmountOLD() -{ - FUSE_OPT="-o default_permissions -o allow_other -o use_ino -o nonempty -o suid" - UNION_OPT="-o cow -o noinitgroups" - UPATH="/unionfs" - UBIN="unionfs-fuse" - mkdir -p /unionfs/host - mkdir -p /unionfs/union - dir=$1 - mkdir -p /unionfs/host/$dir - #mount --bind /$dir /unionfs/host/$dir - mkdir -p /unionfs/union/$dir - host="/unionfs/host/${dir}=RW" - common="/opt/og2fs/${dir}=RO" - $UBIN $FUSE_OPT $UNION_OPT ${host}:${common} /unionfs/union/$dir - mount --bind /unionfs/union/$dir /$dir -} - -ogconfigure_lo() -{ -# for the portmapper we need localhost -ifconfig lo 127.0.0.1 -#/etc/init.d/portmap start -} - -ogconfigure_networking() -{ -#echo "ogconfigure_networking: Buscando interfaz a configurar DEVICE" -if [ -n "${BOOTIF}" ] -then - #echo " variable BOOTIF exportada con pxelinux.0 con valor $BOOTIF" - IP=$IPOPTS - temp_mac=${BOOTIF#*-} - # convert to typical mac address format by replacing "-" with ":" - bootif_mac="" - IFS='-' - for x in $temp_mac ; do - if [ -z "$bootif_mac" ]; then - bootif_mac="$x" - else - bootif_mac="$x:$bootif_mac" - fi - done - unset IFS - # look for devices with matching mac address, and set DEVICE to - # appropriate value if match is found. - for device in /sys/class/net/* ; do - if [ -f "$device/address" ]; then - current_mac=$(cat "$device/address") - if [ "$bootif_mac" = "$current_mac" ]; then - DEVICE=${device##*/} - break - fi - fi - done -else - #echo "variable BOOTIF no exportada, intentamos detectar que interfaz se ha iniciado" - IP=$ip - #TODO Detectar que interfaz se ha iniciado - case ${IP} in - none|off) - return 0 - ;; - ""|on|any) - # Bring up device - DEVICE=eth0 - ;; - dhcp|bootp|rarp|both) - DEVICE=eth0 - ;; - *) - DEVICE=`echo $IP | cut -f6 -d:` - ;; - esac -fi -if [ -z "${DEVICE}" ]; then - echo "variable DEVICE con valor $DEVICE no encontrada, llamamos de nuevo a ogconfigure_networking" - ogconfigure_networking -fi - -[ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ] && return 0 -#if [ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ]; then -# echo "variable DEVICE con valor $DEVICE y fichero /tmp/net-$DEVICE encontrados" -# return 0 -#else -# echo "variable DEVICE con valor $DEVICE encontrada, procedemos a configurala y a crear el fichero /tmp/net-$DEVICE" -#fi - -# Activamos la interfaz antes de configurar. -ip address flush $DEVICE -ip link set dev $DEVICE up -# Si no se detecta señal portadora volver a configurar. -sleep 1 -CARRIER=$(cat /sys/class/net/${DEVICE}/carrier) -if [ "$CARRIER" != "1" ] -then - ogconfigure_networking -fi - -# support ip options see linux sources -# Documentation/filesystems/nfsroot.txt -# Documentation/frv/booting.txt -for ROUNDTTT in 2 3 4 6 9 16 25 36 64 100; do - # The NIC is to be configured if this file does not exist. - # Ip-Config tries to create this file and when it succeds - # creating the file, ipconfig is not run again. - if [ -e /tmp/net-"${DEVICE}".conf ]; then - break; - fi - case ${IP} in - none|off) - return 0 - ;; - ""|on|any) - # Bring up device - echo "Setting $DEVICE with option:on|any and Variable IP= $IP: ipconfig -t ${ROUNDTTT} ${DEVICE} " - ipconfig -t ${ROUNDTTT} ${DEVICE} - ;; - dhcp|bootp|rarp|both) - echo "Setting $DEVICE with option:dhcp|bootp|rarp|both and Variable IP= $IP: ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE} " - ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE} - ;; - *) - echo "Setting $DEVICE with option * and Variable IP= $IP: ipconfig -t ${ROUNDTTT} -d $IP " - ipconfig -t ${ROUNDTTT} -d $IP - # grab device entry from ip option - NEW_DEVICE=${IP#*:*:*:*:*:*} - if [ "${NEW_DEVICE}" != "${IP}" ]; then - NEW_DEVICE=${NEW_DEVICE%:*} - else - # wrong parse, possibly only a partial string - NEW_DEVICE= - fi - if [ -n "${NEW_DEVICE}" ]; then - DEVICE="${NEW_DEVICE}" - fi - ;; - esac -done - -# source ipconfig output -if [ -n "${DEVICE}" ]; then - . /tmp/net-${DEVICE}.conf - DEVICECFG="/tmp/net-${DEVICE}" - export DEVICECFG - export DEVICE - echo "DEVICE=$DEVICE" >> $CFGINITRD - echo "DEVICECFG=$DEVICECFG" >> $CFGINITRD - echo "exportando variable DEVICE con valor = $DEVICE y el DEVICECFG con valor $DEVICECFG" -else - # source any interface as not exaclty specified - . /tmp/net-*.conf -fi -} - - ##################################################################### -# Ask yesno question. -# -# Usage: yesno OPTIONS QUESTION -# -# Options: -# --timeout N Timeout if no input seen in N seconds. -# --default ANS Use ANS as the default answer on timeout or -# if an empty answer is provided. -# -# Exit status is the answer. 0=yes 1=no - -ogYesNo() -{ - local ans - local ok=0 - local timeout=0 - local default - local t - - while [[ "$1" ]] - do - case "$1" in - --default) - shift - default=$1 - if [[ ! "$default" ]]; then error "Missing default value"; fi - t=$(echo $default | tr '[:upper:]' '[:lower:]') - - if [[ "$t" != 'y' && "$t" != 'yes' && "$t" != 'n' && "$t" != 'no' ]]; then - error "Illegal default answer: $default" - fi - default=$t - shift - ;; - - --timeout) - shift - timeout=$1 - if [[ ! "$timeout" ]]; then error "Missing timeout value"; fi - #if [[ ! "$timeout" =~ ^[0-9][0-9]*$ ]]; then error "Illegal timeout value: $timeout"; fi - shift - ;; - - -*) - error "Unrecognized option: $1" - ;; - - *) - break - ;; - esac - done - - if [[ $timeout -ne 0 && ! "$default" ]]; then - error "Non-zero timeout requires a default answer" - fi - - if [[ ! "$*" ]]; then error "Missing question"; fi - - while [[ $ok -eq 0 ]] - do - if [[ $timeout -ne 0 ]]; then - if ! read -t $timeout -p "$*" ans; then - ans=$default - else - # Turn off timeout if answer entered. - timeout=0 - if [[ ! "$ans" ]]; then ans=$default; fi - fi - else - read -p "$*" ans - if [[ ! "$ans" ]]; then - ans=$default - else - ans=$(echo $ans | tr '[:upper:]' '[:lower:]') - fi - fi - - if [[ "$ans" == 'y' || "$ans" == 'yes' || "$ans" == 'n' || "$ans" == 'no' ]]; then - ok=1 - fi - - if [[ $ok -eq 0 ]]; then warning "Valid answers are: yes y no n"; fi - done - [[ "$ans" = "y" || "$ans" == "yes" ]] -} - - diff --git a/client/boot-tools/clientstructure/etc/profile.d/loadenviron.sh b/client/boot-tools/clientstructure/etc/profile.d/loadenviron.sh deleted file mode 100755 index c6e8f790..00000000 --- a/client/boot-tools/clientstructure/etc/profile.d/loadenviron.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -#/** -#@file loadenviron.sh -#@brief Script de carga de la API de funciones de OpenGNSys. -#@warning License: GNU GPLv3+ -#@version 0.9 -#@author Ramon Gomez, ETSII Universidad de Sevilla -#@date 2009-10-10 -#*/ - - GLOBAL="cat /proc/cmdline" - for i in `${GLOBAL}` - do - echo $i | grep "=" > /dev/null && export $i - done - - -# FIXME Temporal -export LANG="${LANG:-es_ES}" - -#/// Directorios del projecto OpenGNSys. -export OPENGNSYS="${OPENGNSYS:-/opt/opengnsys}" -if [ -d $OPENGNSYS ]; then - export OGBIN=$OPENGNSYS/bin - export OGETC=$OPENGNSYS/etc - export OGLIB=$OPENGNSYS/lib - export OGAPI=$OGLIB/engine/bin - export OGSCRIPTS=$OPENGNSYS/scripts - export OGIMG=$OPENGNSYS/images - export OGCAC=$OPENGNSYS/cache - export OGLOG=$OPENGNSYS/log - -# export PATH=$OGBIN:$OGAPI:$OGSCRIPTS:$PATH - # export LD_LIBRARY_PATH=$OGLIB:$LD_LIBRARY_PATH - - #/// Cargar fichero de idioma. - LANGFILE=$OGETC/lang.$LANG.conf - if [ -f $LANGFILE ]; then - source $LANGFILE - #for i in $(grep "^[a-zA-Z].*=" $LANGFILE | cut -f1 -d=); do - for i in $(awk -F= '{if (NF==2) print $1}' $LANGFILE); do - export $i - done - fi - #/// Cargar API de funciones. - echo "$MSG_LOADAPI" - for i in $OGAPI/*.lib; do - source $i - done - for i in $(typeset -F | cut -f3 -d" "); do - export -f $i - done - # Carga de las API testing - if [ "$engine" = "testing" ] - then - for i in $OGAPI/*.testing; do - source $i - done - fi - - source /tmp/net-eth* 2>/dev/null - - # Añadir dependencia de arquitectura - ARCH=$(ogGetArch) - if [ -n "$ARCH" ]; then - # export PATH=$OGBIN/$ARCH:$PATH - # export LD_LIBRARY_PATH=$OGLIB/$ARCH:$LD_LIBRARY_PATH - export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/opt/og2fs/2ndfs/opt/drbl/sbin - export PATH=$OGSCRIPTS:$PATH:$OGAPI:$OGBIN:$OGBIN/$ARCH - fi - # Fichero de registros. - export OGLOGFILE="$OGLOG/$(ogGetIpAddress).log" - # FIXME Pruebas para grupos de ordenadores - #export OGGROUP=$(ogGetGroup) - export OGGROUP=aula3 -fi - -#/// Declaración de códigos de error. -export OG_ERR_FORMAT=1 # Formato de ejecución incorrecto. -export OG_ERR_NOTFOUND=2 # Fichero o dispositivo no encontrado. -export OG_ERR_PARTITION=3 # Error en partición de disco. -export OG_ERR_LOCKED=4 # Partición o fichero bloqueado. -export OG_ERR_IMAGE=5 # Error al crear o restaurar una imagen. -export OG_ERR_NOTOS=6 # Sin sistema operativo. -export OG_ERR_NOTEXEC=7 # Programa o función no ejecutable. - - diff --git a/client/boot-tools/clientstructure/root/CompileSoftware.sh b/client/boot-tools/clientstructure/root/CompileSoftware.sh deleted file mode 100755 index 1a9b854a..00000000 --- a/client/boot-tools/clientstructure/root/CompileSoftware.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -################################################################ -##################### SOFTWARE ##################### -################################################################ -export LANGUAGE=C -export LC_ALL=C -export LANG=C - -#dpkg-divert --local --rename --add /sbin/initctl -#ln -s /bin/true /sbin/initctl - -apt-get -y update -# software to compile code -apt-get -y --force-yes install build-essential libattr* attr make m4 gettext libmhash-dev gdebi-core gawk - -source /opt/opengnsys/lib/engine/bin/ToolsGNU.c - -ctorrent install -udpcast install -#ntfs-3g install -ms-sys install - -wget -O partclone_0.2.16_i386.deb http://downloads.sourceforge.net/project/partclone/stable/0.2.16/partclone_0.2.16_i386.deb?use_mirror=ovh -gdebi -n partclone_0.2.16_i386.deb - - cd /tmp - wget http://damien.guibouret.free.fr/savepart.zip - unzip savepart.zip -d /sbin/ - - diff --git a/client/boot-tools/clientstructure/root/ConfFS.sh b/client/boot-tools/clientstructure/root/ConfFS.sh deleted file mode 100755 index 3e0f4b5c..00000000 --- a/client/boot-tools/clientstructure/root/ConfFS.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -dpkg-divert --local --rename --add /sbin/initctl -ln -s /bin/true /sbin/initctl -#mv /etc/fstab /etc/fstab.original 2>/dev/null -#mv /etc/mtab /etc/mtab.original 2>/dev/null - -#TODO: fichero etc/hosts -#TODO: fichero etc/resolv.conf -echo "ogClient" > /etc/hostname - -#export PASSROOT=og -#dpkg-reconfigure passwd -#echo "root:$PASSROOT" | chpasswd - - -#for i in pts/0 pts/1 pts/2 pts/3 do -# -# -#done -#TODO: introducir mas consoluas para el acceso como root. -echo "pts/0" >> /etc/securetty -echo "pts/1" >> /etc/securetty -echo "pts/2" >> /etc/securetty -echo "pts/3" >> /etc/securetty
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/root/InstallSoftware.sh b/client/boot-tools/clientstructure/root/InstallSoftware.sh deleted file mode 100755 index da8d8d06..00000000 --- a/client/boot-tools/clientstructure/root/InstallSoftware.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -################################################################ -##################### SOFTWARE ##################### -################################################################ -export LANGUAGE=C -export LC_ALL=C -export LANG=C - - -dpkg-divert --local --rename --add /sbin/initctl -ln -s /bin/true /sbin/initctl - -apt-get clean -apt-get -y update - - -# software system -apt-get -y --force-yes install linux-image-${OSRELEASE} linux-headers-${OSRELEASE} linux-image-$RELEASE wget dialog man-db htop fbset gdebi-core busybox-static - -apt-get -y --force-yes install console-data locales - -# sofware networking -apt-get -y --force-yes install netpipes nfs-common sshfs smbfs smbclient davfs2 unionfs-fuse open-iscsi nmap tcpdump arping dnsutils - -apt-get clean -# software services -apt-get -y --force-yes install openssh-server bittornado trickle iptraf screen schroot grub - -# software disk and filesystem -apt-get -y --force-yes install drbl-ntfsprogs ntfsprogs parted ntfs-3g dosfstools -apt-get -y --force-yes install dmraid dmsetup lvm2 e2fsprogs jfsutils reiserfsprogs xfsprogs unionfs-fuse mhddfs squashfs-tools -apt-get -y --force-yes install btrfs-tools hfsplus hfsprogs hfsutils nilfs-tools reiser4progs ufsutils - -# software cloning -apt-get -y --force-yes install drbl-partimage fsarchiver pv kexec-tools -apt-get -y --force-yes install mbuffer - - -apt-get clean -## software postconf -apt-get -y --force-yes install drbl-chntpw chntpw ethtool lshw gawk - -# software compressor -apt-get -y --force-yes install lzma zip unzip gzip lzop drbl-lzop pigz pbzip2 lbzip2 rzip p7zip-full unzip - -apt-get -y --force-yes remove busybox -apt-get -y --force-yes install busybox-static bash-static -apt-get clean -#apt-get -y --force-yes xorg-dev xorg lxde roxterm -# -#################################################################### -###################### Reconfigurando paquetes ###################### -################################################################### - - -#dpkg-reconfigure console-data -#dpkg-reconfigure console-setup -#dpkg-reconfigure locales -apt-get clean -##TODO################# Borrar algunos binarios del mkinitramfs - - diff --git a/client/boot-tools/clientstructure/root/qemu.sh b/client/boot-tools/clientstructure/root/qemu.sh deleted file mode 100755 index c5a93cd9..00000000 --- a/client/boot-tools/clientstructure/root/qemu.sh +++ /dev/null @@ -1,9 +0,0 @@ -#/bin/bash - -mount -o rw,remount / -mount proc /proc -t proc -export PATH=$PATH dpkg -i *.deb -modprobe 8139too -modprobe 8139cp -dhclient -/etc/init.d/ssh restart
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/etc/apt/sources.list.debian b/client/boot-tools/includes/etc/apt/sources.list.debian index 495e48d4..495e48d4 100644 --- a/client/boot-tools/clientstructure/etc/apt/sources.list.debian +++ b/client/boot-tools/includes/etc/apt/sources.list.debian diff --git a/client/boot-tools/clientstructure/etc/apt/sources.list.ubuntu b/client/boot-tools/includes/etc/apt/sources.list.ubuntu index 29348ccc..29348ccc 100644 --- a/client/boot-tools/clientstructure/etc/apt/sources.list.ubuntu +++ b/client/boot-tools/includes/etc/apt/sources.list.ubuntu diff --git a/client/boot-tools/clientstructure/etc/environment b/client/boot-tools/includes/etc/environment index bb529d99..bb529d99 100644 --- a/client/boot-tools/clientstructure/etc/environment +++ b/client/boot-tools/includes/etc/environment diff --git a/client/boot-tools/clientstructure/etc/fstab b/client/boot-tools/includes/etc/fstab index d7473df4..d7473df4 100644 --- a/client/boot-tools/clientstructure/etc/fstab +++ b/client/boot-tools/includes/etc/fstab diff --git a/client/boot-tools/clientstructure/etc/initramfs-tools/hooks/oghooks b/client/boot-tools/includes/etc/initramfs-tools/hooks/oghooks index 67f807ab..67f807ab 100755 --- a/client/boot-tools/clientstructure/etc/initramfs-tools/hooks/oghooks +++ b/client/boot-tools/includes/etc/initramfs-tools/hooks/oghooks diff --git a/client/boot-tools/clientstructure/etc/initramfs-tools/modules b/client/boot-tools/includes/etc/initramfs-tools/modules index 8bac1d4b..8bac1d4b 100644 --- a/client/boot-tools/clientstructure/etc/initramfs-tools/modules +++ b/client/boot-tools/includes/etc/initramfs-tools/modules diff --git a/client/boot-tools/includes/etc/initramfs-tools/scripts/ogfunctions b/client/boot-tools/includes/etc/initramfs-tools/scripts/ogfunctions new file mode 100644 index 00000000..773e4137 --- /dev/null +++ b/client/boot-tools/includes/etc/initramfs-tools/scripts/ogfunctions @@ -0,0 +1,669 @@ +#@file ogfunctions.lib +#@brief Librería o clase para la gestion del sistema operativo de los clientes OpenGnsys +#@class client +#@brief Librería o clase para la gestion del sistema operativo de los clientes OpenGnsys +#@version 0.91 +#@warning License: GNU GPLv3+ + +#/** +# ogExportKernelParameters +#@brief Exporta los parametros pasados al kernel +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.7 - +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#*/ ## +ogExportKernelParameters () +{ + GLOBAL="cat /proc/cmdline" + for i in `${GLOBAL}` + do + echo $i | grep "=" > /dev/null && export $i + done + return 0 +} + +#/** +# ogExportVarEnvironment +#@brief Exporta las variables usadas en el proceso de inicio OpenGnsys y las almacena en /tmp +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +#*/ ## +ogExportVarEnvironment () +{ + export CFGINITRD="/tmp/initrd.cfg" + OGPROTOCOL="${ogprotocol:-smb}" + case "$OGPROTOCOL" in + nfs|NFS) + export SRCOGLIVE="/var/lib/tftpboot" && echo "SRCOGLIVE=$SRCOGLIVE" >> $CFGINITRD + export SRCOGSHARE="/opt/opengnsys/client" && echo "SRCOGSHARE=$SRCOGSHARE" >> $CFGINITRD + export SRCOGLOG="/opt/opengnsys/log/clients" && echo "SRCOGLOG=$SRCOGLOG" >> $CFGINITRD + export SRCOGIMAGES="/opt/opengnsys/images" && echo "SRCOGIMAGES=$SRCOGIMAGES" >> $CFGINITRD + ;; + smb|SMB|cifs|CIFS|samba|SAMBA) + export OPTIONS=" -o user=opengnsys,pass=og" + export SRCOGLIVE="tftpboot" && echo "SRCOGLIVE=$SRCOGLIVE" >> $CFGINITRD + export SRCOGSHARE="ogclient" && echo "SRCOGSHARE=$SRCOGSHARE" >> $CFGINITRD + export SRCOGLOG="oglog" && echo "SRCOGLOG=$SRCOGLOG" >> $CFGINITRD + export SRCOGIMAGES="ogimages" && echo "SRCOGIMAGES=$SRCOGIMAGES" >> $CFGINITRD + ;; + local|LOCAL) + export SRCOGLIVE="local" + ;; + esac + #punto de acceso al boot-tools live + export DSTOGLIVE="/opt/oglive/tftpboot" + #punto de montaje para unionfs + export OGLIVERAMFS="/opt/oglive/ramfs" && echo "OGLIVERAMFS=$OGLIVERAMFS" >> $CFGINITRD + #punto de montaje donde se accede al 2nd FS mediante loop + export OGLIVEROOTFS="/opt/oglive/rootfs" && echo "OGLIVEROOTFS=$OGLIVEROOTFS" >> $CFGINITRD + #punto de union entre LOCALROOTIMG y LOCALROOTRAM + export OGLIVEUNIONFS="/opt/oglive/unionfs" && echo "OGLIVEUNIONFS=$OGLIVEUNIONFS" >> $CFGINITRD + #etiquta para los dispositivos offline + export OGLIVELABEL="ogClient" + + #echo "puntos de montajes para los demas accesos" + #echo "acceso al client, engine, scritps, interfaz" + export DSTOGSHARE="/opt/opengnsys" && echo "DSTOGSHARE=$DSTOGSHARE" >> $CFGINITRD + export DSTOGLOG="/opt/opengnsys/log" && echo "DSTOGLOG=$DSTOGLOG" >> $CFGINITRD + export DSTOGIMAGES="/opt/opengnsys/images" && echo "DSTOGIMAGES=$DSTOGIMAGES" >> $CFGINITRD + + ##INFORMACION DE OTRAS VARIABLES OBTENDIAS EN OTRAS FUNCIONES ogConfigureNetwork. + #DEVICE + #IPV4DDR + #IPV4BROADCAST + #IPV4NETMASK + #IPV4GATEWAY + #HOSTNAME + #INFORMACION de otras variasbles obteneidas desde ogGetROOTSERVER + #ROOTSERVER si ip=dhcp -> ROOTSERVER=NEXT-SERVER; si ip=host:rootserver:gw:mask:hostname:interfaz -> ROOTSERVER=rootserver + #BOOTIF -> si el gestor remoto es pxelinux.0 y se añade una linea más tipo "IPAPPEND 2" esta variable tendrá la mac de la interfaz. + #$OGSERVERLIVE + #$OGSERVERSHARE + #$OGSERVERLOG + #$OGSERVERIMAGES + return 0 +} + + +#/** +# ogConfigureRamfs +#@brief Configura el initrd para adaptarlo al sistema raiz. +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#*/ ## +ogConfigureRamfs () +{ + mkdir -p $DSTOGLIVE + mkdir -p $OGLIVERAMFS + mkdir -p $OGLIVEROOTFS + mkdir -p $OGLIVEUNIONFS +} + + +#/** +# ogLoadNetModule +#@brief Carga en un demerminado modulo de red, requiere compilación previo del modulo +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#*/ ## +ogLoadNetModule () +{ + if [ -n "$ognetmodule" ] + then + echo "Cargando modulo de red $netmodule" + insmod `find /lib/modules/ -name ${netmodule}*` + fi +} + + +#/** +# ogPostConfigureFS +#@brief Configura el sistema raiz, para independizarlo entre los clientes. +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#*/ ## +ogPostConfigureFS() +{ + # configuramos el /etc/hostname. + echo $HOSTNAME > /etc/hostname + + #configuramos el /etc/hosts + echo "127.0.0.1 localhost" > /etc/hosts + echo "$IPV4ADDR $HOSTNAME" >> /etc/hosts + + #configuramos el host.conf + echo "order hosts,bind" > /etc/host.conf + echo "multi on" >> /etc/host.conf + + #configuramos el dns + echo "nameserver $ogdns" > /etc/resolv.conf + + + # configuramos el /etc/networks + #read -e NETIP NETDEFAULT <<<$(route -n | grep eth0 | awk -F" " '{print $1}') + NETIP=$(route -n | grep eth0 | awk -F" " '{print $1}') && NETIP=$(echo $NETIP | cut -f1 -d" ") + echo "default 0.0.0.0" > /etc/networks + echo "loopback 127.0.0.0" >> /etc/networks + echo "link-local 169.254.0.0" >> /etc/networks + echo "localnet $NETIP" >> /etc/networks + #route + + #echo "ogLive1.0.2" > /etc/debian_chroot + + #enlace si iniciamos desde ogprotocolo=local { cdrom, usb, cache } . + # monta el raiz del dispositivo local en /opt/og2fs/tftpboot - acceso al fichero .sqfs + # y monta el sistema root sqfs en /opt/og2fs/2ndfs + [ "$LOCALMEDIA" == "CACHE" ] && ln -s $DSTOGLIVE /opt/opengnsys/cache + [ "$ogprotocol" == "local" ] && ln -s ${OGLIVEROOTFS}/opt/opengnsys/* /opt/opengnsys/ + + #Montamos un directorio temporal para el apt-get + mount tmpfs /var/cache/apt/archives -t tmpfs -o size=15M + mkdir -p /var/cache/apt/archives/partial + +} + + +#/** +# ogGetROOTSERVER +#@brief Determina los puntos de accesos a los distintos recursos. +#Requiere ogConfigureNetworking. +#Exporta ROOTSERVER +# si la red ha sido configurada con dhcp el valor de ROOTSERVER será el valor de next-server del dhcp +# si la red ha sido configurada con el parametro de kernel ip, será el segundo valor. +## ip=iphost:ipnext-server:ipgateway:netmask:hostname:iface:none +## ip=172.17.36.21:62.36.225.150:172.17.36.254:255.255.255.0:prueba1:eth0:none +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#*/ ## +ogGetROOTSERVER () +{ + # get nfs root from dhcp + if [ "x${NFSROOT}" = "xauto" ]; then + # check if server ip is part of dhcp root-path + if [ "${ROOTPATH#*:}" = "${ROOTPATH}" ]; then + NFSROOT=${ROOTSERVER}:${ROOTPATH} + else + NFSROOT=${ROOTPATH} + fi + + # nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] + elif [ -n "${NFSROOT}" ]; then + # nfs options are an optional arg + if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then + NFSOPTS="-o ${NFSROOT#*,}" + fi + NFSROOT=${NFSROOT%%,*} + if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then + NFSROOT=${ROOTSERVER}:${NFSROOT} + fi + fi + export ROOTSERVER + echo "ROOTSERVER=$ROOTSERVER" >> $CFGINITRD + + #si oglive no oglive=R + export OGSERVERIMAGES="${ogrepo:-$ROOTSERVER}" && echo "OGSERVERIMAGES=$OGSERVERIMAGES" >> $CFGINITRD + export OGSERVERSHARE="${ogshare:-$ROOTSERVER}" && echo "OGSERVERSHARE=$OGSERVERSHARE" >> $CFGINITRD + export OGSERVERLOG="${oglog:-$ROOTSERVER}" && echo "OGSERVERLOG=$OGSERVERLOG" >> $CFGINITRD + export OGSERVERLIVE="${oglive:-$OGSERVERIMAGES}" && echo "OGSERVERLIVE=$OGSERVERLIVE" >> $CFGINITRD + + return 0 +} + + + +# ogUpdateInitrd +#@brief Actualiza el intird de la cache desde el servidor. Si el arranque ha disdo desde cache, compueba desde el servidor nueva version del initird. +#@param1 +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +#*/ ## + +ogUpdateInitrd () +{ + cd /tmp + mkdir /tmp/cache + mount -t reiserfs LABEL=CACHE /tmp/cache || return + mkdir /tmp/cache/boot + + + # comparamos los del server + busybox tftp -g -r ogvmlinuz.sum $ROOTSERVER + busybox tftp -g -r oginitrd.img.sum $ROOTSERVER + SERVERVMLINUZ=`cat ogvmlinuz.sum` + SERVERINITRD=`cat oginitrd.img.sum` + + + #comparamos los de la cache + CACHEVMLINUZ=`cat /tmp/cache/boot/ogvmlinuz.sum` + CACHEINITRD=`cat /tmp/cache/boot/oginitrd.img.sum` + + echo "MD5 on SERVER: $SERVERVMLINUZ $SERVERINITRD" + echo "MD5 on CACHE: $CACHEVMLINUZ $CACHEINITRD" + + cd /tmp/cache/boot + + if [ "$CACHEVMLINUZ" != "$SERVERVMLINUZ" ] + then + echo "ogvmlinuz updating" + busybox tftp -g -r ogvmlinuz $ROOTSERVER + busybox tftp -g -r ogvmlinuz.sum $ROOTSERVER + DOREBOOT=true + fi + if [ "$CACHEINITRD" != "$SERVERINITRD" ] + then + echo "oginitrd updating" + busybox tftp -g -r oginitrd.img $ROOTSERVER + busybox tftp -g -r oginitrd.img.sum $ROOTSERVER + DOREBOOT=true + fi + + cd /; umount /tmp/cache + + [ "$DOREBOOT" == "true" ] && busybox reboot -f + +} + +#/** +# ogConnect +#@brief Conecta con los recursos necesarios para opengnsys +#@param1 ip del servidor TODO:dns +#@param2 protocolo +#@param3 punto de acceso remoto +#@param4 punto de montaje local +#@param5 acceso de lectura tipo ",ro" +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +#*/ ## + +ogConnect () +{ + SERVER=$1 + PROTOCOL=$2 + SRC=$3 + DST=$4 + READONLY=$5 + + case "$PROTOCOL" in + nfs) + nfsmount -o nolock${READONLY} ${SERVER}:${SRC} ${DST} + ;; + smb) + mount.cifs //${SERVER}/${SRC} ${DST} ${OPTIONS}${READONLY} + ;; + esac +} + + +#/** +# ogConnectOgLive +#@brief Conecta con el recurso para usar el sistema raiz externo, remoto o local +#@param1 +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +ogConnectOgLive () +{ +# Si ogprotocol=local, la funcion ogExportVar => SRCOGLIVE=local + if [ "$SRCOGLIVE" == "local" ] + then + echo "Montar imagen del sistema root desde dispositivo local" + for i in $(blkid /dev/s* | grep $OGLIVELABEL | awk -F: '{print $2}' | tr -d \"); do export $i; done + mount -t $TYPE LABEL=$LABEL $DSTOGLIVE + if [ $? != 0 ] + then + mount -t reiserfs LABEL=CACHE $DSTOGLIVE + export LOCALMEDIA=CACHE + fi + else +# Si ogprotocol es remoto. TODO en smb rw y en nfs ro?? + ogConnect $OGSERVERLIVE $OGPROTOCOL $SRCOGLIVE $DSTOGLIVE + fi +# Si el montaje ha sido correcto, tanto en local como en remoto. Procedemos con la union + ogMergeLive +} + + +#/** +# ogMergeLive +#@brief Metafuncion para fusionar el initrd con el sistema raiz. +#@param1 +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +ogMergeLive() +{ +#Si existe en el punto de acceso del del oglive el fichero ogclient.sqfs +if [ -f $DSTOGLIVE/ogclient/ogclient.sqfs ] +then + cat /proc/mounts > /tmp/mtab.preunion + if [ "$og2nd" == "img" ] + then + #Montamos el ROOTFS tipo img, para desarrolladores + #TODO: comprobar que se tiene acceso de escritura + losetup /dev/loop0 $DSTOGLIVE/ogclient/ogclient.img -o 32256 + mount /dev/loop0 $OGLIVEROOTFS + else + ## Montamos el ROOTFS tipo squashfs + mount $DSTOGLIVE/ogclient/ogclient.sqfs $OGLIVEROOTFS -t squashfs -o loop + fi +# Realizamos la union entre el ogliveram(initrd) y el ogliverootfs(ogclient.sqfs) + for i in etc var lib bin sbin usr root boot; do + ogUnionLiveDir $i + done + cat /tmp/mtab.preunion > /etc/mtab +else + echo "Fichero imagen del cliente no encontrado" + return 1 +fi +} + + + +#/** +# ogUnionLiveDir +#@brief fusiona dos directorios con unionfs +#@param1 +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +ogUnionLiveDir() +{ + TMPDIR=/$1 #dir + FUSE_OPT="-o default_permissions -o allow_other -o use_ino -o nonempty -o suid" + UNION_OPT="-o cow -o noinitgroups" + UBIN="unionfs-fuse" + + mkdir -p $OGLIVERAMFS$TMPDIR + U1STDIR="${OGLIVERAMFS}${TMPDIR}=RW" + U2NDDIR="${OGLIVEROOTFS}${TMPDIR}=RO" + UNIONDIR=${OGLIVEUNIONFS}${TMPDIR} + mkdir -p $UNIONDIR + $UBIN $FUSE_OPT $UNION_OPT ${U1STDIR}:${U2NDDIR} $UNIONDIR + mount --bind $UNIONDIR $TMPDIR +} + + + +#/** +# ogConfigureLoopback +#@brief Configura la interfaz loopback para cliente torrent +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 Usando funciones generales de ubuntu +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#@version 1.0.1 Deteccion automatica de interfaz con enlace activo. +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2011/05/24 +#*/ ## +ogConfigureLoopback() +{ + # for the portmapper we need localhost + ifconfig lo 127.0.0.1 + #/etc/init.d/portmap start +} + +#/** +# ogConfigureNetworking +#@brief Configura la interfaz de red usada en el pxe +#@param +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author Antonio J. Doblas. Universidad de Malaga. +#@date 2010/05/24 +#*/ ## +ogConfigureNetworking() +{ +#echo "ogConfigureNetworking: Buscando interfaz a configurar DEVICE" +if [ -n "${BOOTIF}" ] +then + #echo " variable BOOTIF exportada con pxelinux.0 con valor $BOOTIF" + IP=$IPOPTS + temp_mac=${BOOTIF#*-} + # convert to typical mac address format by replacing "-" with ":" + bootif_mac="" + IFS='-' + for x in $temp_mac ; do + if [ -z "$bootif_mac" ]; then + bootif_mac="$x" + else + bootif_mac="$x:$bootif_mac" + fi + done + unset IFS + # look for devices with matching mac address, and set DEVICE to + # appropriate value if match is found. + for device in /sys/class/net/* ; do + if [ -f "$device/address" ]; then + current_mac=$(cat "$device/address") + if [ "$bootif_mac" = "$current_mac" ]; then + DEVICE=${device##*/} + break + fi + fi + done +else + #echo "variable BOOTIF no exportada, intentamos detectar que interfaz se ha iniciado" + IP=$ip + #TODO Detectar que interfaz se ha iniciado + case ${IP} in + none|off) + return 0 + ;; + ""|on|any) + # Bring up device + DEVICE=eth0 + ;; + dhcp|bootp|rarp|both) + DEVICE=eth0 + ;; + *) + DEVICE=`echo $IP | cut -f6 -d:` + ;; + esac +fi +if [ -z "${DEVICE}" ]; then + echo "variable DEVICE con valor $DEVICE no encontrada, llamamos de nuevo a ogconfigure_networking" + ogConfigureNetworking +fi + +[ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ] && return 0 +#if [ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ]; then +# echo "variable DEVICE con valor $DEVICE y fichero /tmp/net-$DEVICE encontrados" +# return 0 +#else +# echo "variable DEVICE con valor $DEVICE encontrada, procedemos a configurala y a crear el fichero /tmp/net-$DEVICE" +#fi + +# Activamos la interfaz antes de configurar. +ip address flush $DEVICE +ip link set dev $DEVICE up +# Si no se detecta señal portadora volver a configurar. +sleep 1 +CARRIER=$(cat /sys/class/net/${DEVICE}/carrier) +if [ "$CARRIER" != "1" ] +then + ogConfigureNetworking +fi + +# support ip options see linux sources +# Documentation/filesystems/nfsroot.txt +# Documentation/frv/booting.txt +for ROUNDTTT in 2 3 4 6 9 16 25 36 64 100; do + # The NIC is to be configured if this file does not exist. + # Ip-Config tries to create this file and when it succeds + # creating the file, ipconfig is not run again. + if [ -e /tmp/net-"${DEVICE}".conf ]; then + break; + fi + case ${IP} in + none|off) + return 0 + ;; + ""|on|any) + # Bring up device + echo "Setting $DEVICE with option:on|any and Variable IP= $IP: ipconfig -t ${ROUNDTTT} ${DEVICE} " + ipconfig -t ${ROUNDTTT} ${DEVICE} + ;; + dhcp|bootp|rarp|both) + echo "Setting $DEVICE with option:dhcp|bootp|rarp|both and Variable IP= $IP: ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE} " + ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE} + ;; + *) + echo "Setting $DEVICE with option * and Variable IP= $IP: ipconfig -t ${ROUNDTTT} -d $IP " + ipconfig -t ${ROUNDTTT} -d $IP + # grab device entry from ip option + NEW_DEVICE=${IP#*:*:*:*:*:*} + if [ "${NEW_DEVICE}" != "${IP}" ]; then + NEW_DEVICE=${NEW_DEVICE%:*} + else + # wrong parse, possibly only a partial string + NEW_DEVICE= + fi + if [ -n "${NEW_DEVICE}" ]; then + DEVICE="${NEW_DEVICE}" + fi + ;; + esac +done + +# source ipconfig output +if [ -n "${DEVICE}" ]; then + . /tmp/net-${DEVICE}.conf + DEVICECFG="/tmp/net-${DEVICE}.conf" + export DEVICECFG + export DEVICE + echo "DEVICE=$DEVICE" >> $CFGINITRD + echo "DEVICECFG=$DEVICECFG" >> $CFGINITRD + echo "exportando variable DEVICE con valor = $DEVICE y el DEVICECFG con valor $DEVICECFG" +else + # source any interface as not exaclty specified + . /tmp/net-*.conf +fi +} + + +#/** +# ogYesNo +#@brief Gestion de peticiones de usuario en modo ogdebug=true +#@param1 OPTIONS --timeout N --default ANSWER +#@param1 Questions +#@return 1=yes 0=no +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 0.9 +#@author: +#@date 2010/05/24 +#*/ ## +ogYesNo() +{ + local ans + local ok=0 + local timeout=0 + local default + local t + + while [[ "$1" ]] + do + case "$1" in + --default) + shift + default=$1 + if [[ ! "$default" ]]; then error "Missing default value"; fi + t=$(echo $default | tr '[:upper:]' '[:lower:]') + + if [[ "$t" != 'y' && "$t" != 'yes' && "$t" != 'n' && "$t" != 'no' ]]; then + error "Illegal default answer: $default" + fi + default=$t + shift + ;; + + --timeout) + shift + timeout=$1 + if [[ ! "$timeout" ]]; then error "Missing timeout value"; fi + #if [[ ! "$timeout" =~ ^[0-9][0-9]*$ ]]; then error "Illegal timeout value: $timeout"; fi + shift + ;; + + -*) + error "Unrecognized option: $1" + ;; + + *) + break + ;; + esac + done + + if [[ $timeout -ne 0 && ! "$default" ]]; then + error "Non-zero timeout requires a default answer" + fi + + if [[ ! "$*" ]]; then error "Missing question"; fi + + while [[ $ok -eq 0 ]] + do + if [[ $timeout -ne 0 ]]; then + if ! read -t $timeout -p "$*" ans; then + ans=$default + else + # Turn off timeout if answer entered. + timeout=0 + if [[ ! "$ans" ]]; then ans=$default; fi + fi + else + read -p "$*" ans + if [[ ! "$ans" ]]; then + ans=$default + else + ans=$(echo $ans | tr '[:upper:]' '[:lower:]') + fi + fi + + if [[ "$ans" == 'y' || "$ans" == 'yes' || "$ans" == 'n' || "$ans" == 'no' ]]; then + ok=1 + fi + + if [[ $ok -eq 0 ]]; then warning "Valid answers are: yes y no n"; fi + done + [[ "$ans" = "y" || "$ans" == "yes" ]] +} + diff --git a/client/boot-tools/clientstructure/etc/initramfs-tools/scripts/oginit b/client/boot-tools/includes/etc/initramfs-tools/scripts/oginit index d91afaee..cc179f9f 100755 --- a/client/boot-tools/clientstructure/etc/initramfs-tools/scripts/oginit +++ b/client/boot-tools/includes/etc/initramfs-tools/scripts/oginit @@ -3,25 +3,30 @@ #@file oginit #@brief Guion modificador inicio initrd para OpenGnSys #@warning -#@version 0.1 - basado en ROOTfs +#@version 0.1 - basado en ROOTfs - rootfs over nfs - #@author Antonio J. Doblas Viso. Universidad de Málaga #@date 2009/00/00 -#@version 0.2 - basado en el instalador de ubunto -#@author Alejandro Castillo -#@author Ramón Gómez -#@author Irina -#@author Antonio Doblas +#@version 0.2 - basado en RAMFS - instalador de ubunto - +#@author Alejandro Castillo, Ramón Gómez, Irina, Antonio Doblas #@date 2010/00/00 -#@version 0.7 - Generación limpia con mkinitrd, busybox +#@version 0.7 - Hibrido en RAMFS + ROOTFS -mkinitrd, busybox, deboostrap- #@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT. #@date 2010/05/24 -#@version 0.8 - Integración con FileSystem externo +#@version 0.8 - Soporte smb, asignación ip estática #@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT. #@date 2010/06/24 -#@version 0.8.1 - UnionFS + squasfs +#@version 0.8.1 - Integración RAMFS+ROOTFS con UnionFS y squasfs #@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT. #@date 2010/06/29 - +#@version 1.0. - Adaptacion variables. Corrección enlace red +#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT. +#@date 2011/06/16 +#@version 1.0.1 - Logica para inicio multiples dispositivos, usb, red, cd +#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT. +#@date 2011/07/4 +#@version 1.0.2 - RAMFS: instalación y actualización automatica en cache +#@author Antonio J. Doblas Viso. Universidad de Málaga. EVLT. +#@date 2011/08/4 #*/ @@ -45,8 +50,6 @@ mountroot () [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before get OG variables: y/N " [ $? == 0 ] && sh || echo " " - - set -a log_success_msg "Checking kernel parameters" ogExportKernelParameters @@ -67,30 +70,40 @@ mountroot () [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before configure networking: y/N " [ $? == 0 ] && sh || echo " " - ogconfigure_networking + ogConfigureNetworking log_success_msg "config networking" - ogconfigure_lo + ogConfigureLoopback log_success_msg "config loopback" [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before detect rootserver: y/N " [ $? == 0 ] && sh || echo " " - ogGetROOTSERVER && log_success_msg "Get Info from pxe server" - - [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before conect with og Services : y/N " - [ $? == 0 ] && sh || echo " " - ogConectROOTSERVER && log_success_msg "Conecting with og services" || sh - # ogConectROOTMEDIA + ogGetROOTSERVER && log_success_msg "Get Info from pxe server and ckeck distribuited OG services " - [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before merge the Second File System with initrd (First File System) : y/N " - [ $? == 0 ] && sh || echo " " - ogMerge2ndFile && log_success_msg "Merge onto Second File System" + if [ "$ogdebug" == "true" -a "$ogupdateinitrd" == "true" ]; then + ogYesNo --timeout 5 --default no "Stop before check updating initrd: y/N " + [ $? == 0 ] && sh || echo " " + fi + [ "$ogupdateinitrd" == "true" ] && ogUpdateInitrd - #[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/og-bottom" - #run_scripts /scripts/og-bottom - #[ "$quiet" != "y" ] && log_end_msg + [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before connect and merging the rootfs -ogLive- with $OGSERVERLIVE: y/N " + [ $? == 0 ] && sh || echo " " + ogConnectOgLive && log_success_msg "Merge the initrd with the remote rootfs -ogLive- on $OGSERVERLIVE" || sh + # si es necesario realiza ogConnect $OGSERVERLIVE $OGPROTOCOL $SRCOGLIVE $DSTOGLIVE + [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before connect with client dir SHARE -engine,scripts,interface, -share- on $OGSERVERSHARE : y/N " + [ $? == 0 ] && sh || echo " " + ogConnect $OGSERVERSHARE $OGPROTOCOL $SRCOGSHARE $DSTOGSHARE + + [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before connect with client dir LOG STORAGE on $OGSERVERLOG : y/N " + [ $? == 0 ] && sh || echo " " + ogConnect $OGSERVERLOG $OGPROTOCOL $SRCOGLOG $DSTOGLOG + + [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before connect with REPOSITORY STORAGE on $OGSERVERIMAGES : y/N " + [ $? == 0 ] && sh || echo " " + ogConnect $OGSERVERIMAGES $OGPROTOCOL $SRCOGIMAGES $DSTOGIMAGES + [ "$ogdebug" == "true" ] && ogYesNo --timeout 5 --default no "Stop before doing the postconfiguration: y/N " [ $? == 0 ] && sh || echo " " diff --git a/client/boot-tools/clientstructure/etc/inittab b/client/boot-tools/includes/etc/inittab index 6d3277fc..6d3277fc 100644 --- a/client/boot-tools/clientstructure/etc/inittab +++ b/client/boot-tools/includes/etc/inittab diff --git a/client/boot-tools/clientstructure/etc/modprobe.d/blacklist-framebuffer.conf b/client/boot-tools/includes/etc/modprobe.d/blacklist-framebuffer.conf index 8b047e4e..8b047e4e 100644 --- a/client/boot-tools/clientstructure/etc/modprobe.d/blacklist-framebuffer.conf +++ b/client/boot-tools/includes/etc/modprobe.d/blacklist-framebuffer.conf diff --git a/client/boot-tools/clientstructure/etc/mtab b/client/boot-tools/includes/etc/mtab index e69de29b..e69de29b 100644 --- a/client/boot-tools/clientstructure/etc/mtab +++ b/client/boot-tools/includes/etc/mtab diff --git a/client/boot-tools/clientstructure/etc/network/interfaces b/client/boot-tools/includes/etc/network/interfaces index dbe43582..dbe43582 100644 --- a/client/boot-tools/clientstructure/etc/network/interfaces +++ b/client/boot-tools/includes/etc/network/interfaces diff --git a/client/boot-tools/includes/etc/profile.d/loadenviron.sh b/client/boot-tools/includes/etc/profile.d/loadenviron.sh new file mode 100755 index 00000000..e2ad0144 --- /dev/null +++ b/client/boot-tools/includes/etc/profile.d/loadenviron.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +### NOTA este archivo se debe de copiar desde el fichero etc/init/default + diff --git a/client/boot-tools/includes/etc/securetty.template b/client/boot-tools/includes/etc/securetty.template new file mode 100644 index 00000000..491d8f52 --- /dev/null +++ b/client/boot-tools/includes/etc/securetty.template @@ -0,0 +1,142 @@ +# /etc/securetty: list of terminals on which root is allowed to login. +# See securetty(5) and login(1). +console + + +pts/0 +pts/1 +pts/2 +pts/3 + + +# Standard serial ports +ttyS0 +ttyS1 +ttyS2 +ttyS3 +ttyS4 +ttyS5 + +# USB dongles +ttyUSB0 +ttyUSB1 +ttyUSB2 + +# PowerMac +ttyPZ0 +ttyPZ1 +ttyPZ2 +ttyPZ3 + +# Embedded MPC platforms +ttyPSC0 +ttyPSC1 +ttyPSC2 +ttyPSC3 +ttyPSC4 +ttyPSC5 + +# PA-RISC mux ports +ttyB0 +ttyB1 + +# Standard hypervisor virtual console +hvc0 + +# Oldstyle Xen console +xvc0 + +# Standard consoles +tty1 +tty2 +tty3 +tty4 +tty5 +tty6 +tty7 +tty8 +tty9 +tty10 +tty11 +tty12 +tty13 +tty14 +tty15 +tty16 +tty17 +tty18 +tty19 +tty20 +tty21 +tty22 +tty23 +tty24 +tty25 +tty26 +tty27 +tty28 +tty29 +tty30 +tty31 +tty32 +tty33 +tty34 +tty35 +tty36 +tty37 +tty38 +tty39 +tty40 +tty41 +tty42 +tty43 +tty44 +tty45 +tty46 +tty47 +tty48 +tty49 +tty50 +tty51 +tty52 +tty53 +tty54 +tty55 +tty56 +tty57 +tty58 +tty59 +tty60 +tty61 +tty62 +tty63 + +# Local X displays (allows empty passwords with pam_unix's nullok_secure) +:0 +:0.0 +:0.1 +:1 +:1.0 +:1.1 +:2 +:2.0 +:2.1 +:3 +:3.0 +:3.1 + +# Embedded Freescale i.MX ports +ttymxc0 +ttymxc1 +ttymxc2 +ttymxc3 +ttymxc4 +ttymxc5 + +# Embedded Renesas SuperH ports +ttySC0 +ttySC1 +ttySC2 +ttySC3 +ttySC4 +ttySC5
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/etc/ssh/ssh_config b/client/boot-tools/includes/etc/ssh/ssh_config index 7f9319dc..7f9319dc 100644 --- a/client/boot-tools/clientstructure/etc/ssh/ssh_config +++ b/client/boot-tools/includes/etc/ssh/ssh_config diff --git a/client/boot-tools/clientstructure/etc/ssh/sshd_config b/client/boot-tools/includes/etc/ssh/sshd_config index 80900684..80900684 100644 --- a/client/boot-tools/clientstructure/etc/ssh/sshd_config +++ b/client/boot-tools/includes/etc/ssh/sshd_config diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/box.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/box.png Binary files differnew file mode 100644 index 00000000..54876e68 --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/box.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/bullet.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/bullet.png Binary files differnew file mode 100644 index 00000000..dd527369 --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/bullet.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/entry.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/entry.png Binary files differnew file mode 100644 index 00000000..a9f4157b --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/entry.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/lock.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/lock.png Binary files differnew file mode 100644 index 00000000..a0f8c12f --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/lock.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/logoopengnsys.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/logoopengnsys.png Binary files differnew file mode 100644 index 00000000..c87ca25e --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/logoopengnsys.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.plymouth b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.plymouth new file mode 100644 index 00000000..a974b70c --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.plymouth @@ -0,0 +1,11 @@ +[Plymouth Theme] +Name=Script +Description=Script example plugin. +ModuleName=script + +[script] +ImageDir=/lib/plymouth/themes/opengnsys +ScriptFile=/lib/plymouth/themes/opengnsys/opengnsys.script + +[script-env-vars] +example_env_var=example env var value diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.png Binary files differnew file mode 100644 index 00000000..c87ca25e --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.script b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.script new file mode 100644 index 00000000..dc0c8541 --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/opengnsys.script @@ -0,0 +1,203 @@ +# This is an example plymouth plugin script + +Window.SetBackgroundTopColor(0, 0, 0); +Window.SetBackgroundBottomColor(0, 0, 0); + +#logo.image = Image("special://logo"); +logo.image = Image ("opengnsys.png"); +logo.sprite = Sprite(logo.image); +logo.opacity_angle = 0; + +fun refresh_callback () + { + if (status == "normal") + { + logo.opacity_angle += ((2 * 3.14) / 50) * 0.5; # 0.5 HZ + min_opacity = 0.3; + opacity = (Math.Cos(logo.opacity_angle) + 1) / 2; + opacity *= 1 - min_opacity; + opacity += min_opacity; + logo.sprite.SetX (Window.GetX() + Window.GetWidth() / 2 - logo.image.GetWidth() / 2); + logo.sprite.SetY (Window.GetY() + Window.GetHeight() / 2 - logo.image.GetHeight() / 2); + logo.sprite.SetOpacity (opacity); + } + else + { + logo.sprite.SetX (0); + logo.sprite.SetY (0); + logo.sprite.SetOpacity (1); + } + } + +Plymouth.SetRefreshFunction (refresh_callback); + +#----------------------------------------- Dialogue -------------------------------- + +status = "normal"; + +fun dialog_setup() + { + local.box; + local.lock; + local.entry; + + box.image = Image("box.png"); + lock.image = Image("lock.png"); + entry.image = Image("entry.png"); + + box.sprite = Sprite(box.image); + box.x = Window.GetX() + Window.GetWidth() / 2 - box.image.GetWidth ()/2; + box.y = Window.GetY() + Window.GetHeight() / 2 - box.image.GetHeight()/2; + box.z = 10000; + box.sprite.SetPosition(box.x, box.y, box.z); + + lock.sprite = Sprite(lock.image); + lock.x = box.x + box.image.GetWidth()/2 - (lock.image.GetWidth() + entry.image.GetWidth()) / 2; + lock.y = box.y + box.image.GetHeight()/2 - lock.image.GetHeight()/2; + lock.z = box.z + 1; + lock.sprite.SetPosition(lock.x, lock.y, lock.z); + + entry.sprite = Sprite(entry.image); + entry.x = lock.x + lock.image.GetWidth(); + entry.y = box.y + box.image.GetHeight()/2 - entry.image.GetHeight()/2; + entry.z = box.z + 1; + entry.sprite.SetPosition(entry.x, entry.y, entry.z); + + global.dialog.box = box; + global.dialog.lock = lock; + global.dialog.entry = entry; + global.dialog.bullet_image = Image("bullet.png"); + dialog_opacity (1); + } + +fun dialog_opacity(opacity) + { + dialog.box.sprite.SetOpacity (opacity); + dialog.lock.sprite.SetOpacity (opacity); + dialog.entry.sprite.SetOpacity (opacity); + for (index = 0; dialog.bullet[index]; index++) + { + dialog.bullet[index].sprite.SetOpacity(opacity); + } + } + +fun display_normal_callback () + { + global.status = "normal"; + if (global.dialog) + dialog_opacity (0); + } + +fun display_password_callback (prompt, bullets) + { + global.status = "password"; + if (!global.dialog) + dialog_setup(); + else + dialog_opacity(1); + for (index = 0; dialog.bullet[index] || index < bullets; index++) + { + if (!dialog.bullet[index]) + { + dialog.bullet[index].sprite = Sprite(dialog.bullet_image); + dialog.bullet[index].x = dialog.entry.x + index * dialog.bullet_image.GetWidth(); + dialog.bullet[index].y = dialog.entry.y + dialog.entry.image.GetHeight() / 2 - dialog.bullet_image.GetHeight() / 2; + dialog.bullet[index].z = dialog.entry.z + 1; + dialog.bullet[index].sprite.SetPosition(dialog.bullet[index].x, dialog.bullet[index].y, dialog.bullet[index].z); + } + if (index < bullets) + dialog.bullet[index].sprite.SetOpacity(1); + else + dialog.bullet[index].sprite.SetOpacity(0); + } + } + +Plymouth.SetDisplayNormalFunction(display_normal_callback); +Plymouth.SetDisplayPasswordFunction(display_password_callback); + +#----------------------------------------- Progress Bar -------------------------------- + +progress_box.original_image = Image("progress_box.png"); +progress_box.image = progress_box.original_image.Scale(Window.GetWidth (), progress_box.original_image.GetHeight()); +progress_box.sprite = Sprite(progress_box.image); + +progress_box.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; +progress_box.y = Window.GetY() + Window.GetHeight() - progress_box.image.GetHeight(); +progress_box.sprite.SetPosition(progress_box.x, progress_box.y, 0); + +progress_bar.original_image = Image("progress_bar.png"); +progress_bar.image = progress_bar.original_image.Scale(0, progress_box.image.GetHeight()); +progress_bar.sprite = Sprite(); + +progress_bar.x = Window.GetX() + Window.GetWidth() / 2 - progress_box.image.GetWidth() / 2; +progress_bar.y = Window.GetY() + Window.GetHeight() - progress_box.image.GetHeight(); +progress_bar.sprite.SetPosition(progress_bar.x, progress_bar.y, 1); + +fun progress_callback (duration, progress) + { + if (progress_bar.image.GetWidth () != Math.Int (progress_bar.original_image.GetWidth () * progress)) + { + progress_bar.image = progress_bar.original_image.Scale(progress_box.image.GetWidth(progress_box.image) * progress, progress_box.image.GetHeight()); + progress_bar.sprite.SetImage (progress_bar.image); + } + } + +Plymouth.SetBootProgressFunction(progress_callback); + +#----------------------------------------- Quit -------------------------------- + +fun quit_callback () +{ + logo.sprite.SetOpacity (1); +} + +Plymouth.SetQuitFunction(quit_callback); + +#----------------------------------------- Message -------------------------------- + +message_sprite = Sprite(); +message_sprite.SetPosition(10, 10, 10000); + +fun message_callback (text) +{ + my_image = Image.Text(text, 0.6, 0.6, 0.6); + message_sprite.SetImage(my_image); + message_sprite.SetX(Window.GetWidth () / 2 - my_image.GetWidth() / 2); + message_sprite.SetY((Window.GetHeight () * 0.7) - (2 * my_image.GetHeight())); + message.sprite.SetZ(11); +} + +Plymouth.SetMessageFunction(message_callback); + + +#----------------------------------------- Status Update -------------------------------- + +statusupdate_sprite = Sprite(); + +fun StringLength(string) { + + index = 0; + str = String(string); + while(str.CharAt(index)) index++; + return index; +} + +fun status_callback (text) +{ + // Truncate the message if too long + if (StringLength(text) > (Window.GetHeight () / 4 )) { + text = text.SubString(0, (Window.GetHeight () / 4 ) - 3); + text += "..."; + } + + my_image = Image.Text(text, 0.4, 0.4, 0.4); + statusupdate_sprite.SetPosition(10, 10 + (i * 20), 10000); + statusupdate_sprite.SetImage(my_image); + statusupdate_sprite.SetX(Window.GetWidth () / 2 - my_image.GetWidth() / 2); + statusupdate_sprite.SetY((Window.GetHeight () * 0.7) - my_image.GetHeight()); + statusupdate.sprite.SetZ(11); +} + +Plymouth.SetUpdateStatusFunction(status_callback); + + diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/progress_bar.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/progress_bar.png Binary files differnew file mode 100644 index 00000000..fad2e3f9 --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/progress_bar.png diff --git a/client/boot-tools/includes/lib/plymouth/themes/opengnsys/progress_box.png b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/progress_box.png Binary files differnew file mode 100644 index 00000000..bdc029e1 --- /dev/null +++ b/client/boot-tools/includes/lib/plymouth/themes/opengnsys/progress_box.png diff --git a/client/boot-tools/includes/usr/bin/boot-tools/boottoolsBootGraphics.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsBootGraphics.sh new file mode 100644 index 00000000..edd0dc00 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsBootGraphics.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#TODO Comprobar si esta los source. +#svn checkout http://www.opengnsys.es/svn/branches/version1.0/client /tmp/opengnsys_installer/opengnsys/client/; +#svn checkout http://www.opengnsys.es/svn/branches/version2/ /tmp/opengnsys_installer/opengnsys2 +find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null; + +#plymouth +apt-get -y install plymouth plymouth-theme-script + + +#plymoutyh +update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth 100 +update-alternatives --set default.plymouth /lib/plymouth/themes/opengnsys/opengnsys.plymouth + +mkdir -p /etc/initramfs-tools/conf.d +echo "FRAMEBUFFER=y" > /etc/initramfs-tools/conf.d/splash + +history -c
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/root/ReconfigureLocales.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsLocales.sh index 5480d141..63d36943 100755 --- a/client/boot-tools/clientstructure/root/ReconfigureLocales.sh +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsLocales.sh @@ -1,4 +1,6 @@ #!/bin/bash dpkg-reconfigure console-data dpkg-reconfigure console-setup -dpkg-reconfigure locales
\ No newline at end of file +dpkg-reconfigure locales + +history -c
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh new file mode 100644 index 00000000..21b7a54d --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsOpengnsys.sh @@ -0,0 +1,124 @@ +#!/bin/bash +#TODO Comprobar si esta los source. + +#svn checkout http://www.opengnsys.es/svn/branches/version1.0/client /tmp/opengnsys_installer/opengnsys/client/; +#svn checkout http://www.opengnsys.es/svn/branches/version2/ /tmp/opengnsys_installer/opengnsys2 +find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null; + +apt-get -y --force-yes install subversion +export SVNURL="http://opengnsys.es/svn/branches/version1.0/client/" +VERSIONSVN=$(LANG=C svn info $SVNURL | awk '/Revision:/ {print "r"$2}') + +VERSIONBOOTTOOLS=ogLive + +NAMEISOCLIENT="/tmp/opengnsys_info_rootfs" +NAMEHOSTCLIENT="/tmp/opengnsys_chroot" + +SVNCLIENTDIR=/tmp/opengnsys_installer/opengnsys/client/boot-tools +SVNCLIENTSTRUCTURE=/tmp/opengnsys_installer/opengnsys/client/shared +SVNCLIENTENGINE=/tmp/opengnsys_installer/opengnsys/client/engine +SVNOG2=/tmp/opengnsys_installer/opengnsys2 + +OGCLIENTMOUNT="" + + +OSDISTRIB=$(lsb_release -i | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null +OSCODENAME=$(cat /etc/lsb-release | grep CODENAME | awk -F= '{print $NF}') +OSRELEASE=$(uname -a | awk '{print $3}') +uname -a | grep x86_64 > /dev/null && export OSARCH=amd64 || export OSARCH=i386 +OSHTTP="http://es.archive.ubuntu.com/ubuntu/" + +echo $OSDISTRIB:$OSCODENAME:$OSRELEASE:$OSARCH:$OSHTTP + + +LERROR=TRUE + +echo "$FUNCNAME: Iniciando la personalización con datos del SVN " + +# parseamos del apt.source +sed -e "s/OSCODENAME/$OSCODENAME/g" ${SVNCLIENTDIR}/includes/etc/apt/sources.list.ubuntu > ${SVNCLIENTDIR}/includes/etc/apt/sources.list +if [ $? -ne 0 ] +then + echo "$FUNCNAME(): Parsing apt.sources : ERROR" + exit 1 +fi + + + +#damos permiso al directorio de scripts +chmod -R 775 ${SVNCLIENTDIR}/includes/usr/bin/* + +# los copiamos +cp -prv ${SVNCLIENTDIR}/includes/* / +mkdir -p ${OGCLIENTMOUNT}/opt/opengnsys/ +cp -prv ${SVNCLIENTSTRUCTURE}/* ${OGCLIENTMOUNT}/opt/opengnsys/ +cp -prv ${SVNCLIENTENGINE}/* ${OGCLIENTMOUNT}/opt/opengnsys/lib/engine/bin/ + +if [ $? -ne 0 ] +then + echo "$FUNCNAME(): Copying client data : ERROR" + exit 1 +fi + +# copiamos algunas cosas del nfsexport + +#### Tipos de letra para el Browser. +cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/lib/fonts +#### Crear enlaces para compatibilidad con las distintas versiones del Browser. +mkdir -p $OGCLIENTMOUNT/usr/local/Trolltech/QtEmbedded-4.5.1/lib/ +mkdir -p $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.2/lib/ +mkdir -p $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.3/lib/ +cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/Trolltech/QtEmbedded-4.5.1/lib/fonts +cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.2/lib/fonts +cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.3/lib/fonts +if [ $? -ne 0 ] +then + echo "$FUNCNAME(): Linking Browser fonts : ERROR" + exit 1 +fi + +######################################################### +cp -pr ${SVNCLIENTSTRUCTURE}/lib/pci.ids $OGCLIENTMOUNT/etc +if [ $? -ne 0 ] +then + echo "$FUNCNAME(): Copying pci.ids : ERROR" + exit 1 +fi +####### Browsser +cp ${SVNCLIENTSTRUCTURE}/bin/browser $OGCLIENTMOUNT/bin +if [ $? -ne 0 ] +then + echo "$FUNCNAME(): Copying Browser : ERROR" + exit 1 +fi + + +#Compatiblidad con og2 +cp ${SVNCLIENTSTRUCTURE}/bin/browser2 $OGCLIENTMOUNT/bin + +cp -prv ${SVNOG2}/ogr/ogr $OGCLIENTMOUNT/opt/opengnsys/bin/ + +cp -prv ${SVNOG2}/ogr/libogr.py $OGCLIENTMOUNT/usr/lib/python2.7/libogr.py +cp -prv ${SVNOG2}/ogr/libogr.py $OGCLIENTMOUNT/usr/lib/python2.6/libogr.py +cp -prv ${SVNOG2}/ogr/libogr.py $OGCLIENTMOUNT/opt/opengnsys/lib/python + + +echo "mkdir -p /opt/opengnsys/lib/engine/" +mkdir -p /opt/opengnsys/engine/ +echo "cp -prv ${SVNOG2}/engine/2.0/* $OGCLIENTMOUNT/opt/opengnsys/engine/" +cp -prv ${SVNOG2}/engine/2.0/* $OGCLIENTMOUNT/opt/opengnsys/engine/ + + +cp -prv ${SVNOG2}/job_executer $OGCLIENTMOUNT/opt/opengnsys/bin/ + + +cp ${SVNCLIENTSTRUCTURE}/bin/ogAdmClient $OGCLIENTMOUNT/bin + + +echo ${VERSIONBOOTTOOLS}-${OSCODENAME}-${OSRELEASE}-${VERSIONSVN} > $NAMEISOCLIENT +echo ${VERSIONBOOTTOOLS}-${OSCODENAME}-${VERSIONSVN} > $NAMEHOSTCLIENT +echo ${VERSIONBOOTTOOLS}-${OSCODENAME}-${VERSIONSVN} > /etc/debian_chroot +echo ${VERSIONBOOTTOOLS}-${OSCODENAME}-${VERSIONSVN} > /etc/opengnsys_chroot + +history -c + diff --git a/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh new file mode 100755 index 00000000..140cffb9 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsFsPostconfiguration.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + + +history -c
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/root/GenerateInitrd.generic.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsInitrdGenerate.sh index eaeb475b..fe9fe4ff 100755 --- a/client/boot-tools/clientstructure/root/GenerateInitrd.generic.sh +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsInitrdGenerate.sh @@ -13,4 +13,6 @@ rm * cp /bin/busybox ./ cd /tmp/ mkinitramfs -o /tmp/initrd.img-$OSRELEASE -v $OSRELEASE -cp /boot/vmlinuz-$OSRELEASE /tmp
\ No newline at end of file +cp /boot/vmlinuz-$OSRELEASE /tmp + +history -c
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareCompile.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareCompile.sh new file mode 100755 index 00000000..568548f2 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareCompile.sh @@ -0,0 +1,32 @@ +#!/bin/bash +################################################################ +##################### SOFTWARE ##################### +################################################################ +export LANGUAGE=C +export LC_ALL=C +export LANG=C + + +source /opt/opengnsys/lib/engine/bin/ToolsGNU.c &>/dev/null +cd /tmp + +echo "ctorrent " +which ctorrent || ctorrent install &>/dev/null + +echo "udp-sender " +which udp-sender || udpcast install &>/dev/null + +echo "ms-sys " +which ms-sys || ms-sys install &>/dev/null + +echo "echo partclone " +#which partclone.ntfs || $(wget -O partclone_0.2.16_i386.deb http://downloads.sourceforge.net/project/partclone/stable/0.2.16/partclone_0.2.16_i386.deb?use_mirror=ovh &>/dev/null; gdebi -n partclone_0.2.16_i386.deb &>/dev/null) +which partclone.ntfs || gdebi -n /var/cache/apt/archivesOG/partclone_0.2.8_i386.deb + +echo "spartlnx" +which spartlnx.run || $(wget http://damien.guibouret.free.fr/savepart.zip &>/dev/null; unzip -o savepart.zip -d /sbin/) + +echo "xvesa" +gdebi -n /var/cache/apt/archivesOG/xvesa.deb + +history -c
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh new file mode 100755 index 00000000..9af72199 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareInstall.sh @@ -0,0 +1,69 @@ +#!/bin/bash +export LANGUAGE=C +export LC_ALL=C +export LANG=C +#LOG_FILE=/tmp/boot-tools-software.txt + +#Desactivamos upstart +dpkg-divert --local --rename --add /sbin/initctl +ln -s /bin/true /sbin/initctl + +#cp /tmp/sources.list /etc/apt/sources.list +#Limpiamos y actualizamos los repositorios apt +apt-get clean +apt-get update + +#Desactivamos el hook del oginitrd.img para evitar problemas. +mv /etc/initramfs-tools/hooks/oghooks /etc/initramfs-tools/ + +echo " /dev/sda1 / ext4 rw,errors=remount-ro 0 0 " > /etc/mtab + + +#Instalamos el kernel. +export OSDISTRIB=$(lsb_release -i | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null +export OSCODENAME=$(cat /etc/lsb-release | grep CODENAME | awk -F= '{print $NF}') +export OSRELEASE=$(uname -a | awk '{print $3}') +uname -a | grep x86_64 > /dev/null && export OSARCH=amd64 || export OSARCH=i386 +export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" +# software Kernel +apt-get -y --force-yes install linux-image-${OSRELEASE} linux-headers-${OSRELEASE} linux-image-$RELEASE + +#Eliminamos cualquier busybox previo: antes del busybox. +apt-get -y --force-yes remove busybox + +#estos paquetes ofrecen interaccion. +# si es actualización, ya existe el fichero /etc/ssh/ssh_config +apt-get -y install sshfs + +apt-get -y install console-data + +for group in `find /usr/bin/boot-tools/listpackages/ -name sw.*` +do + echo "Instalando el grupo de paquetes almacenados en $group" + for package in ` awk /^install/'{print $2}' $group ` + do + echo -n $package + apt-get -y --force-yes install $package &>/dev/null + RETVAL=$? + if [ $RETVAL == 0 ] + then + echo " : OK - Paquete instalado correctamente (codigo interno de apt-get $RETVAL)" + else + echo " : Error Paquete $package del grupo $group (codigo interno de apt-get $RETVAL) " + echo "Pulse pause para continuar" + read + fi + done +done + + +#Activamos el hook del oginitrd.img +mv /etc/initramfs-tools/oghooks /etc/initramfs-tools/hooks/ + +echo " " > /etc/mtab + +apt-get clean +apt-get autoclean +apt-get autoremove + +history -c diff --git a/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareXwindows b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareXwindows new file mode 100644 index 00000000..41824f18 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSoftwareXwindows @@ -0,0 +1,14 @@ +#!/bin/bash + +export LANGUAGE=C +export LC_ALL=C +export LANG=C + +apt-get clean +apt-get -y update + +apt-get -y --force-yes install xorg-dev xorg lxde roxterm + +apt-get clean + +history -c
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/root/generateSshKeysClient.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSshClient.sh index 9857ad40..10aa673e 100755 --- a/client/boot-tools/clientstructure/root/generateSshKeysClient.sh +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSshClient.sh @@ -20,4 +20,6 @@ ssh-keygen -q -f /root/.ssh/id_rsa -N "" cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys ## TODO: exportamos la publica a los repos -cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub
\ No newline at end of file +cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub + +history -c
\ No newline at end of file diff --git a/client/boot-tools/clientstructure/root/importSshKeys.sh b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSshServer.sh index 17a797f8..02ea71cd 100755 --- a/client/boot-tools/clientstructure/root/importSshKeys.sh +++ b/client/boot-tools/includes/usr/bin/boot-tools/boottoolsSshServer.sh @@ -14,4 +14,5 @@ echo "importando la clave publica del servidor OG" cat /tmp/id_rsa.pub [ -f /tmp/id_rsa.pub ] && cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys || echo "no key publica og" -
\ No newline at end of file + + history -c
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.Xwindow b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.Xwindow new file mode 100644 index 00000000..25356820 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.Xwindow @@ -0,0 +1,10 @@ +#sw.X +#+300M +#install xorg-dev +#install xorg +#install lxde +#+80M roxterm y gparted +install roxterm +install gparted +#xvesa en compilacion +install openbox
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.Zinitrd b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.Zinitrd new file mode 100644 index 00000000..48438791 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.Zinitrd @@ -0,0 +1,3 @@ +#sw.zinitrd +install busybox-static +install bash-static diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.basic b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.basic new file mode 100644 index 00000000..4286d652 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.basic @@ -0,0 +1,13 @@ +#Format install paquete +install dialog +install man-db +install fbset +install gdebi-core +install busybox-static +install console-data +install locales +install lshw +install gawk +install subversion +install python-openssl +install python
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.cloning b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.cloning new file mode 100644 index 00000000..9eda4b6b --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.cloning @@ -0,0 +1,16 @@ +#sw.cloning +install drbl-partimage +install fsarchiver +install pv +install kexec-tools +install mbuffer +install parted +install drbl-chntpw +install chntpw +install clonezilla +install registry-tools +install reglookup +install libparse-win32registry-perl +install grokevt +install libhivex0 +install libhivex-bin
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.compile b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.compile new file mode 100644 index 00000000..8b1d1001 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.compile @@ -0,0 +1,10 @@ +install build-essential +install libattr* +install attr +install make +install m4 +install gettext +install libmhash-dev +install gdebi-core +install gawk + diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.compresor b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.compresor new file mode 100644 index 00000000..113e885e --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.compresor @@ -0,0 +1,12 @@ +#sw.compressor +install lzma +install zip +install unzip +install gzip +install lzop +install drbl-lzop +install pigz +install pbzip2 +install lbzip2 +install rzip +install p7zip-full
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.filesystem.local b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.filesystem.local new file mode 100644 index 00000000..16d67da5 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.filesystem.local @@ -0,0 +1,21 @@ +#sw.filesystem.local +install squashfs-tools +install unionfs-fuse +install drbl-ntfsprogs +install ntfsprogs +install ntfs-3g +install dosfstools +install dmraid +install dmsetup +install lvm2 +install e2fsprogs +install jfsutils +install reiserfsprogs +install xfsprogs +install mhddfs +install hfsplus +install hfsprogs +install hfsutils +install nilfs-tools +install reiser4progs +install ufsutils
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.filesystem.remote b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.filesystem.remote new file mode 100644 index 00000000..192a4017 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.filesystem.remote @@ -0,0 +1,9 @@ +#sw.filesystem.remote +install nfs-common +install sshfs +install smbfs +install smbclient +install davfs2 +install open-iscsi +install openssh-server +install bittornado
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.monitoring b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.monitoring new file mode 100644 index 00000000..49adc6f3 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.monitoring @@ -0,0 +1,12 @@ +#sw.monitoring +install htop +install ncdu +install bwbar +install bmon +install iftop +install ifstat +install dstat +install hdparm +install sdparm +install blktool +install testdisk
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.networking b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.networking new file mode 100644 index 00000000..d8efd04e --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.networking @@ -0,0 +1,14 @@ +#sw.networking +install netpipes +install wget +install tftp +install dnsutils +install trickle +install lighttpd +install ethtool +install ssmping +install mii-diag +install tcpdump +install nmap +install arping +install iptraf
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.testing b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.testing new file mode 100644 index 00000000..282de9e8 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/listpackages/sw.testing @@ -0,0 +1,4 @@ +#sw.other +install screen +install schroot +install grub
\ No newline at end of file diff --git a/client/boot-tools/includes/usr/bin/boot-tools/qemu.sh b/client/boot-tools/includes/usr/bin/boot-tools/qemu.sh new file mode 100755 index 00000000..49031670 --- /dev/null +++ b/client/boot-tools/includes/usr/bin/boot-tools/qemu.sh @@ -0,0 +1,12 @@ +#/bin/bash + +mount -o rw,remount / +mount proc /proc -t proc +export PATH=$PATH dpkg -i *.deb +modprobe 8139too +modprobe 8139cp +dhclient +/etc/init.d/ssh restart + + +#qemu -hda ogclient.img -kernel ./ogvmlinuz -initrd ./oginitrd.img -append "root=/dev/sda1 rw init=false" -boot c
\ No newline at end of file diff --git a/client/boot-tools/includes/var/cache/apt/archivesOG/partclone_0.2.7-1drbl_i386.deb b/client/boot-tools/includes/var/cache/apt/archivesOG/partclone_0.2.7-1drbl_i386.deb Binary files differnew file mode 100755 index 00000000..870b021f --- /dev/null +++ b/client/boot-tools/includes/var/cache/apt/archivesOG/partclone_0.2.7-1drbl_i386.deb diff --git a/client/boot-tools/includes/var/cache/apt/archivesOG/partclone_0.2.8_i386.deb b/client/boot-tools/includes/var/cache/apt/archivesOG/partclone_0.2.8_i386.deb Binary files differnew file mode 100755 index 00000000..9dbe2e9e --- /dev/null +++ b/client/boot-tools/includes/var/cache/apt/archivesOG/partclone_0.2.8_i386.deb diff --git a/client/boot-tools/includes/var/cache/apt/archivesOG/xvesa.deb b/client/boot-tools/includes/var/cache/apt/archivesOG/xvesa.deb Binary files differnew file mode 100644 index 00000000..72433e76 --- /dev/null +++ b/client/boot-tools/includes/var/cache/apt/archivesOG/xvesa.deb diff --git a/client/boot-tools/clientstructure/var/lib/locales/supported.d/local b/client/boot-tools/includes/var/lib/locales/supported.d/local index be3f2a41..be3f2a41 100644 --- a/client/boot-tools/clientstructure/var/lib/locales/supported.d/local +++ b/client/boot-tools/includes/var/lib/locales/supported.d/local diff --git a/client/boot-tools/kernelParameterOG.es.txt b/client/boot-tools/kernelParameterOG.es.txt index 66d7fcfa..7f8a15b2 100644 --- a/client/boot-tools/kernelParameterOG.es.txt +++ b/client/boot-tools/kernelParameterOG.es.txt @@ -1,49 +1,5 @@ -KERNEL ogclient/ogvmlinuz -initrd=ogclient/oginitrd.img +Ver información completa en: + http://www.opengnsys.es/wiki/InitrdClienteSecondFileSystem -### PARAMETROS ESTANDAR DEl KERNEL -## indicamos al kernel que proceso a iniciar el Opengnsys - boot=oginit - vga=788 -irqpoll -acpi=on - -ip=dhcp -ip= - -### PARAMETROS ESPECIFICOS DE OG. - # Indicamos al cliente OG, cuando termine su proceso que incie el init (/opt/opengnsys/etc/preinit/default.sh) - # si no se utiliza este parametro por defecto usa init. - oginit=init|/bin/bash - - - #por defecto todos los servicios OG, los considera ubicados en el next-server (parámetro indicado en el servicio dhcp) -# en el caso de que queramos que indicar que REPO (/opt/opengnsys/images) está en otro equipo utilizar este parámetro ogrepo - ogrepo=ip del repositorio - - # fichero donde se encuentra el rootfs que usara el ogvmlinuz y el oginitrd.img - # hay dos formatos, el img (fichero modificable desde el OG server), o el sqfs (fichero solo lectura del img) - og2nd=sqfs|img - - #protocolo de acceso al og2nd. - ogprotocol=smb|nfs|local - #local para cdrom, usb a partir de la iso. labelparticionusbUNETBOOTIN=ogClient - #loacl tambien para fichero.sqfs en cache. - - - # modo de funcionalidad del browser con shell root activa. - ogactiveadmin=true|false - - #modo de depuración en el proceso de arranque del cliente. - ogdebug=true|false - - -#modulo especial de la tarjeta de red. -ognetmodule - - - - - diff --git a/client/boot-tools/ogClientGeneratorV2.sh b/client/boot-tools/ogClientGeneratorV2.sh deleted file mode 100755 index 3f816aeb..00000000 --- a/client/boot-tools/ogClientGeneratorV2.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/bash -#@file ogClientGenerator.sh -#@brief Script generación del cliente OpenGnSys -#@warning -#@version 0.9 - -#@author Antonio J. Doblas Viso. -#@date 2010/05/24 -#*/ - - -#$1 OSCONENAME lucid karmic -#if [ $# -ne 1 ]; then -# echo ": invalid number of parameters" -# echo " host | lucid | karmic | jaunty | lenny | squeeze " -# exit 1 -#fi -TYPECLIENT=host - -# Solo ejecutable por usuario root -if [ "$(whoami)" != 'root' ] -then - echo "ERROR: this program must run under root privileges!!" - exit 1 -fi - - - -#FIXME: variables del instalador oficial. -WORKDIR=/tmp/opengnsys_installer -INSTALL_TARGET=/opt/opengnsys -LOG_FILE=/tmp/opengnsys_installation.log -PROGRAMDIR=$(readlink -e $(dirname "$0")) - - -#funciones especificas del cliente. -source $PROGRAMDIR/ogClientManager.lib -#funciones incluidas dentro del scritps general de instalacion. -source $PROGRAMDIR/ogInstaller.lib - -echoAndLog "OpenGnSys CLIENT installation begins at $(date)" - -########################################################################## -## FASE 1 - Instalación de software adicional. -##TO DO Integrar en el instaldor. Actualizar repositorios -# Datos para la generación del cliente. -DEPENDENCIES=( debootstrap subversion schroot squashfs-tools) -apt-get update -# Instalación de dependencias (paquetes de sistema operativo). -declare -a notinstalled -checkDependencies DEPENDENCIES notinstalled -if [ $? -ne 0 ]; then - installDependencies notinstalled - if [ $? -ne 0 ]; then - echoAndLog "Error while installing some dependeces, please verify your server installation before continue" - exit 1 - fi -fi -############## FIN DEL TO DO -############################################## FIN FASE 1 - - - -############## FASE 2 - Asignación de variables -#obtenemos las variables necesarias. -ogClientVar -#obtenemos la información del host. -ogClientOsInfo -######################## FIN fase 2 - -############# FASE 3: Segundo Sistema archivos (img) Creación. -#TODO comprobacion de que el fichero esta creado. -file $OGCLIENTFILE | grep "partition 1: ID=0x83" -if [ $? == 1 ] -then - ##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. - ogClient2ndFile || exit 1 -fi - - -#3.2 generamos el Sistema de archivos con debootstrap -# Comprobamos que ya tenemos alguno. -schroot -p -c IMGogclient -- touch /tmp/ogclientOK -if [ -f /tmp/ogclientOK ] -then - rm /tmp/ogclientOK -else - ogClient2ndFs $TYPECLIENT || exit -fi - - -############### FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot -cat /etc/schroot/schroot.conf | grep ogclient || ogClientSchrootConf - - -############### FASE 5: Configuración del Segundo Sistema de archivos (img) con la estructura especial de OpenGnsys -ogClient2ndSVN $TYPECLIENT || exit - - - - -############# FASE6: Ejecutamos los scripts de personalización del 2º sistema de archivos (img) desde la jaula schroot -### 6.1 instalacion de software con apt-get -schroot -p -c IMGogclient -- /root/InstallSoftware.sh -echo "saltando" - if [ $? -ne 0 ]; then - errorAndLog "Instalando sofware adicional OG : ERROR" - exit -else - echoAndLog "Instalando sofware adicional OG: OK" -fi -#### 6.2 compilación de software. -cd / -schroot -p -c IMGogclient -- /root/CompileSoftware.sh -cd - - -### 6.3 configuracion hostname passroot securety -cd / -schroot -c IMGogclient -- /root/ConfFS.sh -cd - -#schroot -c IMGogclient -- echo -ne "og1\nog1\n" | passwd root -# schroot -c IMGogclient -- passwd root | echo "root" - - -### 6.4 incorporamos la clave publica del servidor -cd / -ssh-keygen -q -f /root/.ssh/id_rsa -N "" -cp /root/.ssh/id_rsa.pub /tmp -schroot -p -c IMGogclient -- /root/importSshKeys.sh -cd - -############ y la del propio cliente. -schroot -c IMGogclient -- /root/generateSshKeysClient.sh - -## configuramos los locales. -schroot -c IMGogclient -- /root/ReconfigureLocales.sh - - -################## FIN fase 6. Fin de comfiguración del segundo sistema de archivos (img) - -################## FASE 7. Generamos el 1er sistema de archivos. INITRD -#nota el parametro es el "tipo" de linux generado en debootstrap. usar solo "host", es decir version,kernel ... del propio host -#nota: hace un schroot, al 2fs (img), ejecuta el fichero generateinitrd. -#nota: deja en el directorio tmp del host el nuevo initrd, y lo copia al tftpboot -ogClientInitrd $TYPECLIENT - - -################## FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) -# generamos el 2sistema de archivos en squashfs -ogClient2ndSqfs -################## FIN FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) - - -##################### FASE 9. algunos detallas del pxe -#dejamos ficheros de ejemplo para el pxe y el nfs -#ogClientConfpxe -##################### FIN FASE 9. algunos detallas del pxe - - -# Mostrar sumario de la instalación e instrucciones de post-instalación. -installationSummary - -echoAndLog "OpenGnSys installation finished at $(date)" diff --git a/client/boot-tools/ogClientManager.lib b/client/boot-tools/ogClientManager.lib deleted file mode 100644 index 9f56ec4a..00000000 --- a/client/boot-tools/ogClientManager.lib +++ /dev/null @@ -1,725 +0,0 @@ - -ogClientVar() -{ -export SVNCLIENTDIR=/tmp/opengnsys_installer/opengnsys/client/boot-tools -export SVNCLIENTSTRUCTURE=/tmp/opengnsys_installer/opengnsys/client/shared -export SVNCLIENTENGINE=/tmp/opengnsys_installer/opengnsys/client/engine - -export OGCLIENTBASEDIR=/var/lib/tftpboot/ogclient/ -export OGCLIENTFILE=${OGCLIENTBASEDIR}ogclient.img -export OGCLIENTMOUNT=${OGCLIENTBASEDIR}ogclientmount -# tamaño maximo limitado por schroot 2GB -export OGCLIENTSIZEMB=1900 -#export OGCLIENTSIZEMB=1000 -# export OGCLIENTSIZEKB=500 -export OGCLIENTLABEL=ogClient -#export OGLIB=/opt/opengnsys/client/lib -} - - - -function ogClientOsInfo () -{ -#TODO según host, un OSHHTP u otro OSARCH - #1 OSCODENAME jaunty|karmic|lucid - #devuelve OSDISTRIB(ubuntu,debian),OSCODENAME(lucid,karmic,squeeze):OGRELEASE:httpAPT - case $1 in - host | HOST) - export OSDISTRIB=$(lsb_release -i | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null - #OSCODENAME=$(lsb_release -c | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null - export OSCODENAME=$(cat /etc/lsb-release | grep CODENAME | awk -F= '{print $NF}') - export OSRELEASE=$(uname -a | awk '{print $3}') - uname -a | grep x86_64 > /dev/null && export OSARCH=amd64 || export OSARCH=i386 - export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" - ;; - jaunty|JAUNTY) - export OSDISTRIB=ubuntu - export OSCODENAME=jaunty - export OSRELEASE="2.6.28-11-generic" - export OSARCH=i386 - export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" - ;; - lenny|LENNY) - export OSDISTRIB=debian - export OSCODENAME=lenny - export OSRELEASE="2.6.28-11-generic" - export OSARCH=i386 - export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " - ;; - squeeze|SQUEEZE) - export OSDISTRIB=debian - export OSCODENAME=squeeze - export OSRELEASE="2.6.28-11-generic" - export OSARCH=i386 - export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " - ;; - karmic|KARMIC) - export OSDISTRIB=ubuntu - export OSCODENAME=karmic - export OSRELEASE="2.6.31-14-generic" - export OSARCH=i386 - export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " - ;; - lucid|LUCID) - export OSDISTRIB=ubuntu - export OSCODENAME=lucid - export OSRELEASE="2.6.32-21-generic-pae" - export OSARCH=i386 - export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " - ;; - *) - return 1 - ;; - esac - echo $OSDISTRIB:$OSCODENAME:$OSRELEASE:$OSARCH:$OSHTTP -} - -#creación y formateo del disco virtual. -ogClient2ndFile () -{ -local RERROR DISKLOOP PARTLOOP #return code error -echoAndLog "$FUNCNAME(): Creación y formateo del disco virtual $OGCLIENTSIZEMB MB " -#Desmontamos por si acaso el dispositivo virtual -mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT -mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT -echo "$FUNCNAME(): Creando el directorio donde se montará el disco virtual $OGCLIENTMOUNT" -mkdir -p $OGCLIENTMOUNT -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Creando directorio $OGCLIENTMOUNT : ERROR" - return 1 -fi -echo "$FUNCNAME(): Creando el disco virtual que almacenará el FS del cliente $OGCLIENTSIZEMB MB de datos físicos" -dd if=/dev/zero of=$OGCLIENTFILE bs=1048576 count=$OGCLIENTSIZEMB -#qemu-img create $OGCLIENTFILE 3G -#dd if=/dev/zero of=$OGCLIENTFILE bs=1k count=$OGCLIENTSIZEKB # necesita 500MB -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Creando el disco virtual: ERROR" - return 1 -fi - -DISKLOOP=$(losetup -f) -losetup $DISKLOOP $OGCLIENTFILE -echo "$FUNCNAME(): particiondo el disco virtual - $DISKLOOP - con una particion primaria" -echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk $DISKLOOP -#echo $? -# da error, porque no puede actualizar el kernel. -#if [ $? -ne 0 ] -#then -# errorAndLog "$FUNCNAME(): Particionando el disco virutal: ERROR" -# return 1 -#fi - -echoAndLog "$FUNCNAME(): Desmontando $DISKLOOP despues del particionado " -losetup -d $DISKLOOP - -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Liberando disco virtual despues del particionado: ERROR" - return 1 -fi - - -#mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 -#mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 -PARTLOOP=$(losetup -f) -echo "$FUNCNAME(): Formateando la particion principal $PARTLOOP" -losetup -o 32256 $PARTLOOP $OGCLIENTFILE && mkfs.ext3 -b 4096 -L $OGCLIENTLABEL $PARTLOOP -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Formateando la particion principal del disco virtual: ERROR" - return 1 -fi -echoAndLog "$FUNCNAME(): Desmontando $PARTLOOP despues del formateo " -losetup -d $PARTLOOP -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Liberando la particion virtual despues del formateo: ERROR" - return 1 -else - echoAndLog "$FUNCNAME(): $OGCLIENTFILE $OGCLIENTSIZEMB MB : OK" -fi -} - - - - - -ogClient2ndFs () -{ -ogClientOsInfo $1 -echoAndLog "$FUNCNAME: Iniciando la generación del sistema de archivos " -#Montamos el dispositivo virtual en su punto de montaje. -mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 - -mount | grep $OGCLIENTMOUNT && echoAndLog "$FUNCNAME: mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 OK " || errorAndLog "$FUNCNAME: mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 : FAILURE " - -#debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe ${OSCODENAME} ${OGCLIENTMOUNT} ${OSHTTP} -debootstrap --arch=$OSARCH --components=main,universe ${OSCODENAME} ${OGCLIENTMOUNT} ${OSHTTP} - - -if [ $? -ne 0 ]; then - errorAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $OGCLIENTMOUNT $OSHTTP - : ha fallado!" - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - return 1 -else - echoAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $OGCLIENTMOUNT $OSHTTP - : ok" - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - return 0 -fi - sleep 5 - -##preubas revisar OSRELEASE -#debootstrap --include=linux-image-${OSRELEASE} --arch=i386 --variant=minbase $OSVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ -#debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ -#echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ -} - - - - -########## configura el segundo sistema de archivos -########### parametro: "host" -function ogClient2ndSVN() -{ -ogClientOsInfo $1 -#1 la salida de ogClientOsInfo -local LERROR -LERROR=TRUE -echoAndLog "$FUNCNAME: Iniciando la personalización con datos del SVN " -# comprobar que está montado $OGCLIENTMOUNT -mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 - -# parseamos del apt.source -sed -e "s/OSCODENAME/$OSCODENAME/g" ${SVNCLIENTDIR}/clientstructure/etc/apt/sources.list.ubuntu > ${SVNCLIENTDIR}/clientstructure/etc/apt/sources.list -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Parsing apt.sources : ERROR" - return 1 -fi - -#parseamos el script de generación del initrd. -sed -e "s/OSRELEASE/$OSRELEASE/g" ${SVNCLIENTDIR}/clientstructure/root/GenerateInitrd.generic.sh > ${SVNCLIENTDIR}/clientstructure/root/GenerateInitrd.sh -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Parsing GenerateInitrd.sh : ERROR" - return 1 -fi - -#damos permiso al directorio de scripts -chmod 775 ${SVNCLIENTDIR}/clientstructure/root/* - -# los copiamos -cp -prv ${SVNCLIENTDIR}/clientstructure/* $OGCLIENTMOUNT -mkdir -p ${OGCLIENTMOUNT}/opt/opengnsys/ -cp -prv ${SVNCLIENTSTRUCTURE}/* ${OGCLIENTMOUNT}/opt/opengnsys/ -cp -prv ${SVNCLIENTENGINE}/* ${OGCLIENTMOUNT}/opt/opengnsys/lib/engine/bin/ - -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Copying client data : ERROR" - return 1 -fi - -# copiamos algunas cosas del nfsexport - -#### Tipos de letra para el Browser. -cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/lib/fonts -#### Crear enlaces para compatibilidad con las distintas versiones del Browser. -mkdir -p $OGCLIENTMOUNT/usr/local/Trolltech/QtEmbedded-4.5.1/lib/ -mkdir -p $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.2/lib/ -mkdir -p $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.3/lib/ -#ln -fs $OGCLIENTMOUNT/usr/local/lib/fonts /usr/local/Trolltech/QtEmbedded-4.5.1/lib/fonts -#ln -fs $OGCLIENTMOUNT/usr/local/lib/fonts /usr/local/QtEmbedded-4.6.2/lib/fonts -#ln -fs $OGCLIENTMOUNT/usr/local/lib/fonts /usr/local/QtEmbedded-4.6.3/lib/fonts -cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/Trolltech/QtEmbedded-4.5.1/lib/fonts -cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.2/lib/fonts -cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.3/lib/fonts - - - - -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Linking Browser fonts : ERROR" - return 1 -fi - -# B ######################################################## -cp -pr ${SVNCLIENTSTRUCTURE}/lib/pci.ids $OGCLIENTMOUNT/etc -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Copying pci.ids : ERROR" - return 1 -fi - -cp ${SVNCLIENTSTRUCTURE}/bin/browser $OGCLIENTMOUNT/bin -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Copying Browser : ERROR" - return 1 -fi - -cp ${SVNCLIENTSTRUCTURE}/bin/ogAdmClient $OGCLIENTMOUNT/bin -if [ $? -ne 0 ] -then - errorAndLog "$FUNCNAME(): Copying ogAdmClient : ERROR" - return 1 -else - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - echoAndLog "$FUNCNAME: Finalizado: OK " - return 0 -fi -} - - -ogClientSchrootConf() -{ -echoAndLog "$FUNCNAME: Iniciando la configuración del schroot " -cp /etc/schroot/schroot.conf /etc/schroot/schroot.conf.`getDateTime` -cat << EOF > /etc/schroot/schroot.conf -[IMGogclient] -type=loopback -file=/var/lib/tftpboot/ogclient/ogclient.img -description=ogclient ubuntu luc IMGi -priority=1 -users=root -groups=root -root-groups=root -mount-options=-o offset=32256 -root-users=root -[DIRogclient] -type=directory -directory=/var/lib/tftpboot/ogclient/ogclientmount -description=ogclient ubuntu lucid DIR -priority=2 -users=root -groups=root -root-groups=root -root-users=root -EOF -cp /etc/schroot/mount-defaults /etc/schroot/mount-defaults.`getDateTime` -cat << EOF > /etc/schroot/mount-defaults -# mount.defaults: static file system information for chroots. -# Note that the mount point will be prefixed by the chroot path -# (CHROOT_PATH) -# -# <file system> <mount point> <type> <options> <dump> <pass> -proc /proc proc defaults 0 0 -#procbususb /proc/bus/usb usbfs defaults 0 0 -#/dev /dev none rw,bind 0 0 -/dev/pts /dev/pts none rw,bind 0 0 -/dev/shm /dev/shm none rw,bind 0 0 -#/home /home none rw,bind 0 0 -/tmp /tmp none rw,bind 0 0 -EOF - -echoAndLog "$FUNCNAME: Finalizado: OK " -return 0 -} - - - -########### param1 "host" -ogClientInitrd() -{ -ogClientVar -cd / -ogClientOsInfo $1 -schroot -c IMGogclient -- /root/GenerateInitrd.generic.sh -echo "cp /tmp/*-${OSRELEASE} $OGCLIENTBASEDIR" -cp /tmp/*-${OSRELEASE} $OGCLIENTBASEDIR -cp /tmp/initrd.img-${OSRELEASE} ${OGCLIENTBASEDIR}/oginitrd.img -cp /tmp/vmlinuz-${OSRELEASE} ${OGCLIENTBASEDIR}/ogvmlinuz -cd - -} - - -ogClient2ndSqfs() -{ -ogClientVar -echoAndLog "$FUNCNAME: Iniciando la creación del sistema de archivos en sqfs " -# si ya existe un sqfs lo renombramos -[ -f $OGCLIENTBASEDIR/ogclient.sqfs ] && mv $OGCLIENTBASEDIR/ogclient.sqfs $OGCLIENTBASEDIR/ogclient.sqfs.`date +%Y%m%d-%H%M%S` -mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 -mksquashfs $OGCLIENTMOUNT $OGCLIENTBASEDIR/ogclient.sqfs -chmod 744 $OGCLIENTBASEDIR/ogclient.sqfs -mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT -} - - - - -ogClientSshkeys() -{ -echo comprobamos clave rsa en el host REPO OG. -if [ ! -f /root/.ssh/id_rsa.pub ] -then - echo "creando claves rsa" - ssh-keygen -q -f /root/.ssh/id_dsa -t dsa -N "opengnsys" -else - echo "la claves ya estan creadas" -fi -echo "copiamos la clave publica a /tmp" -cp /root/.ssh/id_dsa.pub /tmp - -cat /tmp/id_dsa.pub - -echo "schroot con instrucciones." -schroot -c IMGogclient -- /root/importSshKeys.sh - -echo "limpiando" -rm /tmp/id_dsa.pub - -## copiamos ssh rsa del host al guest como authorized-key2 -##rm ${OGCLIENTMOUNT}/root/.ssh/authorized-key2 -##cat /root/.ssh/id_rsa.pub >> ${OGCLIENTMOUNT}/root/.ssh/authorized-key2 -#cat ${OGCLIENTMOUNT}/root/.ssh/id_rsa.pub >> ${OGCLIENTMOUNT}/root/.ssh/authorized-key2 -##mount | grep $OGCLIENTMOUNT || umount $OGCLIENTMOUNT -} - - - -function ogCrearISO { -apt-get install syslinux genisoimage -#TODO: deb http://free.nchc.org.tw/drbl-core drbl stable -#apt-get install gpxe -mkdir -p /tmp/iso/isolinux -#cd tmp/iso/ -cp -prv /usr/lib/syslinux/* /tmp/iso/isolinux/ -cp -prv /usr/share/gpxe/* /tmp/iso/isolinux/ -mkdir -p /tmp/iso/ogclient -#el ogclienteToISO debe tener una copia del ogvmlinuz como linuxISO -cp -prv /var/lib/tftpboot/ogclientToIso/* /tmp/iso/ogclient - - -cat << FIN > /tmp/iso/isolinux/isolinux.cfg -DEFAULT menu.c32 -PROMPT 0 -ALLOWOPTIONS 1 - -MENU TITLE OpenGnsys 1.0.1 v00 - -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 vga irqpool acpi ogdebug ip:none -KERNEL /ogclient/linuxISO -APPEND initrd=/ogclient/oginitrd.img ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none - -LABEL 1 -MENU LABEL ogClient irqpoll acpi ip:none -KERNEL /ogclient/linuxISO -APPEND initrd=/ogclient/oginitrd.img ro irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=none - -LABEL 2 -MENU LABEL ogClient acpi debug ip=dhcp -KERNEL /ogclient/linuxISO -APPEND initrd=/ogclient/oginitrd.img ro acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=dhcp - -LABEL 3 -MENU LABEL ogClient ip=dhcp -KERNEL /ogclient/linuxISO -APPEND initrd=/ogclient/oginitrd.img ro acpi=off boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=dhcp - - -#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 - -### vi /etc/grub.d/40_custom -## -#menuentry "og cache " { -#set root=(hd0,4) -#linux /ogvmlinuz ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none -#initrd /oginitrd.img -#} - - -} - -function ogprobarISO { -#/tmp/iso -qemu -m 256 -boot d -cdrom ogClient.iso -} - - - - - - - -ogClientConfpxe() -{ -################## DEJAMOS FICHERO DE EJEMPLOS PARA: -#default -cat << FIN >> /var/lib/tftpboot/pxelinux.cfg/defaultNEWClient -LABEL pxe-${OGRELEASE} -KERNEL ogclient/vmlinuz-$OGRELEASE -APPEND initrd=ogclient/initrd.img-$OGRELEASE ip=dhcp ro boot=og vga=788 irqpoll acpi=on reposerver= -LABEL pxe-2.6.32-21-generic-pae -KERNEL ogclient/vmlinuz-2.6.32-21-generic-pae -APPEND initrd=ogclient/initrd.img-2.6.32-21-generic-pae ip=dhcp ro boot=oginit vga=788 irqpoll acpi=on ogrepo=172.17.36.11 ogprotocol=nfs og2nd=sqfs -LABEL cache -KERNEL grub.exe -APPEND --config-file="find --set-root /vmlinuz; kernel /vmlinuz ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd /initrd.img" -LABEL net -KERNEL grub.exe -APPEND keeppxe --config-file="pxe detect; kernel (pd)/ogclient/vmlinuz-2.6.32-21-generic-pae ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd (pd)/ogclient/initrd.img-2.6.32-21-generic-pae" -LABEL IfNOTcacheGOnet -KERNEL grub.exe -APPEND keeppxe --config-file="pxe detect; default 0; timeout 0; hiddenmenu; title cache; fallback 1; find --set-root /vmlinuz; kernel /vmlinuz ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd /initrd.img; boot; title net; kernel (pd)/ogclient/vmlinuz-2.6.32-21-generic-pae ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd (pd)/ogclient/initrd.img-2.6.32-21-generic-pae; boot" -#LABEL pxe-2.6.32-21-generic-pae -#KERNEL ogclient/vmlinuz-2.6.32-21-generic-pae -#APPEND initrd=ogclient/initrd.img-2.6.32-21-generic-pae ip=dhcp ro boot=og vga=788 irqpoll acpi=on reposerver=172.17.32.242 -#LABEL grub -#KERNEL grub.exe -#APPEND keeppxe -FIN -#/etc/hosts -echo "/var/lib/tftpboot *(ro,no_subtree_check,no_root_squash,sync)" > /etc/exportsNEWClient -/etc/init.d/nfs-kernel-server restart -##################################################################### -} - - - -############### No usados en el instalador, solo en actualizaciones. -#/** -# 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 | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 - mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc - mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys - mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp - mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev - mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts - - - [ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`) - [ $# = 1 ] && chroot $OGCLIENTMOUNT $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 - echo "desmontando cliente espere" - sleep 5 - mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount - mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount - mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount - mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount - mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount - mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount - #-d -f -l - -} - - -############################ hasta el final del archivo antiguos -############################# ANTIGUOS -function ogClientGetRelease () -{ - #1 OSCODENAME jaunty|karmic|lucid - case $1 in - jaunty|JAUNTY) - OSCODENAME=jaunty - OGRELEASE="2.6.28-11-generic" - echo $OGRELEASE - ;; - lenny|LENNY) - OSCODENAME=lenny - OGRELEASE="2.6.28-11-generic" - echo $OGRELEASE - ;; - squeeze|SQUEEZE) - OSCODENAME=squeeze - OGRELEASE="2.6.28-11-generic" - echo $OGRELEASE - ;; - karmic|KARMIC) - OSCODENAME=karmic - OGRELEASE="2.6.31-14-generic" - echo $OGRELEASE - ;; - lucid|LUCID) - OSCODENAME=lucid - OGRELEASE="2.6.32-21-generic-pae" - echo $OGRELEASE - ;; - *) - return 1 - ;; - esac - -} - - -#/** -# 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 - OSCODENAME=$1 - OGRELEASE=$2 - - # 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 - - #Desmontamos por si acaso el dispositivo virtual - mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT - - #Creamos el directorio donde montaremos el disco virtual - mkdir -p $OGCLIENTMOUNT - - #Creamos el disco virtual con el filesystem del cliente. - dd if=/dev/zero of=$OGCLIENTFILE bs=1048576 count=$OGCLIENTSIZEMB - #qemu-img create $OGCLIENTFILE 3G - #dd if=/dev/zero of=$OGCLIENTFILE bs=1k count=$OGCLIENTSIZEKB # necesita 500MB - - - #particionamos el disco virtual - losetup /dev/loop0 $OGCLIENTFILE - echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk /dev/loop0 - losetup -d /dev/loop0 - - - #formateamos la particion principal. - losetup -o 32256 /dev/loop1 $OGCLIENTFILE - mkfs.ext3 -b 4096 -L $OGCLIENTLABEL /dev/loop1 - #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 - #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 - losetup -d /dev/loop1 - - #Montamos el dispositivo virtual en su punto de montaje. - mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 - - #TODO Comprobar arquitectura - #Iniciamos la creación del sistema en el directorio de clientes. - #echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ - debootstrap --include=linux-image-${OGRELEASE},linux-headers-${OGRELEASE} --arch=i386 --components=main,universe $OSCODENAME $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ - ##preubas - #debootstrap --include=linux-image-${OGRELEASE} --arch=i386 --variant=minbase $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ - #debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ - - if [ $? -ne 0 ]; then - errorAndLog "ogClientGeneratorDebootstrap(): ha fallado!" - return 1 - else - echoAndLog "ogClientGeneratorDebootstrap(): ok" - return 0 - fi - sleep 5 - -mount | grep $OGCLIENTMOUNT && umount $OGCLIENTFILE - -cat << EOF > /etc/schroot/schroot.conf -[DIRogclient] -type=directory -directory=/var/lib/tftpboot/ogclient/ogclientmount -description=ogclient ubuntu lucid DIR -priority=2 -users=root -groups=root -root-groups=root -root-users=root -EOF -} - - - - - diff --git a/client/boot-tools/ogInstaller.lib b/client/boot-tools/ogInstaller.lib deleted file mode 100644 index af0f18df..00000000 --- a/client/boot-tools/ogInstaller.lib +++ /dev/null @@ -1,958 +0,0 @@ -#!/bin/bash - - -##################################################################### -####### Algunas funciones útiles de propósito general: -##################################################################### -function getDateTime() -{ - echo `date +%Y%m%d-%H%M%S` -} - -# Escribe a fichero y muestra por pantalla -function echoAndLog() -{ - echo $1 - FECHAHORA=`getDateTime` - echo "$FECHAHORA;$SSH_CLIENT;$1" >> $LOG_FILE -} - -function errorAndLog() -{ - echo "ERROR: $1" - FECHAHORA=`getDateTime` - echo "$FECHAHORA;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE -} - -# comprueba si el elemento pasado en $2 esta en el array $1 -function isInArray() -{ - if [ $# -ne 2 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - echoAndLog "${FUNCNAME}(): checking if $2 is in $1" - local deps - eval "deps=( \"\${$1[@]}\" )" - elemento=$2 - - local is_in_array=1 - # copia local del array del parametro 1 - for (( i = 0 ; i < ${#deps[@]} ; i++ )) - do - if [ "${deps[$i]}" = "${elemento}" ]; then - echoAndLog "isInArray(): $elemento found in array" - is_in_array=0 - fi - done - - if [ $is_in_array -ne 0 ]; then - echoAndLog "${FUNCNAME}(): $elemento NOT found in array" - fi - - return $is_in_array - -} - -##################################################################### -####### Funciones de manejo de paquetes Debian -##################################################################### - -function checkPackage() -{ - package=$1 - if [ -z $package ]; then - errorAndLog "checkPackage(): parameter required" - exit 1 - fi - echoAndLog "checkPackage(): checking if package $package exists" - dpkg -s $package | grep Status | grep -qw install &>/dev/null - if [ $? -eq 0 ]; then - echoAndLog "checkPackage(): package $package exists" - return 0 - else - echoAndLog "checkPackage(): package $package doesn't exists" - return 1 - fi -} - -# recibe array con dependencias -# por referencia deja un array con las dependencias no resueltas -# devuelve 1 si hay alguna dependencia no resuelta -function checkDependencies() -{ - if [ $# -ne 2 ]; then - errorAndLog "checkDependencies(): invalid number of parameters" - exit 1 - fi - - echoAndLog "checkDependencies(): checking dependences" - uncompletedeps=0 - - # copia local del array del parametro 1 - local deps - eval "deps=( \"\${$1[@]}\" )" - - declare -a local_notinstalled - - for (( i = 0 ; i < ${#deps[@]} ; i++ )) - do - checkPackage ${deps[$i]} - if [ $? -ne 0 ]; then - local_notinstalled[$uncompletedeps]=$package - let uncompletedeps=uncompletedeps+1 - fi - done - - # relleno el array especificado en $2 por referencia - for (( i = 0 ; i < ${#local_notinstalled[@]} ; i++ )) - do - eval "${2}[$i]=${local_notinstalled[$i]}" - done - - # retorna el numero de paquetes no resueltos - echoAndLog "checkDependencies(): dependencies uncompleted: $uncompletedeps" - return $uncompletedeps -} - -# Recibe un array con las dependencias y lo instala -function installDependencies() -{ - if [ $# -ne 1 ]; then - errorAndLog "installDependencies(): invalid number of parameters" - exit 1 - fi - echoAndLog "installDependencies(): installing uncompleted dependencies" - - # copia local del array del parametro 1 - local deps - eval "deps=( \"\${$1[@]}\" )" - - local string_deps="" - for (( i = 0 ; i < ${#deps[@]} ; i++ )) - do - string_deps="$string_deps ${deps[$i]}" - done - - if [ -z "${string_deps}" ]; then - errorAndLog "installDependencies(): array of dependeces is empty" - exit 1 - fi - - OLD_DEBIAN_FRONTEND=$DEBIAN_FRONTEND - export DEBIAN_FRONTEND=noninteractive - - echoAndLog "installDependencies(): now ${string_deps} will be installed" - apt-get -y install --force-yes ${string_deps} - if [ $? -ne 0 ]; then - errorAndLog "installDependencies(): error installing dependencies" - return 1 - fi - - DEBIAN_FRONTEND=$OLD_DEBIAN_FRONTEND - echoAndLog "installDependencies(): dependencies installed" -} - -# Hace un backup del fichero pasado por parámetro -# deja un -last y uno para el dÃa -function backupFile() -{ - if [ $# -ne 1 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - local fichero=$1 - local fecha=`date +%Y%m%d` - - if [ ! -f $fichero ]; then - errorAndLog "${FUNCNAME}(): file $fichero doesn't exists" - return 1 - fi - - echoAndLog "${FUNCNAME}(): realizando backup de $fichero" - - # realiza una copia de la última configuración como last - cp -p $fichero "${fichero}-LAST" - - # si para el dÃa no hay backup lo hace, sino no - if [ ! -f "${fichero}-${fecha}" ]; then - cp -p $fichero "${fichero}-${fecha}" - fi - - echoAndLog "${FUNCNAME}(): backup realizado" -} - -##################################################################### -####### Funciones para el manejo de bases de datos -##################################################################### - -# This function set password to root -function mysqlSetRootPassword() -{ - if [ $# -ne 1 ]; then - errorAndLog "mysqlSetRootPassword(): invalid number of parameters" - exit 1 - fi - - local root_mysql=$1 - echoAndLog "mysqlSetRootPassword(): setting root password in MySQL server" - /usr/bin/mysqladmin -u root password ${root_mysql} - if [ $? -ne 0 ]; then - errorAndLog "mysqlSetRootPassword(): error while setting root password in MySQL server" - return 1 - fi - echoAndLog "mysqlSetRootPassword(): root password saved!" - return 0 -} - -# Si el servicio mysql esta ya instalado cambia la variable de la clave del root por la ya existente -function mysqlGetRootPassword(){ - local pass_mysql - local pass_mysql2 - # Comprobar si MySQL está instalado con la clave de root por defecto. - if mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<<"quit" 2>/dev/null; then - echoAndLog "${FUNCNAME}(): Using default mysql root password." - else - stty -echo - echo "Existe un servicio mysql ya instalado" - read -p "Insertar clave de root de Mysql: " pass_mysql - echo "" - read -p "Confirmar clave:" pass_mysql2 - echo "" - stty echo - if [ "$pass_mysql" == "$pass_mysql2" ] ;then - MYSQL_ROOT_PASSWORD=$pass_mysql - echo "La clave es: ${MYSQL_ROOT_PASSWORD}" - return 0 - else - echo "Las claves no coinciden no se configura la clave del servidor de base de datos." - echo "las operaciones con la base de datos daran error" - return 1 - fi - fi -} - -# comprueba si puede conectar con mysql con el usuario root -function mysqlTestConnection() -{ - if [ $# -ne 1 ]; then - errorAndLog "mysqlTestConnection(): invalid number of parameters" - exit 1 - fi - - local root_password="${1}" - echoAndLog "mysqlTestConnection(): checking connection to mysql..." - echo "" | mysql -uroot -p"${root_password}" - if [ $? -ne 0 ]; then - errorAndLog "mysqlTestConnection(): connection to mysql failed, check root password and if daemon is running!" - return 1 - else - echoAndLog "mysqlTestConnection(): connection success" - return 0 - fi -} - -# comprueba si la base de datos existe -function mysqlDbExists() -{ - if [ $# -ne 2 ]; then - errorAndLog "mysqlDbExists(): invalid number of parameters" - exit 1 - fi - - local root_password="${1}" - local database=$2 - echoAndLog "mysqlDbExists(): checking if $database exists..." - echo "show databases" | mysql -uroot -p"${root_password}" | grep "^${database}$" - if [ $? -ne 0 ]; then - echoAndLog "mysqlDbExists():database $database doesn't exists" - return 1 - else - echoAndLog "mysqlDbExists():database $database exists" - return 0 - fi -} - -function mysqlCheckDbIsEmpty() -{ - if [ $# -ne 2 ]; then - errorAndLog "mysqlCheckDbIsEmpty(): invalid number of parameters" - exit 1 - fi - - local root_password="${1}" - local database=$2 - echoAndLog "mysqlCheckDbIsEmpty(): checking if $database is empty..." - num_tablas=`echo "show tables" | mysql -uroot -p"${root_password}" "${database}" | wc -l` - if [ $? -ne 0 ]; then - errorAndLog "mysqlCheckDbIsEmpty(): error executing query, check database and root password" - exit 1 - fi - - if [ $num_tablas -eq 0 ]; then - echoAndLog "mysqlCheckDbIsEmpty():database $database is empty" - return 0 - else - echoAndLog "mysqlCheckDbIsEmpty():database $database has tables" - return 1 - fi - -} - - -function mysqlImportSqlFileToDb() -{ - if [ $# -ne 3 ]; then - errorAndLog "${FNCNAME}(): invalid number of parameters" - exit 1 - fi - - local root_password="${1}" - local database=$2 - local sqlfile=$3 - - if [ ! -f $sqlfile ]; then - errorAndLog "${FUNCNAME}(): Unable to locate $sqlfile!!" - return 1 - fi - - echoAndLog "${FUNCNAME}(): importing sql file to ${database}..." - perl -pi -e "s/SERVERIP/$SERVERIP/g; s/DEFAULTUSER/$OPENGNSYS_DB_DEFAULTUSER/g; s/DEFAULTPASSWD/$OPENGNSYS_DB_DEFAULTPASSWD/g" $sqlfile - mysql -uroot -p"${root_password}" --default-character-set=utf8 "${database}" < $sqlfile - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while importing $sqlfile in database $database" - return 1 - fi - echoAndLog "${FUNCNAME}(): file imported to database $database" - return 0 -} - -# Crea la base de datos -function mysqlCreateDb() -{ - if [ $# -ne 2 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - local root_password="${1}" - local database=$2 - - echoAndLog "${FUNCNAME}(): creating database..." - mysqladmin -u root --password="${root_password}" create $database - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while creating database $database" - return 1 - fi - echoAndLog "${FUNCNAME}(): database $database created" - return 0 -} - - -function mysqlCheckUserExists() -{ - if [ $# -ne 2 ]; then - errorAndLog "mysqlCheckUserExists(): invalid number of parameters" - exit 1 - fi - - local root_password="${1}" - local userdb=$2 - - echoAndLog "mysqlCheckUserExists(): checking if $userdb exists..." - echo "select user from user where user='${userdb}'\\G" |mysql -uroot -p"${root_password}" mysql | grep user - if [ $? -ne 0 ]; then - echoAndLog "mysqlCheckUserExists(): user doesn't exists" - return 1 - else - echoAndLog "mysqlCheckUserExists(): user already exists" - return 0 - fi - -} - -# Crea un usuario administrativo para la base de datos -function mysqlCreateAdminUserToDb() -{ - if [ $# -ne 4 ]; then - errorAndLog "mysqlCreateAdminUserToDb(): invalid number of parameters" - exit 1 - fi - - local root_password=$1 - local database=$2 - local userdb=$3 - local passdb=$4 - - echoAndLog "mysqlCreateAdminUserToDb(): creating admin user ${userdb} to database ${database}" - - cat > $WORKDIR/create_${database}.sql <<EOF -GRANT USAGE ON *.* TO '${userdb}'@'localhost' IDENTIFIED BY '${passdb}' ; -GRANT ALL PRIVILEGES ON ${database}.* TO '${userdb}'@'localhost' WITH GRANT OPTION ; -FLUSH PRIVILEGES ; -EOF - mysql -u root --password=${root_password} < $WORKDIR/create_${database}.sql - if [ $? -ne 0 ]; then - errorAndLog "mysqlCreateAdminUserToDb(): error while creating user in mysql" - rm -f $WORKDIR/create_${database}.sql - return 1 - else - echoAndLog "mysqlCreateAdminUserToDb(): user created ok" - rm -f $WORKDIR/create_${database}.sql - return 0 - fi -} - - -##################################################################### -####### Funciones para el manejo de Subversion -##################################################################### - -function svnExportCode() -{ - if [ $# -ne 1 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - local url=$1 - - echoAndLog "${FUNCNAME}(): downloading subversion code..." - - svn export "${url}" opengnsys - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password" - return 1 - fi - echoAndLog "${FUNCNAME}(): subversion code downloaded" - return 0 -} - - -############################################################ -### Detectar red -############################################################ - -function getNetworkSettings() -{ - # Variables globales definidas: - # - SERVERIP: IP local del servidor. - # - NETIP: IP de la red. - # - NETMASK: máscara de red. - # - NETBROAD: IP de difusión de la red. - # - ROUTERIP: IP del router. - # - DNSIP: IP del servidor DNS. - - local MAINDEV - - echoAndLog "${FUNCNAME}(): Detecting default network parameters." - MAINDEV=$(ip -o link show up | awk '!/loopback/ {d=d$2} END {sub(/:.*/,"",d); print d}') - if [ -z "$MAINDEV" ]; then - errorAndLog "${FUNCNAME}(): Network device not detected." - exit 1 - fi - SERVERIP=$(ip -o addr show dev $MAINDEV | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}') - NETMASK=$(LANG=C ifconfig $MAINDEV | awk '/Mask/ {sub(/.*:/,"",$4); print $4}') - NETBROAD=$(ip -o addr show dev $MAINDEV | awk '$3~/inet$/ {print ($6)}') - NETIP=$(netstat -nr | grep $MAINDEV | awk '$1!~/0\.0\.0\.0/ {if (n=="") n=$1} END {print n}') - ROUTERIP=$(netstat -nr | awk '$1~/0\.0\.0\.0/ {print $2}') - DNSIP=$(awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n1) - if [ -z "$NETIP" -o -z "$NETMASK" ]; then - errorAndLog "${FUNCNAME}(): Network not detected." - exit 1 - fi - - # Variables de ejecución de Apache - # - APACHE_RUN_USER - # - APACHE_RUN_GROUP - if [ -f /etc/apache2/envvars ]; then - source /etc/apache2/envvars - fi - APACHE_RUN_USER=${APACHE_RUN_USER:-"www-data"} - APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"www-data"} -} - - -############################################################ -### Esqueleto para el Servicio pxe y contenedor tftpboot ### -############################################################ - -function tftpConfigure() { - echo "Configurando el servicio tftp" - basetftp=/var/lib/tftpboot - - # reiniciamos demonio internet ????? porque ???? - /etc/init.d/openbsd-inetd start - - # preparacion contenedor tftpboot - cp -pr /usr/lib/syslinux/ ${basetftp}/syslinux - cp /usr/lib/syslinux/pxelinux.0 ${basetftp} - # prepamos el directorio de la configuracion de pxe - mkdir -p ${basetftp}/pxelinux.cfg - cat > ${basetftp}/pxelinux.cfg/default <<EOF -DEFAULT pxe - -LABEL pxe -KERNEL linux -APPEND initrd=initrd.gz ip=dhcp ro vga=788 irqpoll acpi=on -EOF - # comprobamos el servicio tftp - sleep 1 - testPxe - ## damos perfimos de lectura a usuario web. - chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP ${basetftp} -} - -function testPxe () { - cd /tmp - echo "comprobando servicio pxe ..... Espere" - tftp -v localhost -c get pxelinux.0 /tmp/pxelinux.0 && echo "servidor tftp OK" || echo "servidor tftp KO" - cd / -} - -######################################################################## -## Configuracion servicio NFS -######################################################################## - -# ADVERTENCIA: usa variables globales NETIP y NETMASK! -function nfsConfigure() -{ - echoAndLog "${FUNCNAME}(): Config nfs server." - - backupFile /etc/exports - - nfsAddExport /opt/opengnsys/client ${NETIP}/${NETMASK}:ro,no_subtree_check,no_root_squash,sync - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while adding nfs client config" - return 1 - fi - - nfsAddExport /opt/opengnsys/images ${NETIP}/${NETMASK}:rw,no_subtree_check,no_root_squash,sync,crossmnt - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while adding nfs images config" - return 1 - fi - - nfsAddExport /opt/opengnsys/log/clients ${NETIP}/${NETMASK}:rw,no_subtree_check,no_root_squash,sync - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while adding logging client config" - return 1 - fi - - /etc/init.d/nfs-kernel-server restart - - exportfs -va - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while configure exports" - return 1 - fi - - echoAndLog "${FUNCNAME}(): Added NFS configuration to file \"/etc/exports\"." - return 0 -} - - -# ejemplos: -#nfsAddExport /opt/opengnsys 192.168.0.0/255.255.255.0:ro,no_subtree_check,no_root_squash,sync -#nfsAddExport /opt/opengnsys 192.168.0.0/255.255.255.0 -#nfsAddExport /opt/opengnsys 80.20.2.1:ro 192.123.32.2:rw -function nfsAddExport() -{ - if [ $# -lt 2 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - if [ ! -f /etc/exports ]; then - errorAndLog "${FUNCNAME}(): /etc/exports don't exists" - return 1 - fi - - local export="${1}" - local contador=0 - local cadenaexport - - grep "^${export}" /etc/exports > /dev/null - if [ $? -eq 0 ]; then - echoAndLog "${FUNCNAME}(): $export exists in /etc/exports, omiting" - return 0 - fi - - cadenaexport="${export}" - for parametro in $* - do - if [ $contador -gt 0 ] - then - host=`echo $parametro | awk -F: '{print $1}'` - options=`echo $parametro | awk -F: '{print $2}'` - if [ "${host}" == "" ]; then - errorAndLog "${FUNCNAME}(): host can't be empty" - return 1 - fi - cadenaexport="${cadenaexport}\t${host}" - - if [ "${options}" != "" ]; then - cadenaexport="${cadenaexport}(${options})" - fi - fi - let contador=contador+1 - done - - echo -en "$cadenaexport\n" >> /etc/exports - - echoAndLog "${FUNCNAME}(): add $export to /etc/exports" - - return 0 -} - -######################################################################## -## Configuracion servicio DHCP -######################################################################## - -function dhcpConfigure() -{ - echoAndLog "${FUNCNAME}(): Sample DHCP Configuration." - - backupFile /etc/dhcp3/dhcpd.conf - - sed -e "s/SERVERIP/$SERVERIP/g" \ - -e "s/NETIP/$NETIP/g" \ - -e "s/NETMASK/$NETMASK/g" \ - -e "s/NETBROAD/$NETBROAD/g" \ - -e "s/ROUTERIP/$ROUTERIP/g" \ - -e "s/DNSIP/$DNSIP/g" \ - $WORKDIR/opengnsys/server/DHCP/dhcpd.conf > /etc/dhcp3/dhcpd.conf - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while configuring dhcp server" - return 1 - fi - - /etc/init.d/dhcp3-server restart - echoAndLog "${FUNCNAME}(): Sample DHCP Configured in file \"/etc/dhcp3/dhcpd.conf\"." - return 0 -} - - -##################################################################### -####### Funciones especÃficas de la instalación de Opengnsys -##################################################################### - -# Copiar ficheros del OpenGnSys Web Console. -function installWebFiles() -{ - echoAndLog "${FUNCNAME}(): Installing web files..." - cp -ar $WORKDIR/opengnsys/admin/WebConsole/* $INSTALL_TARGET/www #*/ comentario para doxigen - if [ $? != 0 ]; then - errorAndLog "${FUNCNAME}(): Error copying web files." - exit 1 - fi - find $INSTALL_TARGET/www -name .svn -type d -exec rm -fr {} \; 2>/dev/null - # Cambiar permisos para ficheros especiales. - chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP \ - $INSTALL_TARGET/www/includes \ - $INSTALL_TARGET/www/comandos/gestores/filescripts \ - $INSTALL_TARGET/www/images/iconos - echoAndLog "${FUNCNAME}(): Web files installed successfully." -} - -# Configuración especÃfica de Apache. -function openGnsysInstallWebConsoleApacheConf() -{ - if [ $# -ne 2 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - local path_opengnsys_base=$1 - local path_apache2_confd=$2 - local path_web_console=${path_opengnsys_base}/www - - if [ ! -d $path_apache2_confd ]; then - errorAndLog "${FUNCNAME}(): path to apache2 conf.d can not found, verify your server installation" - return 1 - fi - - mkdir -p $path_apache2_confd/{sites-available,sites-enabled} - - echoAndLog "${FUNCNAME}(): creating apache2 config file.." - - - # genera configuración - cat > $path_opengnsys_base/etc/apache.conf <<EOF -# OpenGnSys Web Console configuration for Apache - -Alias /opengnsys ${path_web_console} - -<Directory ${path_web_console}> - Options -Indexes FollowSymLinks - DirectoryIndex acceso.php -</Directory> -EOF - - ln -fs $path_opengnsys_base/etc/apache.conf $path_apache2_confd/sites-available/opengnsys.conf - ln -fs $path_apache2_confd/sites-available/opengnsys.conf $path_apache2_confd/sites-enabled/opengnsys.conf - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): config file can't be linked to apache conf, verify your server installation" - return 1 - else - echoAndLog "${FUNCNAME}(): config file created and linked, restarting apache daemon" - /etc/init.d/apache2 restart - return 0 - fi -} - -# Crear documentación Doxygen para la consola web. -function makeDoxygenFiles() -{ - echoAndLog "${FUNCNAME}(): Making Doxygen web files..." - $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \ - $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www - if [ ! -d "$INSTALL_TARGET/www/html" ]; then - errorAndLog "${FUNCNAME}(): unable to create Doxygen web files." - return 1 - fi - mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api" - chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api - echoAndLog "${FUNCNAME}(): Doxygen web files created successfully." -} - - -# Crea la estructura base de la instalación de opengnsys -function openGnsysInstallCreateDirs() -{ - if [ $# -ne 1 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - local path_opengnsys_base=$1 - - echoAndLog "${FUNCNAME}(): creating directory paths in $path_opengnsys_base" - - mkdir -p $path_opengnsys_base - mkdir -p $path_opengnsys_base/admin/{autoexec,comandos,menus,usuarios} - mkdir -p $path_opengnsys_base/bin - mkdir -p $path_opengnsys_base/client - mkdir -p $path_opengnsys_base/doc - mkdir -p $path_opengnsys_base/etc - mkdir -p $path_opengnsys_base/lib - mkdir -p $path_opengnsys_base/log/clients - mkdir -p $path_opengnsys_base/sbin - mkdir -p $path_opengnsys_base/www - mkdir -p $path_opengnsys_base/images - ln -fs /var/lib/tftpboot $path_opengnsys_base - ln -fs $path_opengnsys_base/log /var/log/opengnsys - - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?" - return 1 - fi - - echoAndLog "${FUNCNAME}(): directory paths created" - return 0 -} - -# Copia ficheros de configuración y ejecutables genéricos del servidor. -function openGnsysCopyServerFiles () { - if [ $# -ne 1 ]; then - errorAndLog "${FUNCNAME}(): invalid number of parameters" - exit 1 - fi - - local path_opengnsys_base=$1 - - local SOURCES=( client/boot/initrd-generator \ - client/boot/upgrade-clients-udeb.sh \ - client/boot/udeblist.conf \ - client/boot/udeblist-jaunty.conf \ - client/boot/udeblist-karmic.conf \ - client/boot/udeblist-lucid.conf \ - server/PXE/pxelinux.cfg/default \ - doc ) - local TARGETS=( bin/initrd-generator \ - bin/upgrade-clients-udeb.sh \ - etc/udeblist.conf \ - etc/udeblist-jaunty.conf \ - etc/udeblist-karmic.conf \ - etc/udeblist-lucid.conf \ - tftpboot/pxelinux.cfg/default \ - doc ) - - if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then - errorAndLog "${FUNCNAME}(): inconsistent number of array items" - exit 1 - fi - - echoAndLog "${FUNCNAME}(): copying files to server directories" - - pushd $WORKDIR/opengnsys - local i - for (( i = 0; i < ${#SOURCES[@]}; i++ )); do - if [ -f "${SOURCES[$i]}" ]; then - echoAndLog "Copying ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}" - cp -p "${SOURCES[$i]}" "${path_opengnsys_base}/${TARGETS[$i]}" - elif [ -d "${SOURCES[$i]}" ]; then - echoAndLog "Copying content of ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}" - cp -a "${SOURCES[$i]}"/* "${path_opengnsys_base}/${TARGETS[$i]}" - else - echoAndLog "Warning: Unable to copy ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}" - fi - done - popd -} - -#################################################################### -### Funciones de compilación de códifo fuente de servicios -#################################################################### - -# Compilar los servicios de OpenGNsys -function servicesCompilation () -{ - local hayErrores=0 - - # Compilar OpenGnSys Server - echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Admin Server" - pushd $WORKDIR/opengnsys/admin/Services/ogAdmServer - make && make install - if [ $? -ne 0 ]; then - echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Server" - hayErrores=1 - fi - popd - # Compilar OpenGnSys Repository Manager - echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Repository Manager" - pushd $WORKDIR/opengnsys/admin/Services/ogAdmRepo - make && make install - if [ $? -ne 0 ]; then - echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Repository Manager" - hayErrores=1 - fi - popd - # Compilar OpenGnSys Client - echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Admin Client" - pushd $WORKDIR/opengnsys/admin/Services/ogAdmClient - make && mv ogAdmClient ../../../client/nfsexport/bin - if [ $? -ne 0 ]; then - echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Client" - hayErrores=1 - fi - popd - - return $hayErrores -} - - -#################################################################### -### Funciones instalacion cliente opengnsys -#################################################################### - -function openGnsysClientCreate() -{ - local OSDISTRIB OSCODENAME - - local hayErrores=0 - - echoAndLog "${FUNCNAME}(): Copying OpenGnSys Client files." - cp -ar $WORKDIR/opengnsys/client/nfsexport/* $INSTALL_TARGET/client - find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null - echoAndLog "${FUNCNAME}(): Copying OpenGnSys Cloning Engine files." - mkdir -p $INSTALL_TARGET/client/lib/engine/bin - cp -ar $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while copying engine files" - hayErrores=1 - fi - - # Cargar Kernel, Initrd y paquetes udeb para la distribución del servidor (o por defecto). - OSDISTRIB=$(lsb_release -i | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null - OSCODENAME=$(lsb_release -c | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null - if [ "$OSDISTRIB" = "Ubuntu" -a -n "$OSCODENAME" ]; then - echoAndLog "${FUNCNAME}(): Loading Kernel and Initrd files for $OSDISTRIB $OSCODENAME." - $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot -v "$OSCODENAME" - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while generating initrd OpenGnSys Admin Client" - hayErrores=1 - fi - echoAndLog "${FUNCNAME}(): Loading udeb files for $OSDISTRIB $OSCODENAME." - $INSTALL_TARGET/bin/upgrade-clients-udeb.sh "$OSCODENAME" - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while upgrading udeb files OpenGnSys Admin Client" - hayErrores=1 - fi - else - echoAndLog "${FUNCNAME}(): Loading default Kernel and Initrd files." - $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot/ - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while generating initrd OpenGnSys Admin Client" - hayErrores=1 - fi - echoAndLog "${FUNCNAME}(): Loading default udeb files." - $INSTALL_TARGET/bin/upgrade-clients-udeb.sh - if [ $? -ne 0 ]; then - errorAndLog "${FUNCNAME}(): error while upgrading udeb files OpenGnSys Admin Client" - hayErrores=1 - fi - fi - - if [ $hayErrores -eq 0 ]; then - echoAndLog "${FUNCNAME}(): Client generation success." - else - errorAndLog "${FUNCNAME}(): Client generation with errors" - fi - - return $hayErrores -} - - -# Configuración básica de servicios de OpenGnSys -function openGnsysConfigure() -{ - echoAndLog "openGnsysConfigure(): Copying init files." - cp -p $WORKDIR/opengnsys/admin/Services/opengnsys.init /etc/init.d/opengnsys - cp -p $WORKDIR/opengnsys/admin/Services/opengnsys.default /etc/default/opengnsys - update-rc.d opengnsys defaults - echoAndLog "openGnsysConfigure(): Creating OpenGnSys config file in \"$INSTALL_TARGET/etc\"." - perl -pi -e "s/SERVERIP/$SERVERIP/g" $INSTALL_TARGET/etc/ogAdmServer.cfg - perl -pi -e "s/SERVERIP/$SERVERIP/g" $INSTALL_TARGET/etc/ogAdmRepo.cfg - echoAndLog "${FUNCNAME}(): Creating Web Console config file" - OPENGNSYS_CONSOLEURL="http://$SERVERIP/opengnsys" - perl -pi -e "s/SERVERIP/$SERVERIP/g; s/OPENGNSYSURL/${OPENGNSYS_CONSOLEURL//\//\\/}/g" $INSTALL_TARGET/www/controlacceso.php - sed -e "s/SERVERIP/$SERVERIP/g" -e "s/OPENGNSYSURL/${OPENGNSYS_CONSOLEURL//\//\\/}/g" $WORKDIR/opengnsys/admin/Services/ogAdmClient/ogAdmClient.cfg > $INSTALL_TARGET/client/etc/ogAdmClient.cfg - echoAndLog "openGnsysConfiguration(): Starting OpenGnSys services." - /etc/init.d/opengnsys start -} - - -##################################################################### -####### Función de resumen informativo de la instalación -##################################################################### - -function installationSummary(){ - echo - echoAndLog "OpenGnSys Installation Summary" - echo "==============================" - echoAndLog "Project version: $(cat $INSTALL_TARGET/doc/VERSION.txt 2>/dev/null)" - echoAndLog "Installation directory: $INSTALL_TARGET" - echoAndLog "Repository directory: $INSTALL_TARGET/images" - echoAndLog "TFTP configuracion directory: /var/lib/tftpboot" - echoAndLog "DHCP configuracion file: /etc/dhcp3/dhcpd.conf" - echoAndLog "NFS configuracion file: /etc/exports" - echoAndLog "Web Console URL: $OPENGNSYS_CONSOLEURL" - echoAndLog "Web Console admin user: $OPENGNSYS_DB_USER" - echoAndLog "Web Console admin password: $OPENGNSYS_DB_PASSWD" - echoAndLog "Web Console default user: $OPENGNSYS_DB_DEFAULTUSER" - echoAndLog "Web Console default password: $OPENGNSYS_DB_DEFAULTPASSWD" - echo - echoAndLog "Post-Installation Instructions:" - echo "===============================" - echoAndLog "Review or edit all configuration files." - echoAndLog "Insert DHCP configuration data and restart service." - echoAndLog "Log-in as Web Console admin user." - echoAndLog " - Review default Organization data and default user." - echoAndLog "Log-in as Web Console organization user." - echoAndLog " - Insert OpenGnSys data (rooms, computers, etc)." -echo -} - diff --git a/client/engine/Boot.lib b/client/engine/Boot.lib index 8731580f..e21935ca 100755 --- a/client/engine/Boot.lib +++ b/client/engine/Boot.lib @@ -20,10 +20,10 @@ #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. #@exception OG_ERR_NOTOS La partición no tiene instalado un sistema operativo. #@note En Linux, debe arrancarse la partición del directorio \c /boot -#@version 0.1 - Integracion para OpenGNSys. - EAC: HDboot(); BootLinuxEX() en Boot.lib +#@version 0.1 - Integración para OpenGnSys. - EAC: HDboot; BootLinuxEX en Boot.lib #@author Antonio J. Doblas Viso, Universidad de Malaga #@date 2008-10-27 -#@version 0.9 - Adaptacion para OpenGNSys. +#@version 0.9 - Adaptación para OpenGnSys. #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009-09-11 #*/ ## @@ -68,21 +68,19 @@ case "$TYPE" in [ -z "$LOADER" ] && ogRaiseError $OG_ERR_NOTOS && return $? # Activar la partición y copiar Grub4DOS. ogSetPartitionActive $1 $2 - #FIXME: activar seguimiento inicio sesion XP con grub4dos - #if `ogGetOsVersion $1 $2 | grep "XP" > /dev/null` - #then - # dd if=/dev/zero of=${MNTDIR}/ogboot.me bs=1024 count=3 - # dd if=/dev/zero of=${MNTDIR}/ogboot.firstboot bs=1024 count=3 - # dd if=/dev/zero of=${MNTDIR}/ogboot.secondboot bs=1024 count=3 - # ogLoadHiveWindows $1 $2 - # ogHiveNTRunMachine "cmd /c del c:\ogboot.* " ogcleanboot - # ogUpdateHiveWindows - # reboot - #else - cp $OGLIB/grub4dos/* $MNTDIR # */ (Comentario Doxygen) - ##kexec -l $MNTDIR/grub.exe --append=--config-file="find --set-root /$LOADER; chainloader /$LOADER; tpm --init" - kexec -l $MNTDIR/grub.exe --append=--config-file="root (hd$[$1-1],$[$2-1]); chainloader (hd$[$1-1],$[$2-1])/$LOADER; tpm --init" - #fi + #FIXME: activar seguimiento inicio sesion Windows con grub4dos + if [ "$(ogGetOsType $1 $2)" == "Windows" ]; then + dd if=/dev/zero of=${MNTDIR}/ogboot.me bs=1024 count=3 + dd if=/dev/zero of=${MNTDIR}/ogboot.firstboot bs=1024 count=3 + dd if=/dev/zero of=${MNTDIR}/ogboot.secondboot bs=1024 count=3 + ogLoadHiveWindows $1 $2 + ogHiveNTRunMachine "cmd /c del c:\ogboot.*" ogcleanboot + ogUpdateHiveWindows + reboot + else + cp $OGLIB/grub4dos/* $MNTDIR # */ (Comentario Doxygen) + kexec -l $MNTDIR/grub.exe --append=--config-file="root (hd$[$1-1],$[$2-1]); chainloader (hd$[$1-1],$[$2-1])/$LOADER; tpm --init" + fi ;; *) ogRaiseError $OG_ERR_PARTITION "$1, $2" return $? @@ -103,7 +101,7 @@ kexec -e #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Adaptación para OpenGNSys. +#@version 0.9 - Adaptación para OpenGnSys. #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009-09-23 #*/ ## @@ -140,7 +138,7 @@ ogGetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerN #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. #@warning Función básica usada por \c ogBoot -#@version 0.9 - Primera adaptación para OpenGNSys. +#@version 0.9 - Primera adaptación para OpenGnSys. #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009-09-11 #@version 0.9.2 - Soporta partición /boot independiente. @@ -202,7 +200,7 @@ awk 'BEGIN {cont=-1;} #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Adaptación a OpenGNSys. +#@version 0.9 - Adaptación a OpenGnSys. #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009-09-24 #*/ ## @@ -244,7 +242,7 @@ ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\NV H #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9.2 - Adaptación a OpenGNSys. +#@version 0.9.2 - Adaptación a OpenGnSys. #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2010-07-20 #*/ ## @@ -279,7 +277,7 @@ ogSetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows NT\CurrentVersion\Winlog #@return salida del programa my-sys #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Adaptación a OpenGNSys. +#@version 0.9 - Adaptación a OpenGnSys. #@author Antonio J. Doblas Viso. Universidad de Málaga #@date 2009-09-24 #*/ ## @@ -311,7 +309,7 @@ ms-sys -m -f $PART #@return salida del programa my-sys #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Adaptación a OpenGNSys. +#@version 0.9 - Adaptación a OpenGnSys. #@author Antonio J. Doblas Viso. Universidad de Málaga #@date 2009-09-24 #*/ ## @@ -346,7 +344,7 @@ ms-sys -s -f $PART #@return #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Adaptación a OpenGNSys. +#@version 0.9 - Adaptación a OpenGnSys. #@author Antonio J. Doblas Viso. Universidad de Málaga #@date 2009-09-24 #*/ ## @@ -354,7 +352,7 @@ ms-sys -s -f $PART function ogFixBootSector () { # Variables locales. -local PART DISK FILE +local PARTYPE DISK PART FILE # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -369,7 +367,7 @@ fi #TODO, solo si la particion existe #TODO, solo si es ntfs o fat PARTYPE=$(ogGetPartitionId $1 $2) -case $PARTYPE in +case "$PARTYPE" in 1|4|6|7|b|c|e|f) ;; *) @@ -382,15 +380,17 @@ ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) #Preparando instruccion let DISK=$1-1 PART=$2 -FILE=/tmp/temporal +FILE=/tmp/temp$$ cat > $FILE <<EOF disk=$DISK main_part=$PART fix_first_sector=yes EOF -spartlnx.run -cui -nm -a -f $FILE - +spartlnx.run -cui -nm -a -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null +rm -f $FILE } @@ -403,7 +403,7 @@ spartlnx.run -cui -nm -a -f $FILE #@return #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Integración desde EAC para OpenGNSys. +#@version 0.9 - Integración desde EAC para OpenGnSys. #@author Antonio J. Doblas Viso. Universidad de Málaga #@date 2009-09-24 #@version 1.0.1 - Adapatacion para OpenGnsys. @@ -415,11 +415,11 @@ spartlnx.run -cui -nm -a -f $FILE function ogWindowsBootParameters () { # Variables locales. -local PART DISK FILE +local PART DISK FILE VERSION WINVER MOUNT #Preparando variables adaptadas a sintaxis windows. let DISK=$1-1 PART=$2 -FILE=/tmp/temporal +FILE=/tmp/temp$$ # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -462,7 +462,11 @@ disk=$DISK main_part=$PART boot_entry=Windows Resume Application EOF -spartlnx.run -cui -nm -w -f $FILE +spartlnx.run -cui -nm -w -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null + + #Preparando instruccion tipo windows cat > $FILE <<EOF @@ -472,17 +476,23 @@ disk=$DISK main_part=$PART boot_entry=$WINVER EOF -spartlnx.run -cui -nm -w -f $FILE +spartlnx.run -cui -nm -w -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null + ##Preparando instruccion Ramdisk Options -#cat > $FILE <<EOF -#boot_disk=$DISK -#boot_main_part=$PART -#disk=$DISK -#main_part=$PART -#boot_entry=Ramdisk Options -#EOF -#spartlnx.run -cui -nm -w -f $FILE +cat > $FILE <<EOF +boot_disk=$DISK +boot_main_part=$PART +disk=$DISK +main_part=$PART +boot_entry=Ramdisk Options +EOF +spartlnx.run -cui -nm -w -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null + #Preparando instruccion Windows Boot Manager cat > $FILE <<EOF @@ -492,20 +502,25 @@ disk=$DISK main_part=$PART boot_entry=Windows Boot Manager EOF -spartlnx.run -cui -nm -w -f $FILE +spartlnx.run -cui -nm -w -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null + #Preparando instruccion Herramienta de diagnóstico de memoria de Windows -#cat > $FILE <<EOF -#boot_disk=$DISK -#boot_main_part=$PART -#disk=$DISK -#main_part=$PART -#boot_entry=Herramienta de diagnóstico de memoria de Windows -#EOF -#spartlnx.run -cui -nm -w -f $FILE +cat > $FILE <<EOF +boot_disk=$DISK +boot_main_part=$PART +disk=$DISK +main_part=$PART +boot_entry=Herramienta de diagnóstico de memoria de Windows +EOF +spartlnx.run -cui -nm -w -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null } - + # ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition #@brief Registra una partición en windows con un determinado volumen. @@ -517,16 +532,14 @@ spartlnx.run -cui -nm -w -f $FILE #@return #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. -#@version 0.9 - Adaptación a OpenGNSys. +#@version 0.9 - Adaptación a OpenGnSys. #@author Antonio J. Doblas Viso. Universidad de Málaga #@date 2009-09-24 #*/ ## - - function ogWindowsRegisterPartition () -{ +{ # Variables locales. -local PART DISK FILE +local PART DISK FILE REGISTREDDISK REGISTREDPART REGISTREDVOL VERSION SYSTEMROOT # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -543,7 +556,7 @@ REGISTREDPART=$2 REGISTREDVOL=$(echo $3 | cut -c1 | tr '[:lower:]' '[:upper:]') DISK=$4 PART=$5 -FILE=/tmp/temporal +FILE=/tmp/temp$$ ogDiskToDev $REGISTREDDISK $REGISTREDPART || return $(ogRaiseError $OG_ERR_PARTITION "particion a registrar "; echo $?) ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows"; echo $?) @@ -577,5 +590,78 @@ main_part=$REGISTREDPART ;ext_part part_letter=$REGISTREDVOL EOF -spartlnx.run -cui -nm -u -f $FILE +spartlnx.run -cui -nm -u -f $FILE & +sleep 5 +ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null + } + + +# ogGrubInstallPartition int_disk int_partition +#@brief Instala/actualiza el gestro grub en el "boot sector" de la partición indicada +#@param int_disk +#@param indt_part +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 1.0.2 - Primeras pruebas. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011-10-29 +#*/ ## + +function ogGrubInstallPartition { + +# Variables locales. +local PART DISK DIRCONF SCHROOTDEVICE + +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \ + "$FUNCNAME 1 1 " + return +fi + +# Error si no se reciben 2 parámetros. +[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) + +DISK=$1; PART=$2; DIRCONF="/etc/schroot" + + +VERSION=$(ogGetOsVersion $DISK $PART) +echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?) + +SCHROOTLOCATION=$(ogMount $DISK $PART) +SCHROOTDEVICE=$(ogDiskToDev $DISK $PART) + +rm ${DIRCONF}/schroot.conf + +cat >> ${DIRCONF}/schroot.conf << EOF +[linux] +description=$VERSION +type=plain +directory=$SCHROOTLOCATION +EOF + +cat >> $SCHROOTLOCATION/root/installgrub.sh <<EOF +#!/bin/bash +grub-install --recheck --force $SCHROOTDEVICE +update-grub2 +EOF + +chmod 777 $SCHROOTLOCATION/root/installgrub.sh + +mount --bind /dev $SCHROOTLOCATION/dev +mount --bind /dev/pts $SCHROOTLOCATION/dev/pts +mount --bind /proc $SCHROOTLOCATION/proc +mount --bind /sys $SCHROOTLOCATION/sys + + +schroot -c linux -- /root/installgrub.sh + +rm $SCHROOTLOCATION/root/installgrub.sh + +umount $SCHROOTLOCATION/dev/pts +umount $SCHROOTLOCATION/dev +umount $SCHROOTLOCATION/proc +umount $SCHROOTLOCATION/sys +} + diff --git a/client/engine/Disk.lib b/client/engine/Disk.lib index f15f1e08..6b642b38 100755 --- a/client/engine/Disk.lib +++ b/client/engine/Disk.lib @@ -319,7 +319,7 @@ local DISK # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" \ "$FUNCNAME 1 => 244198584" + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk" "$FUNCNAME 1 => 244198584" return fi # Error si no se recibe 1 parámetro. @@ -467,6 +467,59 @@ esac #/** +# ogGetPartitionType int_ndisk int_npartition +#@brief Muestra el tipo de una particion determinada. +#@see ogGetFsType +#*/ ## +function ogGetPartitionType () +{ +ogGetFsType "$@" +} + + +#/** +# ogHidePartition int_ndisk int_npartition +#@brief Oculta un apartición visible. +#@param int_ndisk nº de orden del disco +#@param int_npartition nº de orden de la partición +#@return (nada) +#@exception OG_ERR_FORMAT formato incorrecto. +#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). +#@exception OG_ERR_PARTITION tipo de partición no reconocido. +#@version 1.0 - Versión en pruebas. +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2010/01/12 +#*/ ## +function ogHidePartition () +{ +# Variables locales. +local PART TYPE NEWTYPE +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ + "$FUNCNAME 1 1" + return +fi +# Error si no se reciben 2 parámetros. +[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? +PART=$(ogDiskToDev "$1" "$2") || return $? + +# Obtener tipo de partición. +TYPE=$(ogGetPartitionType "$1" "$2") +case "$TYPE" in + NTFS) NEWTYPE="HNTFS" ;; + FAT32) NEWTYPE="HFAT32" ;; + FAT16) NEWTYPE="HFAT16" ;; + FAT12) NEWTYPE="HFAT12" ;; + *) ogRaiseError $OG_ERR_PARTITION "$TYPE" + return $? ;; +esac +# Cambiar tipo de partición. +ogSetPartitionId $1 $2 $NEWTYPE +} + + +#/** # ogListPartitions int_ndisk #@brief Lista las particiones definidas en un disco. #@param int_ndisk nº de orden del disco @@ -613,11 +666,52 @@ DISK="$(ogDiskToDev $1)" || return $? PART="$(ogDiskToDev $1 $2)" || return $? # Convertir tamaño en KB a sectores de 512 B. SIZE=$[$3*2] || ogRaiseError $OG_ERR_FORMAT || return $? -# Usar \c sfdisk para redefinir el tamaño. +# Redefinir el tamaño de la partición. sfdisk -f -uS -N$2 $DISK <<< ",$SIZE" &>/dev/null || ogRaiseError $OG_ERR_PARTITION "$1,$2" || return $? partprobe 2>/dev/null } +#/** +# ogUnhidePartition int_ndisk int_npartition +#@brief Hace visible una partición oculta. +#@param int_ndisk nº de orden del disco +#@param int_npartition nº de orden de la partición +#@return (nada) +#@exception OG_ERR_FORMAT formato incorrecto. +#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). +#@exception OG_ERR_PARTITION tipo de partición no reconocido. +#@version 1.0 - Versión en pruebas. +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2010/01/12 +#*/ ## +function ogUnhidePartition () +{ +# Variables locales. +local PART TYPE NEWTYPE +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ + "$FUNCNAME 1 1" + return +fi +# Error si no se reciben 2 parámetros. +[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? +PART=$(ogDiskToDev "$1" "$2") || return $? + +# Obtener tipo de partición. +TYPE=$(ogGetPartitionType "$1" "$2") +case "$TYPE" in + HNTFS) NEWTYPE="NTFS" ;; + HFAT32) NEWTYPE="FAT32" ;; + HFAT16) NEWTYPE="FAT16" ;; + HFAT12) NEWTYPE="FAT12" ;; + *) ogRaiseError $OG_ERR_PARTITION "$TYPE" + return $? ;; +esac +# Cambiar tipo de partición. +ogSetPartitionId $1 $2 $NEWTYPE +} + #/** # ogUpdatePartitionTable @@ -629,10 +723,10 @@ partprobe 2>/dev/null #@version 0.1 - Integracion para Opengnsys - EAC: UpdatePartitionTable() en ATA.lib #@author Antonio J. Doblas Viso. Universidad de Malaga #@date 27/10/2008 -#*/ - +#*/ ## function ogUpdatePartitionTable () { +local i for i in `ogDiskToDev` do partprobe $i @@ -641,10 +735,12 @@ done -#/** @function ogGetPartitionsNumber: @brief detecta el numero de particiones del disco duro indicado. -#@param int_numdisk (indentificado EAC del disco) -#@return devuelve el numero paritiones del disco duro indicado -#@warning Salidas de errores no determinada +#/** +# ogGetPartitionsNumber int_ndisk +#@brief Detecta el numero de particiones del disco duro indicado. +#@param int_ndisk nº de orden del disco +#@return Devuelve el numero paritiones del disco duro indicado +#@warning Salidas de errores no determinada #@attention Requisitos: parted #@note Notas sin especificar #@version 0.1 - Integracion para Opengnsys - EAC: DetectNumberPartition () en ATA.lib @@ -653,14 +749,15 @@ done #@version 1.0 - Uso de sfdisk Primera version para OpenGnSys #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009/07/24 -#*/ -function ogGetPartitionsNumber () { +#*/ ## +function ogGetPartitionsNumber () +{ #local disco totalpart #disco=`ogDiskToDev $1` #totalpart=`parted $disco print | egrep ^" [0123456789] " -c` #echo $totalpart local DISK -#/// Contar el nº de veces que aparece el disco en su lista de particiones. +# Contar el nº de veces que aparece el disco en su lista de particiones. DISK=$(ogDiskToDev $1) 2>/dev/null sfdisk -l $DISK 2>/dev/null | grep -c "^$DISK" } diff --git a/client/engine/File.lib b/client/engine/File.lib index 52b48075..b04d2278 100755 --- a/client/engine/File.lib +++ b/client/engine/File.lib @@ -27,7 +27,7 @@ function ogCalculateChecksum () local FILE if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ - "$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf" + "$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf" return fi @@ -53,7 +53,7 @@ function ogCompareChecksumFiles () local ARGS SOURCE TARGET if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ - "if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ... fi" + "if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ...; fi" return fi @@ -89,25 +89,30 @@ function ogCopyFile () { # Variables locales. local ARGS SOURCE TARGET +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \ + "$FUNCNAME REPO newfile.txt 1 2 /tmp/newfile.txt" + return +fi ARGS="$@" case "$1" in /*) # Camino completo. */ (Comentrio Doxygen) - SOURCE=$(ogGetPath "$1") + SOURCE="$(ogGetPath "$1")" shift ;; [1-9]*) # ndisco npartición. - SOURCE=$(ogGetPath "$1" "$2" "$3") + SOURCE="$(ogGetPath "$1" "$2" "$3")" shift 3 ;; *) # Otros: repo, cache, cdrom (no se permiten caminos relativos). - SOURCE=$(ogGetPath "$1" "$2") + SOURCE="$(ogGetPath "$1" "$2")" shift 2 ;; esac # Comprobar fichero origen y directorio destino. [ -n "$SOURCE" ] || ogRaiseError $OG_ERR_NOTFOUND "${ARGS% $*}" || return $? -TARGET=$(ogGetPath "$@") +TARGET="$(ogGetPath "$@")" [ -n "$TARGET" ] || ogRaiseError $OG_ERR_NOTFOUND "$@" || return $? # Copiar fichero. -cp -p "$SOURCE" "$TARGET" # (definir posible error) +cp -a "$SOURCE" "$TARGET" # (definir posible error) } @@ -123,8 +128,14 @@ function ogDeleteFile () { # Variables locales. local FILE +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_file" \ + "$FUNCNAME 1 2 /tmp/newfile.txt" + return +fi + # Comprobar que existe el fichero y borrarlo. -FILE=$(ogGetPath "$@") +FILE="$(ogGetPath "$@")" [ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? rm -f "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? } @@ -142,8 +153,14 @@ function ogDeleteTree () { # Variables locales. local DIR +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \ + "$FUNCNAME 1 2 /tmp/newdir" + return +fi + # Comprobar que existe el directorio y borrarlo con su contenido. -DIR=$(ogGetPath "$@") +DIR="$(ogGetPath "$@")" [ -n "$DIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? rm -fr "$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? } @@ -245,7 +262,7 @@ if [ "$*" == "help" ]; then fi case $# in - 1) PARENT=$(dirname "$1") ;; + 1) PARENT="$(dirname "$1")" ;; 2) PARENT="$1 $(dirname "/$2")" ;; 3) PARENT="$1 $2 $(dirname "/$3")" ;; *) ogRaiseError $OG_ERR_FORMAT @@ -282,13 +299,13 @@ fi ARGS="$@" case "$1" in /*) # Camino completo. */ (Comentrio Doxygen) - SOURCE=$(ogGetPath "$1") + SOURCE="$(ogGetPath "$1")" shift ;; [1-9]*) # ndisco npartición. - SOURCE=$(ogGetPath "$1" "$2" "$3") + SOURCE="$(ogGetPath "$1" "$2" "$3")" shift 3 ;; *) # Otros: repo, cache, cdrom (no se permiten caminos relativos). - SOURCE=$(ogGetPath "$1" "$2") + SOURCE="$(ogGetPath "$1" "$2")" shift 2 ;; esac # Comprobar que existen los ficheros origen y destino. @@ -312,7 +329,7 @@ test "$SOURCE" -nt "$TARGET" function ogMakeChecksumFile () { # Variables locales. -local FILE DATA +local FILE if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \ "$FUNCNAME REPO ubuntu.img" @@ -320,7 +337,7 @@ if [ "$*" == "help" ]; then fi # Comprobar que existe el fichero y guardar su checksum. -FILE=$(ogGetPath "$@") +FILE="$(ogGetPath "$@")" [ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? ogCalculateChecksum "$FILE" > "$FILE.sum" } @@ -342,7 +359,13 @@ ogCalculateChecksum "$FILE" > "$FILE.sum" function ogMakeDir () { local PARENT DIR -PARENT=$(ogGetParentPath "$@") || return $? +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \ + "$FUNCNAME 1 2 /tmp/newdir" + return +fi + +PARENT="$(ogGetParentPath "$@")" || return $? DIR="$(basename "${!#}")" mkdir -p "$PARENT/$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $? } diff --git a/client/engine/FileSystem.lib b/client/engine/FileSystem.lib index ca4486b0..5c69e089 100755 --- a/client/engine/FileSystem.lib +++ b/client/engine/FileSystem.lib @@ -21,34 +21,44 @@ #@note Requisitos: *fsck* #@warning No se comprueban sistemas de archivos montados o bloqueados. #@todo Definir salidas. -#@version 0.9 - Primera adaptación para OpenGNSys. +#@version 0.9 - Primera adaptación para OpenGnSys. #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009-10-07 +#@version 1.0.2 - Ignorar códigos de salida de comprobación (no erróneos). +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-09-23 #*/ function ogCheckFs () { # Variables locales. -local PART TYPE PROG PARAMS +local PART TYPE PROG PARAMS CODES ERRCODE +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ + "$FUNCNAME 1 1" + return +fi -#/// Error si no se reciben 2 parámetros. +# Error si no se reciben 2 parámetros. [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? -#/// Obtener partición. +# Obtener partición. PART="$(ogDiskToDev $1 $2)" || return $? TYPE=$(ogGetFsType $1 $2) case "$TYPE" in - EXT[234]) PROG="e2fsck" ;; - REISERFS) PROG="reiserfsck"; PARAMS="<<<\"Yes\"" ;; - JFS) PROG="fsck.jfs" ;; + EXT[234]) PROG="e2fsck"; PARAMS="-y"; CODES=(1 2) ;; + REISERFS) PROG="fsck.reiserfs"; PARAMS="<<<\"Yes\""; CODES=(1 2) ;; + REISER4) PROG="fsck.reiser4"; PARAMS="-ay" ;; + JFS) PROG="fsck.jfs"; CODES=(1 2) ;; XFS) PROG="fsck.xfs" ;; NTFS|HNTFS) PROG="ntfsfix" ;; - FAT32|HFAT32) PROG="dosfsck"; PARAMS="-a" ;; - FAT16|HFAT16) PROG="dosfsck"; PARAMS="-a" ;; - FAT12|HFAT12) PROG="dosfsck"; PARAMS="-a" ;; + FAT32|HFAT32) PROG="dosfsck"; PARAMS="-a"; CODES=1 ;; + FAT16|HFAT16) PROG="dosfsck"; PARAMS="-a"; CODES=1 ;; + FAT12|HFAT12) PROG="dosfsck"; PARAMS="-a"; CODES=1 ;; *) ogRaiseError $OG_ERR_PARTITION "$1, $2, $TYPE" - return $? ;; + return $? ;; esac -#/// Error si el sistema de archivos esta montado o bloqueado. +# Error si el sistema de archivos esta montado o bloqueado. if ogIsMounted $1 $2; then ogRaiseError $OG_ERR_PARTITION "$1 $2" # Indicar nuevo error return $? @@ -57,14 +67,17 @@ if ogIsLocked $1 $2; then ogRaiseError $OG_ERR_LOCKED "$1 $2" return $? fi -#/// Comprobar en modo uso exclusivo. +# Comprobar en modo uso exclusivo. ogLock $1 $2 eval $PROG $PARAMS $PART ERRCODE=$? case $ERRCODE in - 0) ;; - 127) ogRaiseError $OG_ERR_NOTEXEC "$PROG" ;; - *) ogRaiseError $OG_ERR_PARTITION "$1 $2" ;; + 0|${CODES[*]}) + ERRCODE=0 ;; + 127) ogRaiseError $OG_ERR_NOTEXEC "$PROG" + ERRCODE=$OG_ERR_NOTEXEC ;; + *) ogRaiseError $OG_ERR_PARTITION "$1 $2" + ERRCODE=$OG_ERR_PARTITION ;; esac ogUnlock $1 $2 return $ERRCODE @@ -91,22 +104,22 @@ return $ERRCODE function ogExtendFs () { # Variables locales. -local PART PROG PARAMS +local PART TYPE PROG PARAMS ERRCODE -#/// Si se solicita, mostrar ayuda. +# Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ "$FUNCNAME 1 1" return fi -#/// Error si no se reciben 2 parámetros. +# Error si no se reciben 2 parámetros. [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? -#/// Obtener partición. +# Obtener partición. PART="$(ogDiskToDev $1 $2)" || return $? ogUnmount $1 $2 2>/dev/null -#/// Redimensionar al tamano máximo según el tipo de partición. +# Redimensionar al tamano máximo según el tipo de partición. TYPE=$(ogGetFsType $1 $2) case "$TYPE" in EXT[234]) PROG="resize2fs"; PARAMS="-f" ;; @@ -115,7 +128,7 @@ case "$TYPE" in *) ogRaiseError $OG_ERR_PARTITION "$1 $2 $TYPE" return $? ;; esac -#/// Error si el sistema de archivos está montado o bloqueado. +# Error si el sistema de archivos está montado o bloqueado. if ogIsMounted $1 $2; then ogRaiseError $OG_ERR_PARTITION "$1 $2" # Indicar nuevo error return $? @@ -124,14 +137,16 @@ if ogIsLocked $1 $2; then ogRaiseError $OG_ERR_LOCKED "$1 $2" return $? fi -#/// Redimensionar en modo uso exclusivo. +# Redimensionar en modo uso exclusivo. ogLock $1 $2 eval $PROG $PARAMS $PART &>/dev/null ERRCODE=$? case $ERRCODE in 0) ;; - 127) ogRaiseError $OG_ERR_NOTEXEC "$PROG" ;; - *) ogRaiseError $OG_ERR_PARTITION "$1 $2" ;; + 127) ogRaiseError $OG_ERR_NOTEXEC "$PROG" + ERRCODE=$OG_ERR_NOTEXEC ;; + *) ogRaiseError $OG_ERR_PARTITION "$1 $2" + ERRCODE=$OG_ERR_PARTITION ;; esac ogUnlock $1 $2 return $ERRCODE @@ -217,7 +232,8 @@ if [ -z "$PROG" ]; then REISERFS) PROG="mkfs.reiserfs"; PARAMS="-f" ;; REISER4) PROG="mkfs.reiser4";; XFS) PROG="mkfs.xfs"; PARAMS="-f" ;; - JFS) PROG="mkfs.jfs"; PARAMS="<<<\"y\"";; + JFS) PROG="mkfs.jfs"; PARAMS="<<<\"y\"" ;; + LINUX-SWAP) PROG="mkswap" ;; NTFS|HNTFS) PROG="mkntfs"; PARAMS="-f" ;; FAT32|HFAT32) PROG="mkdosfs"; PARAMS="-F 32" ;; FAT16|HFAT16) PROG="mkdosfs"; PARAMS="-F 16" ;; @@ -278,11 +294,10 @@ return $ERRCODE #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2009-07-21 #*/ ## -function ogGetFsType () { - +function ogGetFsType () +{ # Variables locales. -local ID TYPE - +local DISK ID TYPE # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ @@ -326,7 +341,7 @@ case "$ID" in fd) TYPE="LINUX-RAID" ;; *) TYPE="UNKNOWN" ;; esac -echo $TYPE +echo "$TYPE" } @@ -591,13 +606,8 @@ if [ -z "$MNTDIR" ]; then $MOUNT $PARAMS $PART $MNTDIR 2>/dev/null || \ $MOUNT $PARAMS $PART $MNTDIR -o force,remove_hiberfile 2>/dev/null || \ ogRaiseError $OG_ERR_PARTITION "$1, $2, $TYPE" || return $? - # linea temporal durante desarrollo para poder usar el cliente completo nfs y testeas nuevas herramientas. - if grep -q nfsroot /proc/cmdline; then - echo "$PART $MNTDIR" >> /etc/mtab - fi - # fin linea temporal. fi -echo $MNTDIR +echo "$MNTDIR" } @@ -688,8 +698,6 @@ case "$(ogGetFsType $1 $2)" in *) ogRaiseError $OG_ERR_PARTITION "$1,$2" return $? ;; esac -#/// Mostrar nuevo tamaño en KB. -#echo $[SIZE*1024] ogGetFsSize $1 $2 } @@ -847,11 +855,6 @@ if [ -n "$MNTDIR" ]; then # Desmontar y borrar punto de montaje. umount $PART 2>/dev/null || ogEcho warning "$FUNCNAME: $MSG_DONTUNMOUNT: \"$1, $2\"" rmdir $MNTDIR 2>/dev/null || rm -f $MNTDIR 2>/dev/null - # linea temporal durante desarrollo para testear nuevas herramientas con el cliente completo nfs - if grep -q nfsroot /proc/cmdline; then - grep -v $PART /etc/mtab > /var/tmp/mtab.temporal && cp /var/tmp/mtab.temporal /var/tmp/mtab && rm /var/tmp/mtab.temporal - fi - # fin linea temporal. else ogEcho warning "$MSG_DONTMOUNT: \"$1,$2\"" fi diff --git a/client/engine/Image.lib b/client/engine/Image.lib index a4b82b02..0a0867f2 100755 --- a/client/engine/Image.lib +++ b/client/engine/Image.lib @@ -14,7 +14,7 @@ function ogPartcloneSyntax () { #TODO: comprobar como unico parametro particion /dev/sda1 #COMPAR="partclone.$FS --clone --force --source $PART" -COMPAR="-F -c -s " +COMPAR=" -d0 -F -c -s " TYPE="$(ogGetFsType `ogDevToDisk $1`)" case "$TYPE" in EXT[234]) @@ -210,7 +210,7 @@ if [ "$#" -eq 4 ]; then ;; "partclone" | "PARTCLONE") # -C para que no compruebe tamaños - TOOL="| partclone.restore -o $PART" + TOOL="| partclone.restore -d0 -C -I -o $PART" ;; *) ogRaiseError $OG_ERR_NOTFOUND "Tools imaging no valid $TOOL" || return $? @@ -382,6 +382,7 @@ IMGFILE="$IMGDIR/$(basename "$3").mbr" dd if="$DISK" of="$IMGFILE" bs=446 count=1 || ogRaiseError $OG_ERR_IMAGE "$1 $IMGFILE" || return $? } + #/** # ogIsImageLocked [str_repo] path_image #@brief Comprueba si una imagen está bloqueada para uso exclusivo. @@ -481,7 +482,7 @@ touch $IMGDIR/$(basename "${!#}").lock function ogRestoreImage () { # Variables locales -local PART PARTSIZE IMGFILE IMGTYPE IMGSIZE FSTYPE +local PART PARTSIZE IMGFILE IMGTYPE IMGSIZE FSTYPE PROGRAM ERRCODE # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -662,7 +663,8 @@ rm -f $(ogGetPath $@.lock) #@date 2010/02/08 #*/ ## -function ogGetImageInfo () { +function ogGetImageInfo () +{ # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME filename " \ diff --git a/client/engine/Inventory.lib b/client/engine/Inventory.lib index 47ffd83d..b610639e 100755 --- a/client/engine/Inventory.lib +++ b/client/engine/Inventory.lib @@ -17,8 +17,14 @@ #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2010-07-17 #*/ -function ogGetArch () { -[ -d /lib64 ] && echo x86_64 || echo i386 +function ogGetArch () +{ +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => x86_64" + return +fi + +[ -d /lib64 ] && echo "x86_64" || echo "i386" } @@ -41,10 +47,10 @@ function ogGetOsVersion () { # Variables locales. local MNTDIR TYPE DISTRIB VERSION FILE - # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME" "$FUNCNAME" + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ + "$FUNCNAME 1 2 => Linux:Ubuntu 11.04 64 bits" return fi # Error si no se reciben 2 parametros. @@ -72,7 +78,7 @@ case "$(ogGetFsType $1 $2)" in fi [ -e $MNTDIR/lib64 ] && VERSION="$VERSION 64 bits" ;; - NTFS | HTNFS | FAT32 | HFAT32) + NTFS | HNTFS | FAT32 | HFAT32) TYPE="Windows" # Para Windows: leer la version del registro. VERSION=$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows NT\CurrentVersion\ProductName') @@ -96,6 +102,12 @@ return 0 #*/ ## function ogGetOsType () { +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ + "$FUNCNAME 1 2 => Linux" + return +fi ogGetOsVersion "$@" | cut -sf1 -d: } @@ -168,7 +180,7 @@ lshw | awk 'BEGIN {type="mod";} function ogListSoftware () { # Variables locales. -local MNTDIR TYPE DPKGDIR RPMDIR KEYS k PROG VERS +local MNTDIR TYPE DPKGDIR RPMDIR PACMANDIR KEYS KEYS32 k PROG VERS # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -228,6 +240,7 @@ case "$TYPE" in NTFS|HNTFS|FAT32|HFAT32) # Claves de registro para programas instalados: formato "{clave}". KEYS=$(ogListRegistryKeys $MNTDIR software '\Microsoft\Windows\CurrentVersion\Uninstall') + KEYS32=$(ogListRegistryKeys $MNTDIR software '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave. (for k in $KEYS; do PROG=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") @@ -235,6 +248,13 @@ case "$TYPE" in VERS=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") echo "$PROG $VERS" fi + done + for k in $KEYS32; do + PROG=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") + if [ -n "$PROG" ]; then + VERS=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") + echo "$PROG $VERS" + fi done) | sort | uniq ;; *) ogRaiseError $OG_ERR_PARTITION "$1, $2" @@ -250,7 +270,9 @@ esac #@attention #@version 0.1 Date: 27/10/2008 Author Antonio J. Doblas Viso. Universidad de Malaga #*/ -function ogInfoCache () { +function ogInfoCache () +{ +local info infoFilesystem infoSize infoUsed infoUsedPorcet infoMountedOn content if ogMountCache then info=`df -h | grep $OGCAC` @@ -282,3 +304,4 @@ else fi } + diff --git a/client/engine/Net.lib b/client/engine/Net.lib index 6ac5a94a..b7534e20 100755 --- a/client/engine/Net.lib +++ b/client/engine/Net.lib @@ -4,12 +4,65 @@ #@brief Librería o clase Net #@class Net #@brief Funciones básicas de red. -#@version 0.10 +#@version 1.0.2 #@warning License: GNU GPLv3+ #*/ #/** +# ogGetGroupDir [ str_repo ] +#@brief Devuelve el cmaino del directorio para el grupo del cliente. +#@param str_repo repositorio de imágenes (opcional) +#@return path_dir - Camino al directorio del grupo. +#@note repo = { REPO, CACHE } REPO por defecto +#@exception OG_ERR_FORMAT formato incorrecto. +#@version 1.0.2 - Primera versión para OpenGnSys. +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-10-03 +#*/ +function ogGetGroupDir () +{ +local REPO DIR GROUP +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME str_repo" \ + "$FUNCNAME REPO ==> /opt/opengnsys/images/groups/Grupo1" + return +fi +# Error si se recibe más de 1 parámetro. +case $# in + 0) REPO="REPO" ;; + 1) REPO="$1" ;; + *) ogRaiseError $OG_ERR_FORMAT "$*" + return $? ;; +esac + +GROUP="$(ogGetGroupName)" +if [ -n "$GROUP" ]; then + DIR=$(ogGetPath "$REPO" "/groups/$GROUP" 2>/dev/null) + [ -d "$DIR" ] && echo "$DIR" +fi +} + + +#/** +# ogGetGroupName +#@brief Devuelve el nombre del grupo al que pertenece el cliente. +#@return str_group - Nombre de grupo. +#@version 1.0.2 - Primera versión para OpenGnSys. +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-10-03 +#*/ +function ogGetGroupName () +{ +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => Grupo1" + return +fi +[ -n "$group" ] && echo "$group" +} + + +#/** # ogGetHostname #@brief Muestra el nombre del cliente. #@return str_host - nombre de máquina @@ -20,6 +73,10 @@ function ogGetHostname () { local HOST +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => pc1" + return +fi # Tomar nombre de la variable HOSTNAME HOST="$HOSTNAME" # Si no, tomar del DHCP, opción host-name /* (comentario para Doxygen) @@ -30,14 +87,14 @@ HOST="$HOSTNAME" [ -z "$HOST" ] && HOST=$(awk 'BEGIN {RS=""; FS="="} $1~/hostname/ {print $2}' /proc/cmdline) [ "$HOSTNAME" != "$HOST" ] && export HOSTNAME="$HOST" -echo $HOST +[ -n "$HOST" ] && echo $HOST } #/** # ogGetNetInterface #@brief Muestra la interfaz de red del sistema -#@return str_interfaz - interfaz de red +#@return str_interface - interfaz de red #@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing #@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf #@author Antonio J. Doblas Viso. Universidad de Malaga. @@ -45,13 +102,14 @@ echo $HOST #*/ ## function ogGetNetInterface () { - echo $DEVICE - +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => eth0" + return +fi +[ -n "$DEVICE" ] && echo "$DEVICE" } - - #/** # ogGetIpAddress #@brief Muestra la dirección IP del sistema @@ -63,19 +121,29 @@ function ogGetNetInterface () #@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011-02-24 +#@version 1.0.2 - Soporte para varias tarjetas de red +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-06-17 #*/ ## function ogGetIpAddress () { local IP -if [ -n $IPV4ADDR ] -then - echo $IPV4ADDR +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.10" + return +fi +if [ -n $IPV4ADDR ]; then + IP=$IPV4ADDR else - # Obtener direcciones IP. /* (comentario para Doxygen) - IP=$(ip address show | awk '$2!~/lo/ { readline; if ($1~/inet$/) {sub (/\/.*/, ""); printf ("%s ", $2)}}') - # Mostrar sólo la primera. (comentario para Doxygen) */ - echo ${IP%% *} + # Obtener direcciones IP. + if [ -n "$DEVICE" ]; then + IP=$(ip -o address show up dev "$DEVICE" 2>/dev/null | awk '{if ($3~/inet$/) {printf ("%s ", $4)}}') + else + IP=$(ip -o address show up | awk '$2!~/lo/ {if ($3~/inet$/) {printf ("%s ", $4)}}') + fi fi +# Mostrar solo la primera. +echo ${IP%%/*} # (comentario para Doxygen) */ } @@ -86,12 +154,23 @@ fi #@version 0.10 - Integración en OpenGnSys 0.10 #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2010-02-11 +#@version 1.0.2 - Soporte para varias tarjetas de red +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-06-17 #*/ ## function ogGetMacAddress () { local MAC +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 00:11:22:33:44:55" + return +fi # Obtener direcciones Ethernet. -MAC=$(ip address show | awk '$2!~/lo/ {readline; if ($1~/ether/) printf ("%s ", toupper($2));}') +if [ -n "$DEVICE" ]; then + MAC=$(ip -o address show up dev "$DEVICE" 2>/dev/null | awk '{sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}') +else + MAC=$(ip -o address show up | awk '$2!~/lo/ {sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}') +fi # Mostrar sólo la primera. echo ${MAC%% *} } @@ -111,6 +190,10 @@ echo ${MAC%% *} #*/ ## function ogGetRepoIp () { +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.2" + return +fi # Obtener direcciones IP, segun el protocolo de montaje if [ -n "$OGIMG" ]; then case "$ogprotocol" in @@ -135,8 +218,12 @@ fi #*/ ## function ogGetServerIp () { +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.2" + return +fi # Obtener direcciones IP. -if [ -n "$PENGNSYS" ]; then +if [ -n "$OPENGNSYS" ]; then case "$ogprotocol" in nfs) mount | grep " on $OPENGNSYS " | cut -f1 -d: ;; smb) mount | grep " on $OPENGNSYS " | cut -f3 -d/ ;; diff --git a/client/engine/PostConfEAC.lib b/client/engine/PostConfEAC.lib index 642b9118..f2487919 100755 --- a/client/engine/PostConfEAC.lib +++ b/client/engine/PostConfEAC.lib @@ -573,3 +573,144 @@ schroot -c linux schroot -end-sessiona --all-sessions } +#################################################################################### +################### Funciones para postconfiguracion windows ####################### +############# 2011 Jonathan Alonso Martinez jonathan.alonso@uab.cat ############### +#################### Universidad Autonoma de Barcelona (Spain)###################### +#################################################################################### + +#/** +# ogInstallMiniSetup path_mountpoint str_filename +#@brief Crea unas claves del registro y el archivo cmd que se ejecutara en el primer arranque estando la maquina en un estado bloqueado +#@param path_mountpoint directorio donde está montado el sistema Windows +#@param str_filename nombre del archivo .cmd a ejecutar en el arranque (estara en system32 y sera visible por el sistema) +#@return (nada) +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 1.0.2 - Nueva función +#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona +#@date 2011-06-29 +#*/ ## +function ogInstallMiniSetup () +{ +local CMDDIR CMDFILE +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_filename" \ + "$FUNCNAME /mnt/sda1 filename.cmd" + return +fi +# Error si no se reciben 2 parámetros. +[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) +# Comprobar que existe el directorio del fichero de comandos. +CMDDIR=$(ogGetPath "$1/windows/system32") +[ -n "$CMDDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1/windows/system32" || return $? +CMDFILE="$CMDDIR/$2" + +# Creamos el archivo cmd y creamos un par de comandos para que una vez acabe la +# postconfiguracion resetee el mini setup, sino lo haria en cada arranque. +cat > "$CMDFILE" << EOF +REG ADD HKLM\System\Setup /v SystemSetupInProgress /t REG_DWORD /d 0 /f +REG ADD HKLM\System\Setup /v CmdLine /t REG_SZ /d "" /f +EOF + +#Creamos las claves de registro necesarias para que se haga la ejecucion del .cmd al aranque +ogSetRegistryValue "$1" SYSTEM "\Setup\SystemSetupInProgress" 1 +ogSetRegistryValue "$1" SYSTEM "\Setup\SetupType" 4 +ogSetRegistryValue "$1" SYSTEM "\Setup\CmdLine" "cmd.exe /c $2" +} + + +# ogAddCmd path_mountpoint str_filename str_commands +#@brief Añade comandos al cmd creado por ogInstalMiniSetup +#@param path_mountpoint directorio donde está montado el sistema Windows +#@param str_filename nombre del fichero cmd (siempre se guardara en windows\system32\para que sea visible por el sistema +#@param str_commands comando o comandos que se añadiran al fichero +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. +#@version 1.0.2 - Nueva función +#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona +#@date 2011-06-29 +#*/ ## + +function ogAddCmd () +{ +local CMDFILE +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_filename str_commands" \ + "$FUNCNAME /mnt/sda1 filename.cmd command" + return +fi +# Error si no se reciben 3 parámetros. +[ $# == 3 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) +# Comprobar que existe el fichero de comandos. +CMDFILE=$(ogGetPath "$1/windows/system32/$2") +[ -n "$CMDFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$1/windows/system32/$2" || return $? + +cat >> "$CMDFILE" << EOF +$3 +EOF +} + +# ogDomainScript path_mountpoint str_domain str_user str_password +#@brief Crea un script .vbs para unir al dominio una maquina windows y el comando adequado en el archivo cmd creado por ogInstallMiniSetup +#@param path_mountpoint directorio donde está montado el sistema Windows +#@param str_filename nombre del fichero cmd donde deberemos introducir el comando de ejecutar el script vbs +#@param str_domain Dominio donde se quiere conectar +#@param str_user Usuario con privilegios para unir al dominio +#@param str_password Password del usuario con privilegios +#@return +#@exception OG_ERR_FORMAT Formato incorrecto. +#@version 1.0.2 - Nueva función +#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona +#@date 2011-06-29 +#*/ ## + +function ogDomainScript () +{ +local CMDDIR +# Si se solicita, mostrar ayuda. +if [ "$*" == "help" ]; then + ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_filename str_domain str_user str_password" \ + "$FUNCNAME /mnt/sda1 filename.cmd domain user password_user" + return +fi +# Error si no se reciben 4 parámetros. +[ $# == 5 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) +# Comprobar que existe el directorio de comandos. +CMDDIR=$(ogGetPath "$1/windows/system32") +[ -n "$CMDDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1/windows/system32" || return $? + +# Añadimos en el cmd que se ejecutara al arranque, el comando de ejecutar el script que añade al dominio. +ogAddCmd $1 "$2" "CSCRIPT joindomain.vbs" +# Eliminamos el script porque tiene el usuario de administrador de dominio en claro +ogAddCmd $1 "$2" "del /Q C:\Windows\System32\joindomain.vbs" + +# Creamos el archivo joindomain.vbs que nos introduce la maquina en el dominio +cat > "$CMDDIR/joindomain.vbs" << EOF +Const JOIN_DOMAIN = 1 +Const ACCT_CREATE = 2 +Const ACCT_DELETE = 4 +Const WIN9X_UPGRADE = 16 +Const DOMAIN_JOIN_IF_JOINED = 32 +Const JOIN_UNSECURE = 64 +Const MACHINE_PASSWORD_PASSED = 128 +Const DEFERRED_SPN_SET = 256 +Const INSTALL_INVOCATION = 262144 + +strDomain = "$3" +strUser = "$4" +strPassword = "$5" + +Set objNetwork = CreateObject("WScript.Network") +strComputer = objNetwork.ComputerName + +Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\\" & _ + strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'") + +ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, _ + strDomain & "\" & strUser, NULL, JOIN_DOMAIN + ACCT_CREATE) +EOF +} + diff --git a/client/engine/Protocol.lib b/client/engine/Protocol.lib index ecc0d43b..5fe2bc74 100755 --- a/client/engine/Protocol.lib +++ b/client/engine/Protocol.lib @@ -29,14 +29,10 @@ #@date 2011/03/09 #*/ ## - - - function ogUcastSyntax () { -local PARM SESSION SESSIONPARM MODE PORTBASE PERROR -local ADDRESS +local PARM SESSION SESSIONPARM MODE PORTBASE PERROR ADDRESS local TOOL LEVEL DEVICE MBUFFER SYNTAXSERVER SYNTAXCLIENT # Si se solicita, mostrar ayuda. @@ -159,7 +155,7 @@ function ogUcastSendPartition () { # Variables locales -local PART COMMAND RETVAL +local PART COMMAND RETVAL # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -175,7 +171,6 @@ PART=$(ogDiskToDev "$1" "$2") || return $? #ogIsLocked $1 $2 || ogRaiseError $OG_ERR_LOCKED "$1,$2" || return $? ogUnmount $1 $2 - #generamos la instrucción a ejecutar. COMMAND=`ogUcastSyntax SENDPARTITION "$3" $PART $4 $5` RETVAL=$? @@ -190,6 +185,7 @@ fi } + #/** # ogUcastReceiverPartition #@brief Función para recibir directamente en la partición el contenido de un fichero imagen remoto enviado por UNICAST. @@ -208,7 +204,7 @@ fi function ogUcastReceiverPartition () { # Variables locales -local PART COMMAND RETVAL +local PART COMMAND RETVAL # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -224,7 +220,6 @@ PART=$(ogDiskToDev "$1" "$2") || return $? #ogIsLocked $1 $2 || ogRaiseError $OG_ERR_LOCKED "$1,$2" || return $? ogUnmount $1 $2 - #generamos la instrucción a ejecutar. COMMAND=`ogUcastSyntax RECEIVERPARTITION "$3" $PART $4 $5` RETVAL=$? @@ -260,7 +255,7 @@ fi function ogUcastSendFile () { # Variables locales. -local ARGS SOURCE TARGET COMMAND DEVICE RETVAL LOGFILE +local ARG ARGS SOURCE TARGET COMMAND DEVICE RETVAL LOGFILE #ARGS usado para controlar ubicación de la sesion multicast @@ -301,7 +296,6 @@ esac ogGetPath $SOURCE &> /dev/null || ogRaiseError $OG_ERR_NOTFOUND " device or file $DEVICE not found" || return $? - SESSION=${!ARG} #generamos la instrucción a ejecutar. @@ -340,7 +334,6 @@ fi #*/ ## # - function ogMcastSyntax () { @@ -478,7 +471,7 @@ esac function ogMcastSendFile () { # Variables locales. -local ARGS SOURCE TARGET COMMAND DEVICE RETVAL LOGFILE +local ARGS ARG SOURCE TARGET COMMAND DEVICE RETVAL LOGFILE #LOGFILE="/tmp/mcast.log" @@ -525,7 +518,6 @@ ogGetPath $SOURCE &> /dev/null || ogRaiseError $OG_ERR_NOTFOUND " device or file SESSION=${!ARG} - #generamos la instrucción a ejecutar. COMMAND=`ogMcastSyntax "SENDFILE" "$SESSION" "$SOURCE"` RETVAL=$? @@ -611,6 +603,7 @@ else fi } + #/** # ogMcastSendPartition #@brief Función para enviar el contenido de una partición a multiples particiones remotas. @@ -633,7 +626,7 @@ function ogMcastSendPartition () { # Variables locales -local PART COMMAND RETVAL +local PART COMMAND RETVAL # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -683,7 +676,7 @@ fi function ogMcastReceiverPartition () { # Variables locales -local PART COMMAND RETVAL +local PART COMMAND RETVAL # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -926,7 +919,7 @@ esac # Error si no existe la imagen -[ $SOURCE ] || ogRaiseError $OG_ERR_NOTFOUND || return $? +[ $SOURCE ] || ogRaiseError $OG_ERR_NOTFOUND || return $? [ -r $SOURCE.torrent ] && mv "$SOURCE.torrent" "$SOURCE.torrent.ant" && echo "Esperamos que se refresque el servidor" && sleep 20 @@ -957,7 +950,7 @@ function ogUpdateCacheIsNecesary () { # Variables locales. -local ERROR SOURCE CACHE FILESOURCE MD5SOURCE FILETARGET MD5TARGET +local ERROR SOURCE CACHE FILESOURCE MD5SOURCE FILETARGET MD5TARGET ERROR=0 # Si se solicita, mostrar ayuda. @@ -986,8 +979,8 @@ FILETARGET=`ogGetPath CACHE $2` if [ -z $FILETARGET ] then # borramos el fichero bf del torrent, en el caso de que se hubiese quedado de algun proceso fallido - ogDeleteFile CACHE /$2.torrent.bf &> /dev/null - ogDeleteFile CACHE /$2.sum &> /dev/null + ogDeleteFile CACHE "/$2.torrent.bf" &> /dev/null + ogDeleteFile CACHE "/$2.sum" &> /dev/null echo "TRUE=0, es necesario actualizar. Paso 1, la cache no contiene esa imagen " return 0 fi @@ -1029,7 +1022,7 @@ then return 1 else echo "TRUE=0, Si es necesario actualizar. paso 5.b la imagen en cache es distinta, borramos la imagen anterior y devolvemos 0 para confirmar la actualizacion" - rm $FILETARGET + rm -f $FILETARGET return 0 fi diff --git a/client/engine/Registry.lib b/client/engine/Registry.lib index 9ca6a0e4..6423f43a 100755 --- a/client/engine/Registry.lib +++ b/client/engine/Registry.lib @@ -60,8 +60,8 @@ EOT #@return (nada) #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. -#@note hive = { default, sam, security, software, system, components } -#@note valuetype = { string, binary, dword }, por defecto: string +#@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS } +#@note valuetype = { STRING, BINARY, DWORD }, por defecto: STRING #@warning Requisitos: chntpw #@warning El sistema de archivos de Windows debe estar montada previamente. #@version 1.0.1 - Nueva función @@ -146,6 +146,7 @@ y EOT } + #/** # ogDeleteRegistryValue path_mountpoint str_hive str_valuename #@brief Elimina un valor del registro de Windows. @@ -198,7 +199,7 @@ EOT #@return str_path - camino del fichero de registro #@exception OG_ERR_FORMAT Formato incorrecto. #@exception OG_ERR_NOTFOUND Fichero de registro no encontrado. -#@note hive = { default, sam, security, software, system, components } +#@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS } #@warning El sistema de archivos de Windows debe estar montada previamente. #@version 1.0.1 - Nueva función #@author Ramon Gomez, ETSII Universidad de Sevilla @@ -212,7 +213,7 @@ local FILE FILENT FILEXP # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive" - "$FUNCNAME /mnt/sda1 SOFTWARE" + "$FUNCNAME /mnt/sda1 SOFTWARE => /mnt/sda1/WINDOWS/System32/config/SOFTWARE" return fi # Error si no se reciben 2 parámetros. diff --git a/client/engine/System.lib b/client/engine/System.lib index 020692d5..0d060f29 100755 --- a/client/engine/System.lib +++ b/client/engine/System.lib @@ -15,6 +15,7 @@ #@param str_loglevel nivel de registro de incidencias. #@param str_message mensaje (puede recibir más de 1 parámetro. #@return Mensaje mostrado. +#@warning Si no se indica nivel de registro, solo muestra mensaje en pantalla. #@note El nivel de ayuda \c (help) no se registra en el fichero de incidencias. #@version 0.9 - Primera versión para OpenGnSys #@author Ramon Gomez, ETSII Universidad de Sevilla @@ -28,16 +29,17 @@ local LOGLEVEL LOGFILE DATETIME # Selección del nivel de registro (opcional). case "$1" in help) shift ;; - info) LOGLEVEL=$1; shift ;; - warning) LOGLEVEL=$1; shift ;; - error) LOGLEVEL=$1; shift ;; + info) LOGLEVEL="$1"; shift ;; + warning) LOGLEVEL="$1"; shift ;; + error) LOGLEVEL="$1"; shift ;; *) ;; esac -# Pendiente en cliente Initrd. -#DATETIME=$(date +"%F %T") +DATETIME=$(date +"%F %T") if [ -n "$LOGLEVEL" ]; then - logger -s -t "OpenGnSys $LOGLEVEL" $LOGFILE "$DATETIME $*" + logger -s -t "OpenGnSys $LOGLEVEL" -f $LOGFILE "$DATETIME $*" + logger -t "OpenGnSys $LOGLEVEL" -f $OGLOGCOMMAND "$DATETIME $*" + logger -t "OpenGnSys $LOGLEVEL" -f $OGLOGSESSION "$DATETIME $*" else echo "$*" fi @@ -91,7 +93,7 @@ case "$CODE" in $OG_ERR_MCASTSENDPARTITION) MSG="$MSG_ERR_MCASTSENDPARTITION \"$2\"" ;; $OG_ERR_MCASTRECEIVERPARTITION) MSG="$MSG_ERR_MCASTRECEIVERPARTITION \"$2\"" ;; $OG_ERR_PROTOCOLJOINMASTER) MSG="$MSG_ERR_PROTOCOLJOINMASTER \"$2\"" ;; - *) MSG="$MSG_ERR_GENERIC"; CODE=$OG_ERR_GENERIC ;; + *) MSG="$MSG_ERR_GENERIC"; CODE=$OG_ERR_GENERIC ;; esac # Mostrar mensaje de error y salir con el código indicado. @@ -177,19 +179,20 @@ while [ $# -gt 0 ]; do done } -ogCheckProgram () + +function ogCheckProgram () { # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then - ogHelp "$FUNCNAME \"str_program1 program2 programN\" " \ - "$FUNCNAME \"partimage partclone mbuffer\" " + ogHelp "$FUNCNAME \"str_program ...\"" \ + "$FUNCNAME \"partimage partclone mbuffer\"" return fi # Error si no se recibe 1 parámetro. [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? -local PERROR PLOG +local PERROR PLOG i PERROR=0 PLOG=" " for i in `echo $1` @@ -207,3 +210,4 @@ else return 0 fi } + diff --git a/client/engine/correspondencia-api.txt b/client/engine/correspondencia-api.txt deleted file mode 100644 index e3cff0f5..00000000 --- a/client/engine/correspondencia-api.txt +++ /dev/null @@ -1,227 +0,0 @@ - -OpenGNSys Client Cloning Engine API -=================================== - -La API está dividida en librerías de funciones C/BASH o clases C++/PHP. -La columna de la izquierda es la propuesta de nombre para función/método y la de la derecha es la equivalencia con las actuales en UMA/US/UNIZAR. - -En el resto del fichero están las funciones originales que aún no he revisado. - -Entre el nombre de la función y sus equivalentes, se añade estado de la migración. - version 0.1 incorporada desde hidra, brutalix, EAC, o interfaz hidra-eac pero no compatible. - version 0.x proceso de migración - version 0.9 totalmente funcional con la estructura definida en las primeras funciones insertadas por Ramón. Un ejemplo es ogPartitionActive de la libreria Disk.lib - - -PROPUESTA ---------- - -Librería o clase Install: -- ogConfigureServer 0.1 (CustomEACServer, InterfazCustomEACServer) -- ogLoadConfig (scirpt_uso) - -Librería o clase System: -- ogEcho 0.9 (Msg) -- ogRaiseError (?) - -Librería o clase Disk: -- ogUpdatePartitionTable 0.1 (UpdateDisk) -- ogDeletePartitionTable 0.1 (DeletePartitionTable, hidraDeletePartitionTable) -- ogDevToDisk (Disk, IdPartition, hidraDisk) -- ogDiskToDev 0.9 (DiskEAC) - ogDiskToRelativeDev 0.1 (IdPartition) -- ogCreatePartitions (CreatePartitions, hidraCreatePrimaryPartitions, hidraCreateLogicalPartitions) -- ogListPartitions (ListPartitions, hidraListPartitions, hidraListPrimaryPartitions, hidraListLogicalPartitions) -- ogGetPartitionActive (hidraGetPartitionActive) -- ogSetPartitionActive (SetPartitionActive, hidraSetPartitionActive) -- ogGetPartitionId 0.9 (?) -- ogSetPartitionId 0.1 (SetPartitionType) -- ogGetPartitionSize 0.9 (SizePartition, hidraGetPartitionSize) -- ogSetPartitionSize (hidraSetPartitionSize) - ogGetPartitionsNumber 0.1 (DetectNumberPartition) - ogDeletePartitionsLabels 0.1 (DeleteLABELS) - - -Librería o clase FileSystem: -- ogFormat, ogFormatFs (FormatPartition, hidraFormat) -- ogFormatCache 0.1 (FormatCACHE, hidraFormatCache) -- ogExtend, ogExtendFs (EnlargeFileSystem, hidraFSExtend) -- ogReduce, ogReduceFs (ReduceFileSystem, hidraFSReduce) -- ogGetFsType (TypeFS, hidraTypeFS) -- ogSetFsType (SetPartitionType, hidraSetPartitionType) -- ogFindCache 0.1 (FindCache, hidraFindCache) -- ogIsLocked, ogIsFsLocked (hidraIsLocked) -- ogLock, ogLockFs (hidraLock) -- ogUnlock, ogUnlockFs (hidraUnlock) -- ogMountFs, ogMount (MountPartition, hidraMount) -- ogUnmountFs, ogUnmount (UmountPartition, hidraUnmount) -- ogMountAllFs, ogMountAll (hidraMountAll) -- ogUnmountAllFs, ogUnmountAll (hidraUnmmountAll) -- ogMountRepo, ogMount (MountRepo, hidraMountRepo) -- ogUnmountRepo, ogUnmount (UmountRepo, hidraUnmountRepo) -- ogMountCache, ogMount 0.1 (MountCache, hidraMountCache) -- ogUnmountCache, ogUnmount 0.1 (UmountCache, hidraUnmountCache) - -Librería o clase Image: -- ogCreateImage (CreateImageFromPartition, hidraCreateImageFromPartition) -- ogRestoreImage (RestorePartitionFromImage, RestorePartitionFromPartition, hidraRestorePartitionFromImage) -- ogGetImageSize (hidraImageSize) -- ogCreateTorrent (CreateTorrentFromImage) - - -Librería o clase Boot: -- ogBoot (HDBoot, BootLinuxEX, hidraBoot) -- ogLinuxBootParameters (hidraLinuxBootParameters) -- ogInstallGrub (InstallGrub) -- ogConfigureGrub (ConfGrub) -- ogListRegistryKeys (hidraListRegistryKeys) -- ogGetRegistryValue (hidraGetRegistryKey) -- ogSetRegistryValue (hidraSetRegistryKey) -- ogGetWindowsName (hidraGetWindowsName) -- ogSetWindowsName (hidraSetWindowsName) - ogNewMbrXP v0.1 (NewMbrXP) - -Librería o clase Inventory: -- ogListHardwareInfo (InfoHardware, DetectDevices, hidraHardwareInfo) -- ogGetOsVersion (hidraOSVersion) -- ogListSoftware -- ogListLinuxSoftware (hidraLinuxSoftware) -- ogListWindowsSoftware (idraWindowsSoftware) - ogInfoCache v.0.1 (infoCache) - -Librería o clase File: -- ogGetPath (ConnectToRepo, hidraPath) -- ogIsFile (IfFileExist, IfFileNotExist) - ogNewPath - -Librería o clase String: - -Librería o clase ToolsGNU - - -=================== - -Funciones EAC: - -Referencia del Archivo ATA.lib - -DetectNumberPartition -> GetPartitionNumber -NewMbrXP -DeleteLABELS -IsFSequalPartition -> CompareSizeFSPartition -AmpliarFileSystemNT -> desaparece (la anterior detecta el tipo de FS) -CrearSistemaArchivos -ELIMINARReducirFileSystemNT - -Referencia del Archivo Boot.lib - -SetDefaultBoot -ConvertToGrub -InstalaGrub4dos -moddhcpdconf - -Referencia del Archivo Deploy.lib - -SetDefaultStartpage -DetectMethodTransfer -GetImageFile -UpdateCache -CheckImage -DetectInfoImage -> GetImageInfo -DetectaProgramaImagen -> GetImageProgram -DetectaFSImagen -> GetImageFS -DetectCompresionImage -> GetImageCompression -DeployPartitionFromImage -OpenArchiveZIP -OpenArchiveNT -Synchronize -MakeOffline -MountChrootEACclient -UmountChrootEACclient -MakePhotoConsole -BORRARCheckImageTORRENT - -Referencia del Archivo EACInstall.lib - -BuildEACOSBase -BuildEACBootAgenPXE -BuildEACServer -TestPxe - -Referencia del Archivo FileSystem.lib - -SizeFileSystem -InfoCache -FormatToLower -FormatToUpper -FormatSintaxDev -FormatSintaxSpacePath -FormatSintaxBackSlashPath -GetPath -GetLastStr -GetFirstStr -MkdirPath -DetectaEtiquetas -WhatsTime -HowLongHasWorked -NumberRound - -Referencia del Archivo PostConf.lib - -CrearPatron -ParseaSysprep -NTDetect -LoadRegistrySystem -LoadRegistryUsers -UpdateRegistry -NTChangeName -NTDrivers -NTDrivers2 -NTSetGroupName -NTSetOwner -NTAutoLogon -NTStatusRatonTeclado -NTRunOnceMachine -NTRunMachine -NTRunUser -NTPolUserOn -NTPolUserOFF -NTStatusBootChk -NTNoMsgNewHardware -ChangeName - -Referencia del Archivo Settings.lib - -IPservidor -IfacesEACclient -ExportEACconf -clean - -Referencia del Archivo DBProcess.php - - RegistryHost ($mac, $ip) - SetHostName () - BootServer ($boot, $ip) - Logger () - InsertClassrom ($descripcion, $subred, $netmask, $broadcast, $gateway, $repo_image, $repo_client) - InsertItemtoMenu ($menu, $item) - - -Funciones Hidra: - -HIDRA (* a las que llama la web de hidra,las demás desaparecen salvo algunas que no existe en EAC) - -hidraClientIP -hidraClientMAC -hidraDeleteFile -hidraEACServer -hidraFSCheck -hidraPoweroff -hidraReboot -hidraUpdateCache - - -Funciones de configuracion Unizar - -eac_config_server -opengnsys_installer diff --git a/client/shared/bin/poweroffconf b/client/shared/bin/poweroffconf new file mode 100755 index 00000000..c4813e34 --- /dev/null +++ b/client/shared/bin/poweroffconf @@ -0,0 +1,59 @@ +#!/bin/bash +#/** +#@file poweroffconf +#@brief Control de parada tras tiempo de inactividad para ahorro de energía. +#@param int_minutos Minutos de inactividad (opcional). +#@note La comprobación periódica debe ejecutarse en el "cron" del sistema. +#@note Fichero de configuración: /etc/poweroff.conf +#@author Ramón Gómez - Univ. Sevilla +#@date 2011-10-25 +#@warning License: GNU GPLv3+ +#*/ + + +# Variables generales. +OPENGNSYS=${OPENGNSYS:-/opt/opengnsys} # Instalación de OpenGnSys +OGETC=${OGETC:-$OPENGNSYS/etc} # Configuración de OpenGnSys +POWEROFFCONF=/etc/poweroff.conf # Configuración del script +source $POWEROFFCONF + +case $# in + 0) # Sin parámetros, comprobar que existe la variable POWEROFFSLEEP. + if [ -z "$POWEROFFSLEEP" ]; then + ogRaiseError $OG_ERR_FORMAT "Sin tiempo de espera." + exit $? + fi + ;; + 1) #TODO Comprobar que el parámetro es entero positivo. + # Nuevo timepo de espera. + POWEROFFSLEEP=$1 + perl -pi -e "s/POWEROFFSLEEP=.*/POWEROFFSLEEP=$POWEROFFSLEEP/" $POWEROFFCONF + # Si se necesita, recalcular tiempo de parada. + if [ -n "POWEROFFTIME" ]; then + POWEROFFTIME=$(date --date="$POWEROFFSLEEP min" +"%H%M") + perl -pi -e "s/POWEROFFTIME=.*/POWEROFFTIME=$POWEROFFTIME/" $POWEROFFCONF + fi + exit 0 ;; + *) # Error de formato de ejecución. + ogRaiseError $OG_ERR_FORMAT "Formato: $0 [int_minutos]" + exit $? ;; +esac +# Comprobar si hay algún script en ejecución. +if [ -n "$(pgrep -fl $OPENGNSYS | egrep -v "$OGETC|$0")" ]; then + # Eliminar tiempo de inicio de espera, si se está ejecutando operación. + perl -pi -e 's/POWEROFFTIME=.*$/POWEROFFTIME=/' $POWEROFFCONF +else + # Si el sistema está en estado de espera, ... + NOW=$(date +"%H%M") + if [ -z "$POWEROFFTIME" ]; then + # Asignar tiempo de inicio, si no estaba definido. + POWEROFFTIME=$(date --date="$POWEROFFSLEEP min" +"%H%M") + perl -pi -e "s/POWEROFFTIME=.*$/POWEROFFTIME=$POWEROFFTIME/" $POWEROFFCONF + else + # Apagar el equipo si se sobrepasa el periodo de espera. + if [ $NOW -ge $POWEROFFTIME ]; then + $OPENGNSYS/scripts/poweroff + fi + fi +fi + diff --git a/client/shared/etc/init/default.sh b/client/shared/etc/init/default.sh index 79385796..d1fea1c9 100755 --- a/client/shared/etc/init/default.sh +++ b/client/shared/etc/init/default.sh @@ -1,11 +1,21 @@ #!/bin/bash # TODO Separar esta sección en otro script + + # Lanzar servicios complementarios del cliente. -echo -ne "og\nog\n" | passwd root -#Compatibilidad ssh con el boot-tools 1.0.2 +PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 | \ + sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') +PASS=${PASS:-"og"} +echo -ne "$PASS\n$PASS\n" | passwd root 2>/dev/null + +# Inicio del servidor sshd /usr/sbin/sshd + +# Desactivado apagado de monitor #setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1 + +# Activado WOL en la interfaz usada en arranque pxe ethtool -s $DEVICE wol g 2>/dev/null # Fichero de registro de incidencias (en el servidor; si no, en local). @@ -16,12 +26,29 @@ if ! touch $OGLOGFILE 2>/dev/null; then fi LOGLEVEL=5 -#facilitando el entorno Og desde ssh +#Facilitando el entorno Og desde ssh cp $OPENGNSYS/etc/preinit/loadenviron.sh /etc/profile.d/ + + + +########## PRUEBAS # Crear menú por defecto para el cliente generateMenuDefault -# Arranque de OpenGnSys Client. +# Matando plymount para inicir browser o shell +pkill -9 plymouthd + +[ -f /opt/opengnsys/scripts/runhttplog.sh ] && /opt/opengnsys/scripts/runhttplog.sh + +########## FIN PRUEBAS + +# Arranque de OpenGnSys Client daemon (web services). +if [ -x $OPENGNSYS/job_executer/init.d/job_executer ]; then + echo "Running Opengnsys client daemon (web services)" + $OPENGNSYS/job_executer/init.d/job_executer restart +fi + +# Arranque de OpenGnSys Client daemon (socket). if [ -x "$OPENGNSYS/bin/ogAdmClient" ]; then echo "$MSG_LAUNCHCLIENT" [ $ogactiveadmin == "true" ] && boot=admin diff --git a/client/shared/etc/preinit/default.sh b/client/shared/etc/preinit/default.sh index 539c12fe..addab9aa 100755 --- a/client/shared/etc/preinit/default.sh +++ b/client/shared/etc/preinit/default.sh @@ -5,7 +5,7 @@ set -a source /opt/opengnsys/etc/preinit/loadenviron.sh # Scripts de inicio. -for f in fileslinks loadmodules mountrepo; do +for f in fileslinks loadmodules mountrepo poweroff; do $OGETC/preinit/$f.sh done diff --git a/client/shared/etc/preinit/loadenviron.sh b/client/shared/etc/preinit/loadenviron.sh index af891534..c23fcc80 100755 --- a/client/shared/etc/preinit/loadenviron.sh +++ b/client/shared/etc/preinit/loadenviron.sh @@ -23,7 +23,8 @@ if [ -d $OPENGNSYS ]; then export OGCAC=$OPENGNSYS/cache export OGLOG=$OPENGNSYS/log - export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/opt/og2fs/2ndfs/opt/drbl/sbin + export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/opt/oglive/rootfs/opt/drbl/sbin + export PATH=$OGSCRIPTS:$PATH:$OGAPI:$OGBIN # Exportar parámetros del kernel. @@ -64,9 +65,15 @@ if [ -d $OPENGNSYS ]; then # Fichero de registros. export OGLOGFILE="$OGLOG/$(ogGetIpAddress).log" + # Configuracion de la red (valido offline) + cat /tmp/initrd.cfg | grep DEVICECFG && export $(cat /tmp/initrd.cfg | grep DEVICECFG) + source $DEVICECFG 2>/dev/null + # FIXME Pruebas para grupos de ordenadores #export OGGROUP=$(ogGetGroup) export OGGROUP="$group" + + ROOTREPO=${ROOTREPO:-"$OGSERVERIMAGES"} fi # Declaración de códigos de error. diff --git a/client/shared/etc/preinit/mountrepo.sh b/client/shared/etc/preinit/mountrepo.sh index aa0b9886..5c20499a 100755 --- a/client/shared/etc/preinit/mountrepo.sh +++ b/client/shared/etc/preinit/mountrepo.sh @@ -9,6 +9,7 @@ #*/ OGIMG=${OGIMG:-/opt/opengnsys/images} +ROOTREPO=${ROOTREPO:-"$ROOTSERVER"} # TODO Revisar proceso de arranque para no montar 2 veces el repositorio. if [ $ogactiveadmin == "true" ]; then @@ -18,8 +19,12 @@ if [ $ogactiveadmin == "true" ]; then protocol=${potocol:-"smb"} printf "$MSG_MOUNTREPO\n" "$protocol" "$boot" case "$protocol" in - nfs) mount.nfs ${ROOTSERVER}:$OGIMG $OGIMG -o rw,nolock ;; - smb) mount.cifs //${ROOTSERVER}/ogimages $OGIMG -o rw,serverino,acl,username=opengnsys,password=og ;; + nfs) mount.nfs ${ROOTREPO}:$OGIMG $OGIMG -o rw,nolock ;; + smb) PASS=$(grep "^[ ]*\(export \)\?OPTIONS=" /scripts/ogfunctions 2>&1 | \ + sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') + PASS=${PASS:-"og"} + mount.cifs //${ROOTREPO}/ogimages $OGIMG -o rw,serverino,acl,username=opengnsys,password=$PASS + ;; esac fi diff --git a/client/shared/etc/preinit/poweroff.sh b/client/shared/etc/preinit/poweroff.sh new file mode 100755 index 00000000..9e7d700d --- /dev/null +++ b/client/shared/etc/preinit/poweroff.sh @@ -0,0 +1,35 @@ +#!/bin/bash +#/** +#@file poweroff.sh +#@brief Script de inicio para cargar el proceso comprobación de clientes inactivos. +#@note Arranca y configura el proceso "cron". +#@warning License: GNU GPLv3+ +#@version 1.0.2 +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-10-25 +#*/ + + +# Si está configurado OpenGnSys ... +if [ -n "$OPENGNSYS" ]; then + #echo "$MSG_POWEROFFCONF" + + # Crear fichero de configuración por defecto (30 min. de espera). + POWEROFFCONF=/etc/poweroff.conf + cat << FIN > $POWEROFFCONF +POWEROFFSLEEP=30 +POWEROFFTIME= +FIN + + # Lanzar el proceso "cron". + cron -l + + # Definir la "crontab" lanzando el proceso de comprobación cada minuto. + echo "* * * * * [ -x $OGBIN/poweroffconf ] && $OGBIN/poweroffconf" | crontab - + +else + # FIXME Error: entorno de OpenGnSys no configurado. + echo "Error: OpenGnSys environment is not configured." # FIXME: definir mensaje. + exit 1 +fi + diff --git a/client/shared/lib/httpd/10-cgi.conf b/client/shared/lib/httpd/10-cgi.conf new file mode 100644 index 00000000..e6f4c85c --- /dev/null +++ b/client/shared/lib/httpd/10-cgi.conf @@ -0,0 +1,18 @@ +# /usr/share/doc/lighttpd-doc/cgi.txt + +server.modules += ( "mod_cgi" ) + +$HTTP["url"] =~ "^/cgi-bin/" { +alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" ) +$HTTP["url"] =~ "^/cgi-bin/" { +cgi.assign = ( ".sh" => "/bin/sh" ) +} +} + +## Warning this represents a security risk, as it allow to execute any file +## with a .pl/.py even outside of /usr/lib/cgi-bin. +# +#cgi.assign = ( +# ".pl" => "/usr/bin/perl", +# ".py" => "/usr/bin/python", +#) diff --git a/client/shared/lib/httpd/LogCommand.sh b/client/shared/lib/httpd/LogCommand.sh new file mode 100644 index 00000000..9a116f7c --- /dev/null +++ b/client/shared/lib/httpd/LogCommand.sh @@ -0,0 +1,35 @@ +#!/bin/bash +echo "Content-type: text/html" +echo "" +echo "<html><head><meta http-equiv='Refresh' content='5,URL=./LogCommand.sh'> <link rel='stylesheet' type='text/css' href='oglive.css' /> <title>Bash as CGI" +echo "</title></head><body>" + +$(strings /tmp/command.log > /tmp/command.log.tmp) + +echo "<table>" + +echo "<tr>" + + +echo "<TEXTAREA NAME='trackloghead' ROWS='13' COLS='175'>" +#echo "$(head -n 10 /tmp/command.log.tmp | uniq)" +echo "$(grep -v '^Elapsed:\|^Total [Tt]ime:\|^-\|^|\|^bytes\|^\[' /tmp/command.log.tmp | uniq | head -n 10)" +echo "</TEXTAREA>" + +echo "</tr>" + + +echo "<tr>" + +echo "<TEXTAREA NAME='tracklogtail' ROWS='2' COLS='175'>" +#echo "$(tail -n 5 /tmp/command.log.tmp | uniq)" +echo "$(grep '^Elapsed:\|^Total [Tt]ime:\|^-\|^|\|^bytes' /tmp/command.log.tmp | uniq | tail -n 2)" +echo "</TEXTAREA>" + + +echo "</tr>" + +echo "</table>" + + +echo "</body></html>"
\ No newline at end of file diff --git a/client/shared/lib/httpd/LogSession.sh b/client/shared/lib/httpd/LogSession.sh new file mode 100644 index 00000000..a5d18e68 --- /dev/null +++ b/client/shared/lib/httpd/LogSession.sh @@ -0,0 +1,31 @@ +#!/bin/bash +echo "Content-type: text/html" +echo "" +echo "<html><head> <meta http-equiv='Refresh' content='5,URL=./LogSession.sh'> <title>Bash as CGI" +echo "</title>" + +echo "<style type='text/css'>" +echo "<!--" +echo "TEXTAREA {" +echo "background-color: navy;" +echo "border: black 2px solid;" +echo "color: white;" +echo "font-family: arial, verdana, ms sans serif;" +echo "font-size: 8pt;" +echo "font-weight: normal" +echo "} " +echo "-->" +echo "</style>" + + + +echo "</head><body>" + +echo "<TEXTAREA NAME='contenido' ROWS='115' COLS='175' >" +echo "$(cat /tmp/session.log | uniq )" +echo "</TEXTAREA>" + + + +echo "</body></html>" + diff --git a/client/shared/lib/httpd/bandwidth.sh b/client/shared/lib/httpd/bandwidth.sh new file mode 100644 index 00000000..9e7833c3 --- /dev/null +++ b/client/shared/lib/httpd/bandwidth.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Content-type: text/html" +echo "" +echo "<html><head><meta http-equiv='Refresh' content='11,URL=./bandwidth.sh'> <link rel='stylesheet' type='text/css' href='oglive.css' /> <title>Bash as CGI </title></head><body>" + +echo "<TEXTAREA class='example1' NAME='contenido' ROWS='35' COLS='50' >" +echo " DISK || NET " +echo "Read:Write || Recv:Send " +echo $(tail -n1 /tmp/bandwidth) +#echo " $(dstat -dn -f 1 1 ) " +echo "</TEXTAREA>" +echo "</body></html>"
\ No newline at end of file diff --git a/client/shared/lib/httpd/httpd-log.sh b/client/shared/lib/httpd/httpd-log.sh new file mode 100644 index 00000000..12e6823c --- /dev/null +++ b/client/shared/lib/httpd/httpd-log.sh @@ -0,0 +1,15 @@ + +#!/bin/bash +echo "Content-type: text/html" +echo "" +#echo "<html><head><meta http-equiv='Refresh' content='2,URL=./example3.sh'><title>Bash as CGI" +echo "<html><head><title>OpenGnsys Client</title></head><body>" + +echo "<h1> NO APAGAR POR FAVOR. host $(hostname -s)</h1> " +echo "<IFRAME SRC='bandwidth.sh' WIDTH=250 HEIGHT=80> <A HREF="bandwidth.sh">link</A> </IFRAME> " + + +echo "<IFRAME SRC='LogSession.sh' WIDTH=850 HEIGHT=230> <A HREF="LogSession.sh">link</A> </IFRAME>" +echo "<IFRAME SRC='LogCommand.sh' WIDTH=850 HEIGHT=250> <A HREF="LogCommand.sh">link</A> </IFRAME>" + +echo "</body>
\ No newline at end of file diff --git a/client/shared/lib/httpd/httpd-menu.sh b/client/shared/lib/httpd/httpd-menu.sh new file mode 100644 index 00000000..c5e58364 --- /dev/null +++ b/client/shared/lib/httpd/httpd-menu.sh @@ -0,0 +1,14 @@ +#!/bin/bash + + +#!/bin/bash +echo "Content-type: text/html" +echo "" + +echo "<html><head><title>OpenGnsys Client</title></head><body>" + +$(wget http://172.17.9.205/opengnsys/varios/menubrowser.php -O /tmp/menu.tmp) +echo "$(cat /tmp/menu.tmp)" + +echo "</body> + diff --git a/client/shared/lib/httpd/lighttpd.conf b/client/shared/lib/httpd/lighttpd.conf new file mode 100755 index 00000000..7a11040b --- /dev/null +++ b/client/shared/lib/httpd/lighttpd.conf @@ -0,0 +1,167 @@ +# Debian lighttpd configuration file +# + +############ Options you really have to take care of #################### + +## modules to load +# mod_access, mod_accesslog and mod_alias are loaded by default +# all other module should only be loaded if neccesary +# - saves some time +# - saves memory + +server.modules = ( + "mod_access", + "mod_alias", + "mod_accesslog", + "mod_compress", +# "mod_rewrite", +# "mod_redirect", +# "mod_evhost", +# "mod_usertrack", +# "mod_rrdtool", +# "mod_webdav", +# "mod_expire", +# "mod_flv_streaming", +# "mod_evasive" +) + +## a static document-root, for virtual-hosting take look at the +## server.virtual-* options +server.document-root = "/var/www/" + +## where to upload files to, purged daily. +server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) + +## where to send error-messages to +server.errorlog = "/var/log/lighttpd/error.log" + +## files to check for if .../ is requested +index-file.names = ( "index.php", "index.html", + "index.htm", "default.htm", + "index.lighttpd.html" ) + + +## Use the "Content-Type" extended attribute to obtain mime type if possible +# mimetype.use-xattr = "enable" + +#### accesslog module +accesslog.filename = "/var/log/lighttpd/access.log" + +## deny access the file-extensions +# +# ~ is for backupfiles from vi, emacs, joe, ... +# .inc is often used for code includes which should in general not be part +# of the document-root +url.access-deny = ( "~", ".inc" ) + +## +# which extensions should not be handle via static-file transfer +# +# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi +static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) + + +######### Options that are good to be but not neccesary to be changed ####### + +## Use ipv6 only if available. (disabled for while, check #560837) +#include_shell "/usr/share/lighttpd/use-ipv6.pl" + +## bind to port (default: 80) +# server.port = 81 + +## bind to localhost only (default: all interfaces) +## server.bind = "localhost" + +## error-handler for status 404 +#server.error-handler-404 = "/error-handler.html" +#server.error-handler-404 = "/error-handler.php" + +## to help the rc.scripts +server.pid-file = "/var/run/lighttpd.pid" + +## +## Format: <errorfile-prefix><status>.html +## -> ..../status-404.html for 'File not found' +#server.errorfile-prefix = "/var/www/" + +## virtual directory listings +dir-listing.encoding = "utf-8" +server.dir-listing = "enable" + +## send unhandled HTTP-header headers to error-log +#debug.dump-unknown-headers = "enable" + +### only root can use these options +# +# chroot() to directory (default: no chroot() ) +#server.chroot = "/" + +## change uid to <uid> (default: don't care) +server.username = "www-data" + +## change uid to <uid> (default: don't care) +server.groupname = "www-data" + +#### compress module +compress.cache-dir = "/var/cache/lighttpd/compress/" +compress.filetype = ("text/plain", "text/html", "application/x-javascript", "text/css") + + +#### url handling modules (rewrite, redirect, access) +# url.rewrite = ( "^/$" => "/server-status" ) +# url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" ) + +# +# define a pattern for the host url finding +# %% => % sign +# %0 => domain name + tld +# %1 => tld +# %2 => domain name without tld +# %3 => subdomain 1 name +# %4 => subdomain 2 name +# +# evhost.path-pattern = "/home/storage/dev/www/%3/htdocs/" + +#### expire module +# expire.url = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes") + +#### rrdtool +# rrdtool.binary = "/usr/bin/rrdtool" +# rrdtool.db-name = "/var/www/lighttpd.rrd" + +#### variable usage: +## variable name without "." is auto prefixed by "var." and becomes "var.bar" +#bar = 1 +#var.mystring = "foo" + +## integer add +#bar += 1 +## string concat, with integer cast as string, result: "www.foo1.com" +#server.name = "www." + mystring + var.bar + ".com" +## array merge +#index-file.names = (foo + ".php") + index-file.names +#index-file.names += (foo + ".php") + + +#### external configuration files +## mimetype mapping +include_shell "/usr/share/lighttpd/create-mime.assign.pl" + +## load enabled configuration files, +## read /etc/lighttpd/conf-available/README first +include_shell "/usr/share/lighttpd/include-conf-enabled.pl" + +#### handle Debian Policy Manual, Section 11.5. urls +## by default allow them only from localhost +## (This must come last due to #445459) +## Note: =~ "127.0.0.1" works with ipv6 enabled, whereas == "127.0.0.1" doesn't +#$HTTP["remoteip"] =~ "127.0.0.1" { +# alias.url += ( +# "/doc/" => "/usr/share/doc/", +# "/images/" => "/usr/share/images/" +# ) +# $HTTP["url"] =~ "^/doc/|^/images/" { +# dir-listing.activate = "enable" +# } +#} + diff --git a/client/shared/lib/httpd/oglive.css b/client/shared/lib/httpd/oglive.css new file mode 100644 index 00000000..71f19ce2 --- /dev/null +++ b/client/shared/lib/httpd/oglive.css @@ -0,0 +1,11 @@ +TEXTAREA { +background-color: navy; +border: black 2px solid; +color: white; +font-family: arial, verdana, ms sans serif; +font-size: 8pt; +font-weight: normal +} + + example1 {color:white; background-color:navy; + font-weight:bold; text-align:center;}
\ No newline at end of file diff --git a/client/shared/scripts/bootLinux b/client/shared/scripts/bootLinux index e20b9489..d19be900 100755..120000 --- a/client/shared/scripts/bootLinux +++ b/client/shared/scripts/bootLinux @@ -1,35 +1 @@ -#!/bin/bash -# Scirpt de ejemplo para iniciar Linux desde partición de arranque. -# (puede usarse como base para el programa de arranque usado por OpenGNSys Admin). - -PROG="$(basename $0)" -if [ $# -ne 2 ]; then - ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion" - exit $? -fi - -echo "[0] Inicio del proceso de arranque." -PART=$(ogDiskToDev "$1" "$2") || exit $? - -echo "[10] Desmontar todos los sistemas de archivos." -sync -for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do - ogUnmountAll $i 2>/dev/null -done -ETC=$(ogGetPath $1 $2 /etc) -if [ -n "$ETC" ]; then - echo "[30] Asignar nombre Linux \"$NAME\"." - NAME=$(ogGetHostname) - NAME=${NAME:-"pc"} - echo "$NAME" >$ETC/hostname 2>/dev/null - echo "[50] Actaualizar fstab con particion raiz \"$PART\"." - awk -v P="$PART " '{ if ($2=="/") {sub(/^.*$/, P, $1)} - print } ' $ETC/fstab >/tmp/fstab - mv /tmp/fstab $ETC/fstab -fi -echo "[70] Desmontar cache local." -ogUnmountCache - -echo "[90] Arrancar sistema operativo." -ogBoot $1 $2 - +bootOs
\ No newline at end of file diff --git a/client/shared/scripts/bootOs b/client/shared/scripts/bootOs index 71a9fe73..78d779be 100755 --- a/client/shared/scripts/bootOs +++ b/client/shared/scripts/bootOs @@ -10,9 +10,16 @@ fi echo "[0] Inicio del proceso de arranque." PART=$(ogDiskToDev "$1" "$2") || exit $? -NAME=$(ogGetHostname) +NAME="$(ogGetHostname)" NAME=${NAME:-"pc"} OSTYPE=$(ogGetOsType $1 $2) +# Borrar marcas de arrranque de todos los Windows instalados en el disco. +if [ "$OSTYPE" == "Windows" ]; then + for (( i=1; i<=$(ogGetPartitionsNumber $1); i++ )); do + [ "$(ogGetOsType $1 $i)" == "Windows" ] && ogMount $1 $i &>/dev/null + done + rm -f /mnt/*/ogboot.* +fi echo "[10] Desmontar todos los sistemas de archivos." sync @@ -21,7 +28,8 @@ for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do done case "$OSTYPE" in Windows) - echo "[30] Activar particion de Windows $PART." + echo "[30] Mostrar y activar particion de Windows $PART." + [ $(ogGetPartitionType $1 $2) == "HNTFS" ] && ogUnhidePartition $1 $2 ogSetPartitionActive $1 $2 echo "[50] Asignar nombre Windows \"$NAME\" y usuario por defecto." ogSetWindowsName $1 $2 "$NAME" diff --git a/client/shared/scripts/bootWindows b/client/shared/scripts/bootWindows index e92e484a..d19be900 100755..120000 --- a/client/shared/scripts/bootWindows +++ b/client/shared/scripts/bootWindows @@ -1,30 +1 @@ -#!/bin/bash -# Scirpt de ejemplo para iniciar Windows con partición de arranque. -# (puede usarse como base para el programa de arranque usado por OpenGNSys Admin). - -PROG="$(basename $0)" -if [ $# -ne 2 ]; then - ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion" - exit $? -fi - -echo "[0] Inicio del proceso de arranque." -PART=$(ogDiskToDev "$1" "$2") || exit $? - -echo "[10] Desmontar todos los sistemas de archivos." -sync -for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do - ogUnmountAll $i 2>/dev/null -done -echo "[30] Activar particion de Windows $PART." -ogSetPartitionActive $1 $2 -echo "[50] Asignar nombre Windows \"$NAME\"." -NAME=$(ogGetHostname) -NAME=${NAME:-"pc"} -ogSetWindowsName $1 $2 "$NAME" -echo "[70] Desmontar cache local." -ogUnmountCache - -echo "[90] Arrancar sistema operativo." -ogBoot $1 $2 - +bootOs
\ No newline at end of file diff --git a/client/shared/scripts/cloneRemoteFromMaster b/client/shared/scripts/cloneRemoteFromMaster index 6516b587..cc0a936b 100755 --- a/client/shared/scripts/cloneRemoteFromMaster +++ b/client/shared/scripts/cloneRemoteFromMaster @@ -247,7 +247,9 @@ case $MASTERIP in SIZEIMAGE=$(echo $INFOEXTRA | awk '{print $4}') echo -n "[26] $INFOEXTRA = herramienta= $TOOLCLONE compresor= $COMPRESOR size= $SIZEIMAGE " ogMount $DISKTARGET $PARTTARGET || ogFormat $DISKTARGET $PARTTARGET - SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | awk '{y=x; x=$4};END{print y}' | tr -d kB) + #SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | awk '{y=x; x=$4};END{print y}' | tr -d kB) + SIZEPARTTARGET=$(parted `ogDiskToDev $DISKTARGET $PARTTARGET` unit kB print | grep Disk | awk -F" " '{print $3}' | tr -d kB); + echo "[29] comprobando que el tamaño de la imagen $SIZEIMAGE es menor que el de la particion destino $SIZEPARTTARGET" # comprobamos que el tamaño de a imagen es menor que la del cliente. if [ "$SIZEIMAGE" -lt "$SIZEPARTTARGET" ] diff --git a/client/shared/scripts/configureOs b/client/shared/scripts/configureOs index 64249c9b..c9660d4d 100755 --- a/client/shared/scripts/configureOs +++ b/client/shared/scripts/configureOs @@ -15,6 +15,9 @@ #@version 1.0.1 - Configura el sector de la particion y el gestor de windows para iniciarse desde cualquier particion. #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011-05-20 +#@version 1.0.2 - Configura el sector de la particion y el gestor de linux para iniciarse desde cualquier particion. +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2011-11-22 @@ -32,15 +35,20 @@ FLAGACTIVE=$(ogGetPartitionActive $1) # Cambiar nombre en sistemas Windows y quitar usuario de acceso por defecto. if [ "$(ogGetOsType $1 $2)" = "Windows" ]; then + # Cambiar nombre en sistemas Windows. HOST=$(ogGetHostname) HOST=${HOST:-"pc"} - echo " Cambiar nombre Windows a \"$HOST\" " ogSetWindowsName $1 $2 "$HOST" - #ogSetWinlogonUser $1 $2 " " # Descomentar para cambiar usuario de inicio. - # Configurar el boot sector de la particion windows. - ogFixBootSector $1 $2 - # Configura el gestor de arranque de windows xp vista seven + # Descomentar la siguiente línea para cambiar usuario de inicio. + #ogSetWinlogonUser $1 $2 " " + # Configurar el boot sector de la partición Windows. + ogFixBootSector $1 $2 + # Configurar el gestor de arranque de Windows XP/Vista/7. ogWindowsBootParameters $1 $2 - # Registra en windows que la particion indicada es su nueva unidad c:\ + # Registrar en Windows que la partición indicada es su nueva unidad C:\ ogWindowsRegisterPartition $1 $2 C $1 $2 +fi + +if [ "$(ogGetOsType $1 $2)" = "Linux" ]; then + ogGrubInstallPartition $1 $2 fi
\ No newline at end of file diff --git a/client/shared/scripts/createImage b/client/shared/scripts/createImage index 3643d1af..3bba9d36 100755 --- a/client/shared/scripts/createImage +++ b/client/shared/scripts/createImage @@ -23,10 +23,12 @@ #@version 1.0 - control de errores para el ogAdmServer #@author #@date 2011-04-10 -#@version 1.0.1 - Fin de control de errores para el ogAdmServer -#@author +#@version 1.0.1 - Control de espacio requerido +#@author Antonio J.Doblas Viso #@date 2011-05-10 - + #@version 1.0.2 - Separacion de log +#@author Antonio J.Doblas Viso +#@date 2011-08-4 #*/ ## # Test 1. crear una imagen en un REPO sin espacio libre. @@ -36,6 +38,12 @@ # test 5. intentar crear una imagen, en la que no se puede reducir el FS. TIME1=$SECONDS +OGLOGSESSION="/tmp/session.log" +OGLOGCOMMAND="/tmp/command.log" + + + + PROG="$(basename $0)" if [ $# -ne 4 ]; then ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG ndisco nparticion REPO|CACHE imagen" @@ -47,29 +55,38 @@ IMGPROG="partclone" IMGCOMP="lzop" IMGEXT="img" +echo "[1] Iniciando $0 $*" | tee -a $OGLOGSESSION $OGLOGFILE + + # Si el repositorio es CACHE comprobamos que exista if [ "$3" == "CACHE" -o "$3" == "cache" ]; then ! ogFindCache >/dev/null && exit $(ogRaiseError $OG_ERR_NOTCACHE "CACHE "; echo $?) fi +echo " " > $OGLOGCOMMAND + # Obtener información de los parámetros de entrada. PART=$(ogDiskToDev "$1" "$2" 2>/dev/null) || exit $(ogRaiseError $OG_ERR_PARTITION "$1 $2"; echo $?) +echo " " > $OGLOGCOMMAND + #Comprobamos acceso de escritura. DIRTEMP=$(date +%Y%m%d-%H%M%S) ogMakeDir $3 /$4$DIRTEMP 2>/dev/null || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3"; echo $?) && ogDeleteTree $3 /$4$DIRTEMP +echo " " > $OGLOGCOMMAND + IMGDIR=$(ogGetParentPath "$3" "/$4") # Si no existe, crear subdirectorio de la imagen. if [ $? != 0 ]; then - echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")." + echo "[5] Crear subdirectorio de la imagen \"$3 $(dirname "$4")." | tee -a $OGLOGSESSION $OGLOGFILE ogMakeDir "$3" $(dirname "/$4") || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?) IMGDIR=$(ogGetParentPath "$3" "/$4") || exit $(ogRaiseError $OG_ERR_NOTWRITE "$3 /$4"; echo $?) fi IMGFILE=$IMGDIR/$(basename "/$4").$IMGEXT # Renombrar el fichero de imagen si ya existe. if [ -f "$IMGFILE" ]; then - echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"." + echo "[10] Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"." | tee -a $OGLOGSESSION $OGLOGFILE mv "$IMGFILE" "$IMGFILE.ant" mv "$IMGFILE.torrent" "$IMGFILE.torrent.ant" 2>/dev/null fi @@ -90,9 +107,11 @@ else exit $? fi +echo " " > $OGLOGCOMMAND + # Mostrar información. -echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE" -echo "[16] $PROG: TamañoRequerido=$SIZEREQUIRED EspacioDisponible=$SIZEFREE" +echo "[15] $PROG: Origen=$PART, Destino=$IMGFILE" | tee -a $OGLOGSESSION $OGLOGFILE +echo "[16] $PROG: TamañoRequerido=$SIZEREQUIRED EspacioDisponible=$SIZEFREE" | tee -a $OGLOGSESSION $OGLOGFILE [ "$SIZEREQUIRED" -gt "$SIZEFREE" ] && exit $(ogRaiseError $OG_ERR_CACHESIZE "$3" || echo $?) @@ -100,21 +119,25 @@ echo "[16] $PROG: TamañoRequerido=$SIZEREQUIRED EspacioDisponible=$SIZEFREE" # TODO: que hacer si la cache no tiene espacio libre. # Comprobar consistencia del sistema de archivos. -echo "[20] Comprobar sistema de archivos." +echo "[20] Comprobar sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE ogUnmount $1 $2 ogCheckFs $1 $2 || exit $(ogRaiseError $OG_ERR_PARTITION "ogCheckFs $1 $2" && echo $?) -echo "[30]: Reducir sistema de archivos." +echo " " > $OGLOGCOMMAND + +echo "[30]: Reducir sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE ogReduceFs $1 $2 || exit $(ogRaiseError $OG_ERR_REDUCEFS "$1 $2"; echo $?) +echo " " > $OGLOGCOMMAND + # Crear la imagen. -echo "[40] Crear imagen con: ogCreateImage $1 $2 $3 $4 $IMGPROG $IMGCOMP" +echo "[40] Crear imagen con: ogCreateImage $1 $2 $3 $4 $IMGPROG $IMGCOMP" | tee -a $OGLOGSESSION $OGLOGFILE ogCreateImage $1 "$2" $3 $4 "$IMGPROG" "$IMGCOMP" || exit $(ogRaiseError $OG_ERR_IMAGE "ogCreteImage"; echo $?) -echo "[90] Extender sistema de archivos." +echo "[90] Extender sistema de archivos." | tee -a $OGLOGSESSION $OGLOGFILE ogExtendFs $1 $2 || exit $(ogRaiseError $OG_ERR_EXTENDFS "$1 $2"; echo $?) TIME=$[SECONDS-TIME1] -echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s" +echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s" | tee -a $OGLOGSESSION $OGLOGFILE diff --git a/client/shared/scripts/deployImage b/client/shared/scripts/deployImage index 16a403cc..e5a2bec3 100755 --- a/client/shared/scripts/deployImage +++ b/client/shared/scripts/deployImage @@ -1,6 +1,31 @@ #!/bin/bash +#/** +# deployImage +#@brief Actualiza la cache del cliente con una imagen, y la restaura en la partición. +#@param 1 +#@param ejemplo: +#@return +#@exception OG_ERR_FORMAT formato incorrecto. +#@note +#@todo: +#@version 0.9.1 - integracion EAC +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2008/03/17 +#@version 0.9.2 - integracion OpenGnsys +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/07/27 +#@version 1.0.2 - Separacion de log +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/08/04 +#*/ ## + TIME1=$SECONDS + +OGLOGSESSION="/tmp/session.log" +OGLOGCOMMAND="/tmp/command.log" + + PROG="$(basename $0)" if [ $# -lt 4 ]; then ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $PROG REPO imagen ndisco nparticion [ UNICAST|MULTICAST|TORRENT ] [opciones protocolo]" @@ -8,20 +33,20 @@ if [ $# -lt 4 ]; then fi #controlar param1 REPO -echo "Realizando un updateCache REPO $2.img $5 $6" -updateCache REPO $2.img $5 $6 +echo "[1] Realizando un updateCache REPO $2.img $5 $6" | tee -a $OGLOGSESSION $OGLOGFILE +updateCache REPO $2.img $5 $6 | tee -a $OGLOGCOMMAND RETVAL=$? if [ "$RETVAL" != "0" ] then - echo "fin del updateCache REPO $2.img $5 $6 con error $RETVAL" + echo "[49] Fin del updateCache REPO $2.img $5 $6 con error $RETVAL" | tee -a $OGLOGSESSION $OGLOGFILE # RC=15 No hay cache # RC=16 no hay espacio sufiente exit $RETVAL else - echo "iniciando un ogRestore CACHE desde deployImage" - ogRestoreImage CACHE /$2 $3 $4 + echo "[50] Iniciando un ogRestore CACHE desde deployImage" | tee -a $OGLOGSESSION $OGLOGFILE + ogRestoreImage CACHE /$2 $3 $4 &>> $OGLOGCOMMAND RETVAL=$? - [ "$RETVAL" == "0" ] && configureOs $3 $4 + [ "$RETVAL" == "0" ] && configureOs $3 $4 | tee -a $OGLOGCOMMAND exit $RETVAL fi
\ No newline at end of file diff --git a/client/shared/scripts/listPartitions b/client/shared/scripts/listPartitions new file mode 100755 index 00000000..6f9c318f --- /dev/null +++ b/client/shared/scripts/listPartitions @@ -0,0 +1,3 @@ +#!/bin/bash +ogListPartitions "$@" | sed 's/\(EMPTY:0 \)*$//' + diff --git a/client/shared/scripts/restoreImage b/client/shared/scripts/restoreImage index a01f1a49..f08c0415 100755 --- a/client/shared/scripts/restoreImage +++ b/client/shared/scripts/restoreImage @@ -76,14 +76,10 @@ ogRestoreImage "$@" || exit $? # Restaurar tamaño. echo "[80] Extender sistema de archivos." ogExtendFs $3 $4 -# Cambiar nombre en sistemas Windows y quitar usuario de acceso por defecto. -if [ "$(ogGetOsType $3 $4)" = "Windows" ]; then - HOST=$(ogGetHostname) - HOST=${HOST:-"pc"} - echo "[90] Cambiar nombre Windows a \"$HOST\" y usuario de acceso." - ogSetWindowsName $3 $4 "$HOST" - #ogSetWinlogonUser $3 $4 " " # Descomentar para cambiar usuario de inicio. -fi +# Llamar al script de post-configuración del sistema operativo. +echo "[90] Post-configuracion de aranque del sistema." +configureOs $3 $4 + TIME=$[SECONDS-TIME1] echo "[100] Duracion de la operacion $[TIME/60]m $[TIME%60]s" diff --git a/client/shared/scripts/runAplicationX.sh b/client/shared/scripts/runAplicationX.sh new file mode 100755 index 00000000..85f96814 --- /dev/null +++ b/client/shared/scripts/runAplicationX.sh @@ -0,0 +1,8 @@ +#/bin/bash +/usr/X11R6/bin/Xvesa :0 -ac -shadow -screen 1024x768x24 -br -mouse /dev/input/mice & +/bin/sleep 0.1 +export DISPLAY=:0 +#/usr/bin/lxde-logout +#/usr/bin/openbox +/usr/bin/roxterm +#/usr/sbin/gparted diff --git a/client/shared/scripts/runhttplog.sh b/client/shared/scripts/runhttplog.sh new file mode 100755 index 00000000..04d3e530 --- /dev/null +++ b/client/shared/scripts/runhttplog.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "export OGLOGCOMMAND=/tmp/command.log" >> /etc/profile.d/loadenviron.sh +echo "export OGLOGSESSION=/tmp/session.log" >> /etc/profile.d/loadenviron.sh + export OGLOGCOMMAND=/tmp/command.log + export OGLOGSESSION=/tmp/session.log + +#httd-log-status +cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.back +cp /opt/opengnsys/lib/httpd/lighttpd.conf /etc/lighttpd/ +cp /etc/lighttpd/conf-enabled/10-cgi.conf /etc/lighttpd/conf-enabled/10-cgi.conf.back +cp /opt/opengnsys/lib/httpd/10-cgi.conf /etc/lighttpd/conf-enabled/ +/etc/init.d/lighttpd start +chmod 755 /opt +cp /opt/opengnsys/lib/httpd/* /usr/lib/cgi-bin +#TODO: +dstat -dn 10 > /tmp/bandwidth & +#Se pasan al loadenviro para su uso en ssh +#export OGLOGSESSION=/tmp/session.log +#export OGLOGCOMMAND=/tmp/command.log +touch $OGLOGCOMMAND +touch $OGLOGSESSION +touch ${OGLOGCOMMAND}.tmp +chmod 777 $OGLOGCOMMAND +chmod 777 $OGLOGSESSION +chmod 777 ${OGLOGCOMMAND}.tmp +touch /tmp/menu.tmp +chmod 777 /tmp/menu.tmp +echo "WAITING" >> $OGLOGSESSION +# http-log-status
\ No newline at end of file diff --git a/client/shared/scripts/updateBootCache b/client/shared/scripts/updateBootCache index af2267a2..f3edae7c 100755 --- a/client/shared/scripts/updateBootCache +++ b/client/shared/scripts/updateBootCache @@ -1,7 +1,54 @@ #!/bin/bash -OGBTFTP="/opt/og2fs/tftpboot/ogclient/" + +#/** +# updateBootCache +#@brief acelerador arranque pxe. incorpora a la cache el initrd y el kernel. +#@param 1 +#@param ejemplo: +#@return +#@exception OG_ERR_FORMAT formato incorrecto. +#@note +#@todo: +#@version 1.0.1 - requiere el gestor de arranque grub2dos +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/07/27 +#*/ ## + + + +OGBTFTP="/opt/oglive/tftpboot/ogclient" ogMountCache || exit 1 -echo $OGCAC + [ -d $OGCAC/boot ] || mkdir -p $OGCAC/boot -[ -f ${OGCAC}/boot/ogvmlinuz ] || cp ${OGBTFTP}ogvmlinuz ${OGCAC}/boot/ogvmlinuz -[ -f ${OGCAC}/boot/oginitrd.img ] || cp ${OGBTFTP}oginitrd.img ${OGCAC}/boot/oginitrd.img
\ No newline at end of file + + # comparamos los del server + SERVERVMLINUZ=`cat ${OGBTFTP}/ogvmlinuz.sum` + SERVERINITRD=`cat ${OGBTFTP}/oginitrd.img.sum` + + #comparamos los de la cache + CACHEVMLINUZ=`cat ${OGCAC}/boot/ogvmlinuz.sum` + CACHEINITRD=`cat ${OGCAC}/cache/boot/oginitrd.img.sum` + + echo "MD5 on SERVER: $SERVERVMLINUZ $SERVERINITRD" + echo "MD5 on CACHE: $CACHEVMLINUZ $CACHEINITRD" + + + if [ "$CACHEVMLINUZ" != "$SERVERVMLINUZ" ] + then + echo "ogvmlinuz updating" + cp ${OGBTFTP}ogvmlinuz ${OGCAC}/boot/ogvmlinuz + cp ${OGBTFTP}ogvmlinuz.sum ${OGCAC}/boot/ogvmlinuz.sum + DOREBOOT=true + fi + if [ "$CACHEINITRD" != "$SERVERINITRD" ] + then + echo "oginitrd updating" + cp ${OGBTFTP}oginitrd.img ${OGCAC}/boot/oginitrd.img + cp ${OGBTFTP}oginitrd.img.sum ${OGCAC}/boot/oginitrd.img.sum + DOREBOOT=true + fi + +echo $DOREBOOT +# [ "$DOREBOOT" == "true" ] && busybox reboot -f + + diff --git a/client/shared/scripts/updateCache b/client/shared/scripts/updateCache index bebb1153..2b7f2c3f 100755 --- a/client/shared/scripts/updateCache +++ b/client/shared/scripts/updateCache @@ -1,17 +1,29 @@ #!/bin/bash -# Scirpt para la actualizacion de datos en la cache. -# Versión: 0.9.1, 2008/03/17, - integracion eac -# Versión: 0.9.2, 2010/07/27, - integracion opengnsys - - - -#1 REPO -#2 nombre del fichero con su extension, tipo /imagen1.img o /ubuntu.iso -#3 Protocolo TORRENT | MULTICAST | UNICAST -#4 opciones protocolo -#5 opciones de update cache +#/** +# updateCache +#@brief Actualiza la cache del cliente con imagen o fichero iso. +#@param 1 REPO Origen del fichero. -accesible por nfs-samba- +#@param 2 str_fichero nombre del fichero a actualizar. +#@param 3 str_protoco. TORRENT | MULTICAST | UNICAST. +#@param 4 str_opcionesprotocolo +#@param 4 str_opcionesupdatecache +#@ejemplo: oneRemoteFromMaster 172.17.36.11 CACHE /imagen1 9000:full-duplex:239.194.17.36:70M:50:100 1 1 partclone lzop +#@return +#@exception OG_ERR_FORMAT formato incorrecto. +#@note +#@todo: +#@version 0.9.1 - integracion EAC +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2008/03/17 +#@version 0.9.2 - integracion OpenGnsys +#@author Antonio J. Doblas Viso. Universidad de Malaga. +#@date 2010/07/27 +#@version 1.0.1 - Control de espacio requerido +#@author Antonio J.Doblas Viso +#@date 2011-05-10 +#*/ ## PROG="$(basename $0)" if [ $# -lt 3 ]; then @@ -19,9 +31,9 @@ if [ $# -lt 3 ]; then exit $? fi -REPOSITORIO=$1 -PROTOCOLO=$3 -OPTPROTOCOLO=$4 +REPOSITORIO="$1" +PROTOCOLO="$3" +OPTPROTOCOLO="$4" REPOIP=$(ogGetRepoIp) echo $REPOSITORIO $REPOIP $PROTOCOLO $OPTPROTOCOLO # Si el repositorio local CACHE no existe salimos. @@ -39,7 +51,7 @@ ogUpdateCacheIsNecesary $1 $2; RETVAL=$? CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`) -FILESIZE=$(ls -sk $(ogGetPath $1 $2) | cut -f1 -d" ") +FILESIZE=$(ls -sk $(ogGetPath $REPOSITORIO "$2") | cut -f1 -d" ") if [ "$FILESIZE" -ge "$CACHESIZEFREE" ] then @@ -48,32 +60,35 @@ then exit $? fi -ogUpdateCacheIsNecesary $1 $2; RETVAL=$? +ogUpdateCacheIsNecesary $REPOSITORIO "$2"; RETVAL=$? # si RETVAL=0 => actualizamos si RETVAL=1 no actaulizasmo-exit 0 || si RETVAL>2 exit 1 [ "$RETVAL" == "1" ] && exit 0 [ "$RETVAL" -gt "1" ] && exit 1 -ogMountCache +ogMountCache >/dev/null ## Si no existe, crear subdirectorio para el fichero en la cache. -IMGDIR=$(ogGetParentPath "$1" "/$2") +IMGDIR=$(ogGetParentPath CACHE "/$2") if [ $? != 0 ]; then echo "[5] Crear subdirectorio del fichero \"$2 $(dirname "$2")." - ogMakeDir "CACHE" $(dirname "/$2") - IMGDIR=$(ogGetParentPath "$1" "/$2") || exit $? + ogMakeDir CACHE $(dirname "/$2") + IMGDIR=$(ogGetParentPath CACHE "/$2") || exit $? fi - - case "$PROTOCOLO" in torrent | TORRENT ) - echo "ogCopyFile $1 $2.torrent absolute $OGCAC$OGIMG" - ogCopyFile $1 $2.torrent $OGCAC$OGIMG + echo "ogCopyFile $1 $2.torrent absolute $OGCAC/$OGIMG" + # tiempos + timewait=$(expr $(printf '%d\n' 0x$(ogGetMacAddress | awk -F: '{print $5$6}')) \* 120 / 65535) + ogCopyFile $REPOSITORIO "$2.torrent" "$IMGDIR" #TODO: comprobar que el tracker definido en el fichero es correcto. #TODO comprobar que el fichero torrent está en cache - echo "ogTorrentStart CACHE $2.torrent $4" - ogTorrentStart CACHE $2.torrent $4 + # retardamos el inicio -aleatorio de 0 a 120 segundos- al tracker para gestionar mas de +-40 equipos + P2PWAIT=$[ ( $RANDOM % 120 ) + 1 ] + echo "Esperando $P2PWAIT segundos para iniciar ogTorrentStart CACHE $2.torrent $4" + sleep $P2PWAIT + ogTorrentStart CACHE "$2.torrent" $4 ;; multicast | MULTICAST ) echo "determinando puerto principal y auxiliar." @@ -86,7 +101,7 @@ case "$PROTOCOLO" in echo "comprobando puerto $PORTAUX en $REPOIP (sesion multicast en puerto $PORT) " if (nmap -n -sU -p $PORTAUX $REPOIP | grep open) then - ogMcastReceiverFile $PORT CACHE $2 + ogMcastReceiverFile $PORT CACHE "$2" else # TODO ticket 379 Realizar la petición basada en identificador de operacion echo "solicita la apertura: hose $REPOIP 2009 --out sh -c "echo -ne START_MULTICAST $2 $OPTPROTOCOLO"" @@ -95,7 +110,7 @@ case "$PROTOCOLO" in sleep 10 if (nmap -n -sU -p $PORTAUX $REPOIP | grep open) then - ogMcastReceiverFile $PORT CACHE $2 + ogMcastReceiverFile $PORT CACHE "$2" else echo "la peticion ha fallado: hose $REPOIP 2009 --out sh -c echo -ne START_MULTICAST $2 $OPTPROTOCOLO" exit 1 @@ -104,13 +119,14 @@ case "$PROTOCOLO" in ;; unicast | UNICAST ) echo "unicast" - ogCopyFile $1 $2 $OGCAC$OGIMG + ogCopyFile $REPOSITORIO "$2" "$IMGDIR" ;; esac -ogUpdateCacheIsNecesary $1 $2; RETVAL=$? +ogUpdateCacheIsNecesary $REPOSITORIO "$2"; RETVAL=$? # si RETVAL=0 => actualizamos si RETVAL=1 no actaulizasmo-exit 0 || si RETVAL>2 exit 1 [ "$RETVAL" == "0" ] && exit 1 [ "$RETVAL" == "1" ] && exit 0 -[ "$RETVAL" -gt "1" ] && exit 1
\ No newline at end of file +[ "$RETVAL" -gt "1" ] && exit 1 + |