source: server/bin/installoglive @ 5854ddb

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 5854ddb was a658acf, checked in by ramon <ramongomez@…>, 9 years ago

#682: Modificar script de servidor installoglive para instalar un cliente ogLive desde un fichero de imagen ISO local.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@4718 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.9 KB
Line 
1#!/bin/bash
2# installoglive - instala cliente ogLive.
3# Nota: Si no se especifica fichero local, el usuario debe elegir
4#       el número del ogLive que desea descargar e instalar.
5# Uso:  installoglive [fichero]
6# Autor:   Ramón M. Gómez - ETSII Univ. Sevilla
7# Fecha:   2015-01-26
8# Versión: 1.1 - Posibilidad para instalar fichero ogLive local.
9# Autor:   Ramón M. Gómez - ETSII Univ. Sevilla
10# Fecha:   2016-11-06
11
12
13# Control de acceso.
14PROG=$(basename $0)
15if [ "$USER" != "root" ]; then
16        echo "$PROG: Need to be root." >&2
17        exit 1
18fi
19
20# Constantes.
21DOWNLOADURL="http://opengnsys.es/downloads"
22OPENGNSYS=/opt/opengnsys
23OGINITRD=$OPENGNSYS/tftpboot/ogclient/oginitrd.img
24OGVMLINUZ=$OPENGNSYS/tftpboot/ogclient/ogvmlinuz
25
26if [ -n "$1" ]; then
27        # Si se recibe un parámetro, utilizar fichero ogLive local.
28        TARGETFILE="$1"
29else
30        # Sin parámetros, listar todos los ficheros ogLive descargables.
31        OGLIVE=( $(wget $DOWNLOADURL -O - 2>/dev/null|grep ogLive.*iso) )
32        NISOS=${#OGLIVE[@]}
33        echo "Descargas disponibles (+- = instalado):"
34        for i in $(seq 1 $NISOS); do
35                [ -e $OPENGNSYS/lib/${OGLIVE[i-1]} ] && OGLIVE[i-1]="+-${OGLIVE[i-1]}"
36        done
37        select opt in ${OGLIVE[@]}; do
38                [ -n "$opt" ] && OGLIVEFILE=${opt/+-/} && break
39        done
40
41        # Tamaño del fichero a descargar.
42        SOURCELENGTH=$(LANG=C wget --spider $DOWNLOADURL/$OGLIVEFILE 2>&1 | awk '/Length:/ {print $2}')
43        [ -n "$SOURCELENGTH" ] || exit
44
45        # Descarga de ogLive.
46        TARGETFILE=$OPENGNSYS/lib/$OGLIVEFILE
47        wget $DOWNLOADURL/$OGLIVEFILE -O $TARGETFILE || exit
48fi
49
50# Error si no existe el fichero ogLive o no es una imagen ISO.
51if [ ! -f $TARGETFILE ]; then
52        echo "$PROG: File not found." >&2
53        exit 2
54fi
55if [ -z "$(file -b $TARGETFILE | grep "ISO.*ogClient")" ]; then
56        echo "$PROG: File is not an OpenGnsys Client ISO image." >&2
57        exit 2
58fi
59
60# Obtener la clave actual de acceso a Samba para restaurarla tras la descarga.
61if [ -f $OGINITRD ]; then
62        SAMBAPASS=$(gzip -dc $OGINITRD | \
63        cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
64                        grep "^[        ].*OPTIONS=" | \
65                        sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
66fi
67
68# Hacer copia de seguridad del ogLive actual.
69rm -fr $OPENGNSYS/tftpboot/ogclient.old
70mv -f $OPENGNSYS/tftpboot/ogclient $OPENGNSYS/tftpboot/ogclient.old
71
72# Montar la imagen ISO del ogclient, actualizar ficheros y desmontar.
73TMPDIR=/tmp/${OGLIVEFILE%.iso}
74mkdir -p $TMPDIR
75mount -o loop,ro $TARGETFILE $TMPDIR
76cp -va $TMPDIR/ogclient $OPENGNSYS/tftpboot/ogclient
77umount $TMPDIR
78rmdir $TMPDIR
79
80# Recuperar la clave de acceso a Samba o solicitar una nueva clave.
81if [ -n "$SAMBAPASS" ]; then
82        echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | $OPENGNSYS/bin/setsmbpass
83else
84        $OPENGNSYS/bin/setsmbpass
85fi
86
87# Establecer los permisos.
88find -L $OPENGNSYS/tftpboot/ogclient -type d -exec chmod 755 {} \;
89find -L $OPENGNSYS/tftpboot/ogclient -type f -exec chmod 644 {} \;
90chown -R :opengnsys $OPENGNSYS/tftpboot/ogclient
91
92# Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache
93cp -av $OPENGNSYS/tftpboot/ogclient/{ogvmlinuz,oginitrd.img}* $OPENGNSYS/tftpboot
94
Note: See TracBrowser for help on using the repository browser.