source: installer/opengnsys_update.sh @ 78b5dfe7

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 78b5dfe7 was 4e51cb0, checked in by ramon <ramongomez@…>, 14 years ago

versión 1.0.1: actualizador más simple y comprueba que exista el directorio del proyecto.

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

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