diff options
author | ramon <ramongomez@us.es> | 2015-01-26 08:56:39 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2015-01-26 08:56:39 +0000 |
commit | 85dfa75c449540cd86721a6137aefea58bd4dba1 (patch) | |
tree | 2e23e6f5c87e3576e81d948c4c817091063f48d0 /server | |
parent | c1e77032324e38632006a4a03232e52e16735c7e (diff) |
#682: Crear script {{{installoglive}}} para elegir el cliente ogLive deseado, descargarlo e instalarlo.
git-svn-id: https://opengnsys.es/svn/branches/version1.0@4481 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'server')
-rwxr-xr-x | server/bin/installoglive | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/server/bin/installoglive b/server/bin/installoglive new file mode 100755 index 00000000..80153a5f --- /dev/null +++ b/server/bin/installoglive @@ -0,0 +1,67 @@ +#!/bin/bash +# installoglive - descarga e instala cliente ogLive. +# Nota: El usuario debe elegir el número del ogLive que desea instalar. +# Uso: installoglive +# Autor: Ramón M. Gómez - ETSII Univ. Sevilla +# Fecha: 2015-01-26 + + +# Constantes. +DOWNLOADURL="http://opengnsys.es/downloads" +OPENGNSYS=/opt/opengnsys +OGINITRD=$OPENGNSYS/tftpboot/ogclient/oginitrd.img +OGVMLINUZ=$OPENGNSYS/tftpboot/ogclient/ogvmlinuz + +# Listar todos los ficheros ogLive que pueden ser descargados. +OGLIVE=( $(wget $DOWNLOADURL -O - 2>/dev/null|grep ogLive.*iso) ) +NISOS=${#OGLIVE[@]} +echo "Descargas disponibles (+- = instalado):" +for i in $(seq 1 $NISOS); do + [ -e $OPENGNSYS/lib/${OGLIVE[i-1]} ] && OGLIVE[i-1]="+-${OGLIVE[i-1]}" +done +select opt in ${OGLIVE[@]}; do + [ -n "$opt" ] && OGLIVEFILE=${opt/+-/} && break +done + +# Tamaño del fichero a descargar. +SOURCELENGTH=$(LANG=C wget --spider $DOWNLOADURL/$OGLIVEFILE 2>&1 | awk '/Length:/ {print $2}') +[ -n "$SOURCELENGTH" ] || exit + +# Descarga de ogLive. +TARGETFILE=$OPENGNSYS/lib/$OGLIVEFILE +wget $DOWNLOADURL/$OGLIVEFILE -O $TARGETFILE || exit + +# Obtener la clave actual de acceso a Samba para restaurarla tras la descarga. +if [ -f $OGINITRD ]; then + SAMBAPASS=$(gzip -dc $OGINITRD | \ + cpio -i --to-stdout scripts/ogfunctions 2>&1 | \ + grep "^[ ].*OPTIONS=" | \ + sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/') +fi + +# Hacer copia de seguridad del ogLive actual. +mv -f $OPENGNSYS/tftpboot/ogclient $OPENGNSYS/tftpboot/ogclient.old + +# Montar la imagen ISO del ogclient, actualizar ficheros y desmontar. +TMPDIR=/tmp/${OGLIVEFILE%.iso} +mkdir -p $TMPDIR +mount -o loop,ro $TARGETFILE $TMPDIR +cp -va $TMPDIR/ogclient $OPENGNSYS/tftpboot/ogclient +umount $TMPDIR +rmdir $TMPDIR + +# Recuperar la clave de acceso a Samba o solicitar una nueva clave. +if [ -n "$SAMBAPASS" ]; then + echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | $OPENGNSYS/bin/setsmbpass +else + $OPENGNSYS/bin/setsmbpass +fi + +# Establecer los permisos. +find -L $OPENGNSYS/tftpboot/ogclient -type d -exec chmod 755 {} \; +find -L $OPENGNSYS/tftpboot/ogclient -type f -exec chmod 644 {} \; +chown -R :opengnsys $OPENGNSYS/tftpboot/ogclient + +# Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache +cp -av $OPENGNSYS/tftpboot/ogclient/{ogvmlinuz,oginitrd.img}* $OPENGNSYS/tftpboot + |