source: installer/opengnsys_update.sh @ 42ac964

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 42ac964 was 295b4ab, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0: Mejoras en el script de actualización:

  • Actualización de la estructura de la base de datos.
  • Actualizar correctamente los ficheros del servidor.
  • Secuencia correcta del proceso de actualización.

Modificado #361, #359.

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

  • Property mode set to 100755
File size: 18.3 KB
RevLine 
[a0867b37]1#!/bin/bash
2#/**
3#@file    opengnsys_update.sh
4#@brief   Script actualización de OpenGnSys
5#@warning No se actualiza BD, ni ficheros de configuración.
6#@version 0.9 - basado en opengnsys_installer.sh
7#@author  Ramón Gómez - ETSII Univ. Sevilla
8#@date    2010/01/27
[c1e00e4]9#@version 1.0 - adaptación a OpenGnSys 1.0
10#@author  Ramón Gómez - ETSII Univ. Sevilla
11#@date    2011/03/02
[a0867b37]12#*/
13
14
[295b4ab]15####  AVISO: Editar configuración de acceso por defecto a la Base de Datos.
16OPENGNSYS_DATABASE="ogAdmBD"            # Nombre de la base datos
17OPENGNSYS_DBUSER="usuog"                # Usuario de acceso
18OPENGNSYS_DBPASSWORD="passusuog"        # Clave del usuario
19
20####  AVISO: NO Editar variables de acceso desde el cliente
21OPENGNSYS_CLIENTUSER="opengnsys"        # Usuario Samba
22
23
[a0867b37]24# Sólo ejecutable por usuario root
25if [ "$(whoami)" != 'root' ]
26then
27        echo "ERROR: this program must run under root privileges!!"
28        exit 1
29fi
30
31# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
32PROGRAMDIR=$(readlink -e $(dirname "$0"))
[c1e00e4]33DEPS="build-essential g++-multilib rsync ctorrent samba unzip netpipes debootstrap schroot squashfs-tools"
[a0867b37]34if [ -d "$PROGRAMDIR/../installer" ]; then
35    USESVN=0
36else
37    USESVN=1
[c1e00e4]38    SVN_URL=http://www.opengnsys.es/svn/branches/version1.0
[a0867b37]39    DEPS="$DEPS subversion"
40fi
41
42WORKDIR=/tmp/opengnsys_update
43mkdir -p $WORKDIR
44
45INSTALL_TARGET=/opt/opengnsys
46LOG_FILE=/tmp/opengnsys_update.log
47
48
49
50#####################################################################
51####### Algunas funciones útiles de propósito general:
52#####################################################################
[295b4ab]53
[a0867b37]54function getDateTime()
55{
[295b4ab]56        date "+%Y%m%d-%H%M%S"
[a0867b37]57}
58
59# Escribe a fichero y muestra por pantalla
60function echoAndLog()
61{
62        echo $1
63        FECHAHORA=`getDateTime`
64        echo "$FECHAHORA;$SSH_CLIENT;$1" >> $LOG_FILE
65}
66
67function errorAndLog()
68{
69        echo "ERROR: $1"
70        FECHAHORA=`getDateTime`
71        echo "$FECHAHORA;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
72}
73
74
75#####################################################################
76####### Funciones de copia de seguridad y restauración de ficheros
77#####################################################################
78
79# Hace un backup del fichero pasado por parámetro
80# deja un -last y uno para el día
81function backupFile()
82{
83        if [ $# -ne 1 ]; then
84                errorAndLog "${FUNCNAME}(): invalid number of parameters"
85                exit 1
86        fi
87
88        local fichero=$1
89        local fecha=`date +%Y%m%d`
90
91        if [ ! -f $fichero ]; then
92                errorAndLog "${FUNCNAME}(): file $fichero doesn't exists"
93                return 1
94        fi
95
[ebbbfc01]96        echoAndLog "${FUNCNAME}(): Making $fichero back-up"
[a0867b37]97
98        # realiza una copia de la última configuración como last
99        cp -p $fichero "${fichero}-LAST"
100
101        # si para el día no hay backup lo hace, sino no
102        if [ ! -f "${fichero}-${fecha}" ]; then
103                cp -p $fichero "${fichero}-${fecha}"
104        fi
105}
106
107# Restaura un fichero desde su copia de seguridad
108function restoreFile()
109{
110        if [ $# -ne 1 ]; then
111                errorAndLog "${FUNCNAME}(): invalid number of parameters"
112                exit 1
113        fi
114
115        local fichero=$1
116
[ebbbfc01]117        echoAndLog "${FUNCNAME}(): restoring file $fichero"
[a0867b37]118        if [ -f "${fichero}-LAST" ]; then
119                cp -p "$fichero-LAST" "$fichero"
120        fi
121}
122
123
124#####################################################################
[295b4ab]125####### Funciones de acceso a base de datos
126#####################################################################
127
128# Actualizar la base datos
129function importSqlFile()
130{
131        if [ $# -ne 4 ]; then
132                errorAndLog "${FNCNAME}(): invalid number of parameters"
133                exit 1
134        fi
135
136        local dbuser="$1"
137        local dbpassword="$2"
138        local database="$3"
139        local sqlfile="$4"
140        local tmpfile=$(mktemp)
141        local status
142
143        if [ ! -r $sqlfile ]; then
144                errorAndLog "${FUNCNAME}(): Unable to read $sqlfile!!"
145                return 1
146        fi
147
148        echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..."
149        chmod 600 $tmpfile
150        sed -e "s/SERVERIP/$SERVERIP/g" -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
151            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" $sqlfile > $tmpfile
152        mysql -u$dbuser -p"$dbpassword" --default-character-set=utf8 "$database" < $tmpfile
153        status=$?
154        rm -f $tmpfile
155        if [ $status -ne 0 ]; then
156                errorAndLog "${FUNCNAME}(): error importing $sqlfile in database $database"
157                return 1
158        fi
159        echoAndLog "${FUNCNAME}(): file imported to database $database"
160        return 0
161}
162
163
164#####################################################################
[a0867b37]165####### Funciones de instalación de paquetes
166#####################################################################
167
168# Instalar las deependencias necesarias para el actualizador.
169function installDependencies ()
170{
171        if [ $# = 0 ]; then
172                echoAndLog "${FUNCNAME}(): no deps needed."
[c1e00e4]173        else
174                while [ $# -gt 0 ]; do
[ebbbfc01]175                        dpkg -s $1 2>/dev/null | grep -q "Status: install ok"
[c1e00e4]176                        if [ $? -ne 0 ]; then
177                                INSTALLDEPS="$INSTALLDEPS $1"
178                        fi
179                        shift
180                done
181                if [ -n "$INSTALLDEPS" ]; then
[ebbbfc01]182                        apt-get update && apt-get -y install --force-yes $INSTALLDEPS
[c1e00e4]183                        if [ $? -ne 0 ]; then
184                                errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS."
185                                return 1
186                        fi
187                fi
188        fi
[a0867b37]189}
190
191
192#####################################################################
193####### Funciones para el manejo de Subversion
194#####################################################################
195
196function svnExportCode()
197{
198        if [ $# -ne 1 ]; then
199                errorAndLog "${FUNCNAME}(): invalid number of parameters"
200                exit 1
201        fi
202
203        local url=$1
204
205        echoAndLog "${FUNCNAME}(): downloading subversion code..."
206
[7ad4465]207        svn checkout "${url}" opengnsys
[a0867b37]208        if [ $? -ne 0 ]; then
209                errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
210                return 1
211        fi
212        echoAndLog "${FUNCNAME}(): subversion code downloaded"
213        return 0
214}
215
216
217############################################################
218###  Detectar red
219############################################################
220
221function getNetworkSettings()
222{
[5d6bf97]223        local MAINDEV
224
225        echoAndLog "getNetworkSettings(): Detecting default network parameters."
226        MAINDEV=$(ip -o link show up | awk '!/loopback/ {d=d$2} END {sub(/:.*/,"",d); print d}')
227        if [ -z "$MAINDEV" ]; then
228                errorAndLog "${FUNCNAME}(): Network device not detected."
229                return 1
[a0867b37]230        fi
231
232        # Variables de ejecución de Apache
233        # - APACHE_RUN_USER
234        # - APACHE_RUN_GROUP
235        if [ -f /etc/apache2/envvars ]; then
236                source /etc/apache2/envvars
237        fi
238        APACHE_RUN_USER=${APACHE_RUN_USER:-"www-data"}
239        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"www-data"}
240}
241
242
243#####################################################################
244####### Funciones específicas de la instalación de Opengnsys
245#####################################################################
246
[cf2142ea]247# Copiar ficheros de arranque de los servicios del sistema de OpenGnSys
248
249function updateServicesStart(){
250        echoAndLog "${FUNCNAME}(): Updating /etc/init.d/opengnsys ..."
[6b65dfd]251        cp -p $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
[cf2142ea]252        if [ $? != 0 ]; then
253                errorAndLog "${FUNCNAME}(): Error updating /etc/init.d/opengnsys"
254                exit 1
255        fi
256        echoAndLog "${FUNCNAME}(): /etc/init.d/opengnsys updated successfully."
257}
258
[45f1fe8]259# Actualizar cliente OpenGnSys
[295b4ab]260function updateClientFiles()
[45f1fe8]261{
262        local hayErrores=0
263
264        echoAndLog "${FUNCNAME}(): Updating OpenGnSys Client files."
265        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
266        if [ $? -ne 0 ]; then
267                errorAndLog "${FUNCNAME}(): error while updating client structure"
268                hayErrores=1
269        fi
270        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
271       
272        echoAndLog "${FUNCNAME}(): Updating OpenGnSys Cloning Engine files."
273        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin
274        if [ $? -ne 0 ]; then
275                errorAndLog "${FUNCNAME}(): error while updating engine files"
276                hayErrores=1
277        fi
278       
279        if [ $hayErrores -eq 0 ]; then
280                echoAndLog "${FUNCNAME}(): client  files update success."
281        else
282                errorAndLog "${FUNCNAME}(): client files update with errors"
283        fi
284
285        return $hayErrores
286}
[a0867b37]287# Copiar ficheros del OpenGnSys Web Console.
288function updateWebFiles()
289{
[d655cc4]290        local ERRCODE
[a0867b37]291        echoAndLog "${FUNCNAME}(): Updating web files..."
[d655cc4]292        backupFile $INSTALL_TARGET/www/controlacceso.php
293        mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
[1db2ed8]294        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
[d655cc4]295        ERRCODE=$?
296        mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
[c1e00e4]297        unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
[d655cc4]298        if [ $ERRCODE != 0 ]; then
[a0867b37]299                errorAndLog "${FUNCNAME}(): Error updating web files."
300                exit 1
301        fi
[d655cc4]302        restoreFile $INSTALL_TARGET/www/controlacceso.php
[a0867b37]303        # Cambiar permisos para ficheros especiales.
[ebbbfc01]304        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/includes $INSTALL_TARGET/www/images/iconos
[a0867b37]305        echoAndLog "${FUNCNAME}(): Web files updated successfully."
[e473667]306       
[a0867b37]307}
308
[72134d5]309# Copiar carpeta de Interface
310function updateInterfaceAdm ()
311{
312        local hayErrores=0
313         
314        # Crear carpeta y copiar Interface
315        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
316        mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
317        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
318        ERRCODE=$?
319        mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm
320        if [ $? -ne 0 ]; then
321                echoAndLog "${FUNCNAME}(): error while updating admin interface"
322                exit 1
323        fi
324        chmod -R +x $INSTALL_TARGET/client/interfaceAdm
[295b4ab]325        chown :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
[f6c1d2b]326        chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
[72134d5]327        echoAndLog "${FUNCNAME}(): Admin interface updated successfully."
328}
[a0867b37]329
[5d6bf97]330# Crear documentación Doxygen para la consola web.
331function makeDoxygenFiles()
332{
333        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
334        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
335                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
336        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
337                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files."
338                return 1
339        fi
[45f1fe8]340        rm -fr "$INSTALL_TARGET/www/api"
[5d6bf97]341        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
[45f1fe8]342    rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf}
[5d6bf97]343        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api
344        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully."
345}
346
347
[a0867b37]348# Crea la estructura base de la instalación de opengnsys
349function createDirs()
350{
351        echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}"
352
353        mkdir -p ${INSTALL_TARGET}
354        mkdir -p ${INSTALL_TARGET}/bin
355        mkdir -p ${INSTALL_TARGET}/client
356        mkdir -p ${INSTALL_TARGET}/doc
357        mkdir -p ${INSTALL_TARGET}/etc
358        mkdir -p ${INSTALL_TARGET}/lib
359        mkdir -p ${INSTALL_TARGET}/log/clients
360        mkdir -p ${INSTALL_TARGET}/sbin
361        mkdir -p ${INSTALL_TARGET}/www
362        mkdir -p ${INSTALL_TARGET}/images
363        ln -fs /var/lib/tftpboot ${INSTALL_TARGET}
364        ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys
365
366        if [ $? -ne 0 ]; then
367                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
368                return 1
369        fi
370
371        echoAndLog "${FUNCNAME}(): directory paths created"
372        return 0
373}
374
375# Copia ficheros de configuración y ejecutables genéricos del servidor.
376function updateServerFiles () {
377
[c1e00e4]378        # No copiar ficheros del antiguo cliente Initrd
379        local SOURCES=( repoman/bin \
380                        server/bin \
[a0867b37]381                        doc )
[c1e00e4]382        local TARGETS=( bin \
[85b029f]383                        bin \
[a0867b37]384                        doc )
385
386        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
387                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
388                exit 1
389        fi
390
391        echoAndLog "${FUNCNAME}(): updating files in server directories"
392        pushd $WORKDIR/opengnsys >/dev/null
393        local i
394        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
[295b4ab]395                rsync --exclude .svn -irplt "${SOURCES[$i]}" $(dirname "${INSTALL_TARGET}/${TARGETS[$i]}")
[a0867b37]396        done
397        popd >/dev/null
[9ee62ad]398        echoAndLog "${FUNCNAME}(): updating cron files"
399        echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
[da8db11]400        echoAndLog "${FUNCNAME}(): server files updated successfully."
[a0867b37]401}
402
403####################################################################
404### Funciones de compilación de código fuente de servicios
405####################################################################
406
407# Recompilar y actualiza el binario del clinete
408function recompileClient ()
409{
410        # Compilar OpenGnSys Client
411        echoAndLog "${FUNCNAME}(): recompiling OpenGnSys Client"
[72134d5]412        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
[e473667]413        make && mv ogAdmClient $INSTALL_TARGET/client/bin
[a0867b37]414        if [ $? -ne 0 ]; then
415                echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Client"
416                hayErrores=1
417        fi
418        popd
419
420        return $hayErrores
421}
422
423
424####################################################################
425### Funciones instalacion cliente opengnsys
426####################################################################
427
[c1e00e4]428# Actualizar antiguo cliente Initrd.
429function updateOldClient()
[a0867b37]430{
431        local OSDISTRIB OSCODENAME
432
433        local hayErrores=0
434
435        echoAndLog "${FUNCNAME}(): Copying OpenGnSys Client files."
436        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/nfsexport/* $INSTALL_TARGET/client
437        echoAndLog "${FUNCNAME}(): Copying OpenGnSys Cloning Engine files."
438        mkdir -p $INSTALL_TARGET/client/lib/engine/bin
439        rsync -iplt $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin
440        if [ $? -ne 0 ]; then
441                errorAndLog "${FUNCNAME}(): error while copying engine files"
442                hayErrores=1
443        fi
444
445        # Cargar Kernel, Initrd y paquetes udeb para la distribución del servidor (o por defecto).
[72134d5]446        OSDISTRIB=$(lsb_release -is) 2>/dev/null
447        OSCODENAME=$(lsb_release -cs) 2>/dev/null
[a0867b37]448        if [ "$OSDISTRIB" = "Ubuntu" -a -n "$OSCODENAME" ]; then
449                echoAndLog "${FUNCNAME}(): Loading Kernel and Initrd files for $OSDISTRIB $OSCODENAME."
[da8db11]450                $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot -v $OSCODENAME 2>&1 | tee -a $LOG_FILE
[a0867b37]451                if [ $? -ne 0 ]; then
452                        errorAndLog "${FUNCNAME}(): error while generating initrd OpenGnSys Admin Client"
453                        hayErrores=1
454                fi
455                echoAndLog "${FUNCNAME}(): Loading udeb files for $OSDISTRIB $OSCODENAME."
[da8db11]456                $INSTALL_TARGET/bin/upgrade-clients-udeb.sh $OSCODENAME 2>&1 | tee -a $LOG_FILE
[a0867b37]457                if [ $? -ne 0 ]; then
458                        errorAndLog "${FUNCNAME}(): error while upgrading udeb files OpenGnSys Admin Client"
459                        hayErrores=1
460                fi
461        else
462                echoAndLog "${FUNCNAME}(): Loading default Kernel and Initrd files."
[da8db11]463                $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot 2>&1 | tee -a $LOG_FILE
[a0867b37]464                if [ $? -ne 0 ]; then
465                        errorAndLog "${FUNCNAME}(): error while generating initrd OpenGnSys Admin Client"
466                        hayErrores=1
467                fi
468                echoAndLog "${FUNCNAME}(): Loading default udeb files."
[da8db11]469                $INSTALL_TARGET/bin/upgrade-clients-udeb.sh 2>&1 | tee -a $LOG_FILE
[a0867b37]470                if [ $? -ne 0 ]; then
471                        errorAndLog "${FUNCNAME}(): error while upgrading udeb files OpenGnSys Admin Client"
472                        hayErrores=1
473                fi
474        fi
475
476        if [ $hayErrores -eq 0 ]; then
477                echoAndLog "${FUNCNAME}(): Client generation success."
478        else
479                errorAndLog "${FUNCNAME}(): Client generation with errors"
480        fi
481
482        return $hayErrores
483}
484
[c1e00e4]485# Actualizar nuevo cliente para OpenGnSys 1.0
486function updateClient()
487{
488        local DOWNLOADURL=http://www.opengnsys.es/downloads
[6ef9f23]489        local FILENAME=ogclient-1.0-lucid-32bit.tar.gz
490        local TMPFILE=/tmp/$FILENAME
[c1e00e4]491
492        echoAndLog "${FUNCNAME}(): Loading Client"
493        # Descargar y descomprimir cliente ogclient
[03882ae]494        wget $DOWNLOADURL/$FILENAME -O $TMPFILE
[6ef9f23]495        if [ ! -s $TMPFILE ]; then
496                errorAndLog "${FUNCNAME}(): Error loading OpenGnSys Client"
[c1e00e4]497                return 1
498        fi
[03882ae]499        echoAndLog "${FUNCNAME}(): Extracting Client files"
[6ef9f23]500        tar xzvf $TMPFILE -C $INSTALL_TARGET/tftpboot
501        rm -f $TMPFILE
[c1e00e4]502        # Usar la versión más reciente del Kernel y del Initrd para el cliente.
[295b4ab]503        ln -f $(ls $INSTALL_TARGET/tftpboot/ogclient/vmlinuz-*|tail -1) $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz
504        ln -f $(ls $INSTALL_TARGET/tftpboot/ogclient/initrd.img-*|tail -1) $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img
[c1e00e4]505        # Establecer los permisos.
506        chmod -R 755 $INSTALL_TARGET/tftpboot/ogclient
[295b4ab]507        chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/tftpboot/ogclient
[c1e00e4]508        echoAndLog "${FUNCNAME}(): Client update successfully"
509}
[a0867b37]510
511
512#####################################################################
[3320409]513####### Proceso de actualización de OpenGnSys
[a0867b37]514#####################################################################
515
516
517echoAndLog "OpenGnSys update begins at $(date)"
518
519# Instalar dependencia.
520installDependencies $DEPS
521if [ $? -ne 0 ]; then
522        errorAndLog "Error: you may install all needed dependencies."
523        exit 1
524fi
525
526pushd $WORKDIR
527
528# Detectar parámetros de red por defecto
529getNetworkSettings
530if [ $? -ne 0 ]; then
531        errorAndLog "Error reading default network settings."
532        exit 1
533fi
534
535# Arbol de directorios de OpenGnSys.
536createDirs ${INSTALL_TARGET}
537if [ $? -ne 0 ]; then
538        errorAndLog "Error while creating directory paths!"
539        exit 1
540fi
541
542# Si es necesario, descarga el repositorio de código en directorio temporal
543if [ $USESVN -eq 1 ]; then
544        svnExportCode $SVN_URL
545        if [ $? -ne 0 ]; then
546                errorAndLog "Error while getting code from svn"
547                exit 1
548        fi
549else
550        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
551fi
552
[295b4ab]553# Si existe fichero de actualización de la base de datos; aplicar cambios.
554INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
555REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
556OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
557if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
558        echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION"
559        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
560else
561        echoAndLog "Database unchanged."
562fi
563
564# Actualizar ficheros complementarios del servidor
[a0867b37]565updateServerFiles
566if [ $? -ne 0 ]; then
[da8db11]567        errorAndLog "Error updating OpenGnSys Server files"
[a0867b37]568        exit 1
569fi
570
[295b4ab]571# Actualizar ficheros del cliente
572updateClientFiles
573updateInterfaceAdm
[45f1fe8]574
[295b4ab]575# Actualizar páqinas web
[a0867b37]576updateWebFiles
577if [ $? -ne 0 ]; then
[da8db11]578        errorAndLog "Error updating OpenGnSys Web Admin files"
[a0867b37]579        exit 1
580fi
[5d6bf97]581# Generar páginas Doxygen para instalar en el web
582makeDoxygenFiles
[a0867b37]583
584# Creando la estructura del cliente
585recompileClient
[c1e00e4]586# NO se actualiza el antiguo cliente Initrd
587#updateOldClient
[a0867b37]588updateClient
589if [ $? -ne 0 ]; then
590        errorAndLog "Error updating clients"
591        exit 1
592fi
593
[95f1f68]594# Actualizamos el fichero que arranca los servicios de OpenGnSys
595updateServicesStart
596
[3320409]597# Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes
[ebbbfc01]598if [ -f /tmp/dstate ]; then
599        rm -f /tmp/dstate
[3320409]600fi
601
[a0867b37]602#rm -rf $WORKDIR
603echoAndLog "OpenGnSys update finished at $(date)"
604
605popd
606
Note: See TracBrowser for help on using the repository browser.