diff options
author | ramon <ramongomez@us.es> | 2017-02-17 09:24:30 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2017-02-17 09:24:30 +0000 |
commit | d55c26df3590291077844be646947a97477599a5 (patch) | |
tree | 9573aa26f0e512712ceb2fa068e45fd650a40811 /server | |
parent | 2f9cd7679633a088ce41fdb1b27613f6b751ecb3 (diff) |
#768: Sustituir script {{{installoglive}}} por {{{oglivecli}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5202 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'server')
l---------[-rwxr-xr-x] | server/bin/installoglive | 117 | ||||
-rwxr-xr-x | server/bin/oglivecli | 4 |
2 files changed, 4 insertions, 117 deletions
diff --git a/server/bin/installoglive b/server/bin/installoglive index ac4fe912..f7b0fa3e 100755..120000 --- a/server/bin/installoglive +++ b/server/bin/installoglive @@ -1,116 +1 @@ -#!/bin/bash -# installoglive - instala cliente ogLive. -# Nota: Si no se especifica fichero local, el usuario debe elegir -# el número del ogLive que desea descargar e instalar. -# Uso: installoglive [fichero] -# Autor: Ramón M. Gómez - ETSII Univ. Sevilla -# Fecha: 2015-01-26 -# Versión: 1.1 - Posibilidad para instalar fichero ogLive local. -# Autor: Ramón M. Gómez - ETSII Univ. Sevilla -# Fecha: 2015-11-06 -# Versión: 1.1.0a - Adaptar la versión de Rsync de cliente y servidor. -# Autor: Ramón M. Gómez - ETSII Univ. Sevilla -# Fecha: 2015-12-16 - - -# Control de acceso. -PROG=$(basename $0) -if [ "$USER" != "root" ]; then - echo "$PROG: Need to be root." >&2 - exit 1 -fi - -# Constantes. -DOWNLOADURL="http://opengnsys.es/downloads" -OPENGNSYS=/opt/opengnsys -OGCLIENTDIR=/opt/opengnsys/tftpboot/ogclient -OGINITRD=$OGCLIENTDIR/oginitrd.img -OGVMLINUZ=$OGCLIENTDIR/ogvmlinuz -OGSQFS=$OGCLIENTDIR/ogclient.sqfs - -if [ -n "$1" ]; then - # Si se recibe un parámetro, utilizar fichero ogLive local. - TARGETFILE="$1" - OGLIVEFILE=$(basename $TARGETFILE) -else - # Sin parámetros, listar todos los ficheros ogLive descargables. - 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 -fi - -# Error si no existe el fichero ogLive o no es una imagen ISO. -if [ ! -f $TARGETFILE ]; then - echo "$PROG: File not found." >&2 - exit 2 -fi -if [ -z "$(file -b $TARGETFILE | grep "ISO.*ogClient")" ]; then - echo "$PROG: File is not an OpenGnsys Client ISO image." >&2 - exit 2 -fi - -# 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. -rm -fr ${OGCLIENTDIR}.old -mv -f $OGCLIENTDIR ${OGCLIENTDIR}.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 $OGCLIENTDIR -#rsync -irlt $TMPDIR/ogclient $OPENGNSYS/tftpboot -umount $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 $OGCLIENTDIR -type d -exec chmod 755 {} \; -find -L $OGCLIENTDIR -type f -exec chmod 644 {} \; -chown -R :opengnsys $OGCLIENTDIR - -# Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache -cp -av $OGCLIENTDIR/{ogvmlinuz,oginitrd.img}* $OPENGNSYS/tftpboot - -# Montar SquashFS para comprobar versión de Rsync. -mount -o loop,ro $OGCLIENTDIR/ogclient.sqfs $TMPDIR -# Si versión Rsync de servidor > cliente, enlazar a fichero compilado. -RSYNCSERV=$(rsync --version 2>/dev/null | awk '/protocol/ {print $6}') -RSYNCCLNT=$(chroot $TMPDIR /usr/bin/rsync --version 2>/dev/null | awk '/protocol/ {print $6}') -if [ -z "$RSYNCSERV" -o ${RSYNCSERV:-0} -gt ${RSYNCCLNT:-1} ]; then - [ -e $OPENGNSYS/client/bin/rsync-$RSYNCSERV ] && mv -f $OPENGNSYS/client/bin/rsync-$RSYNCSERV $OPENGNSYS/client/bin/rsync -else - # Si no, renombrar fichero compilado con nº de protocolo. - [ -e $OPENGNSYS/client/bin/rsync ] && mv -f $OPENGNSYS/client/bin/rsync $OPENGNSYS/client/bin/rsync-$($OPENGNSYS/client/bin/rsync --version 2>/dev/null | awk '/protocol/ {print $6}') -fi -# Desmontar SquashFS. -umount $TMPDIR -rmdir $TMPDIR -# Versión del ogLive instalado. -echo "${OGLIVEFILE%.*}" > $INSTALL_TARGET/doc/veroglive.txt +oglivecli
\ No newline at end of file diff --git a/server/bin/oglivecli b/server/bin/oglivecli index d1e02a6a..3fbaf3f6 100755 --- a/server/bin/oglivecli +++ b/server/bin/oglivecli @@ -121,7 +121,7 @@ function convert() { OGLIVEKRNL=$(file -bkr $OGCLIENT/ogvmlinuz | awk '/Linux/ {for(i=1;i<=NF;i++) if($i~/version/) {v=$(i+1);sub(/-.*/,"",v);print v}}') OGLIVEDIR=$DEFOGLIVE-$OGLIVEKRNL [ -r $OLDINFOFILE ] && OGLIVEISO=$(head -1 $OLDINFOFILE).iso - addToJson "" "$OGLIVEKRNL" "" "$OGLIVEDIR" "$OGLIVEISO" + addToJson "$(echo $OGLIVEISO|cut -f2 -d-)" "$OGLIVEKRNL" "${OGLIVEISO##*-}" "$OGLIVEDIR" "$OGLIVEISO" # Rename directory, link to default and clean old files. mv -v $OGCLIENT $OGLIVEDIR ln -vfs $OGLIVEDIR $DEFOGLIVE @@ -129,6 +129,8 @@ function convert() { mv -v $OGCLIENT.old $OGLIVEDIR.old 2>/dev/null rm -fv {ogvmlinuz,oginitrd.img}{,.sum} $OLDINFOFILE popd >/dev/null + # Delete old config file. + rm -f $OLDINFOFILE } # Show script configuration parameters. |