source: installer/opengnsys_update.sh @ dda6ab9

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 dda6ab9 was 0cfe47a, checked in by ramon <ramongomez@…>, 8 years ago

#765: Corregir errata en revisión r5097 en camino de ficheros SQL y evitar duplicado de índice.

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

  • Property mode set to 100755
File size: 34.7 KB
Line 
1#!/bin/bash
2#/**
3#@file    opengnsys_update.sh
4#@brief   Script actualización de OpenGnsys
5#@version 0.9 - basado en opengnsys_installer.sh
6#@author  Ramón Gómez - ETSII Univ. Sevilla
7#@date    2010/01/27
8#@version 1.0 - adaptación a OpenGnSys 1.0
9#@author  Ramón Gómez - ETSII Univ. Sevilla
10#@date    2011/03/02
11#@version 1.0.1 - control de auto actualización del script
12#@author  Ramón Gómez - ETSII Univ. Sevilla
13#@date    2011/05/17
14#@version 1.0.2a - obtiene valor de dirección IP por defecto
15#@author  Ramón Gómez - ETSII Univ. Sevilla
16#@date    2012/01/18
17#@version 1.0.3 - Compatibilidad con Debian y auto configuración de acceso a BD.
18#@author  Ramón Gómez - ETSII Univ. Sevilla
19#@date    2012/03/12
20#@version 1.0.4 - Detector de distribución y compatibilidad con CentOS.
21#@author  Ramón Gómez - ETSII Univ. Sevilla
22#@date    2012/05/04
23#@version 1.0.5 - Actualizar BD en la misma versión, compatibilidad con Fedora (systemd) y configuración de Rsync.
24#@author  Ramón Gómez - ETSII Univ. Sevilla
25#@date    2014/04/03
26#@version 1.0.6 - Redefinir URLs de ficheros de configuración usando HTTPS.
27#@author  Ramón Gómez - ETSII Univ. Sevilla
28#@date    2015/03/12
29#@version 1.1.0 - Instalación de API REST y configuración de zona horaria.
30#@author  Ramón Gómez - ETSII Univ. Sevilla
31#@date    2015/11/09
32#*/
33
34
35####  AVISO: NO EDITAR variables de configuración.
36####  WARNING: DO NOT EDIT configuration variables.
37INSTALL_TARGET=/opt/opengnsys           # Directorio de instalación
38OPENGNSYS_CLIENTUSER="opengnsys"        # Usuario Samba
39
40
41# Sólo ejecutable por usuario root
42if [ "$(whoami)" != 'root' ]; then
43        echo "ERROR: this program must run under root privileges!!"
44        exit 1
45fi
46# Error si OpenGnsys no está instalado (no existe el directorio del proyecto)
47if [ ! -d $INSTALL_TARGET ]; then
48        echo "ERROR: OpenGnsys is not installed, cannot update!!"
49        exit 1
50fi
51# Cargar configuración de acceso a la base de datos.
52if [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then
53        source $INSTALL_TARGET/etc/ogAdmServer.cfg
54elif [ -r $INSTALL_TARGET/etc/ogAdmAgent.cfg ]; then
55        source $INSTALL_TARGET/etc/ogAdmAgent.cfg
56fi
57OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"}            # Base de datos
58OPENGNSYS_DBUSER=${OPENGNSYS_DBUSER:-"$USUARIO"}                # Usuario de acceso
59OPENGNSYS_DBPASSWORD=${OPENGNSYS_DBPASSWORD:-"$PASSWORD"}       # Clave del usuario
60if [ -z "$OPENGNSYS_DATABASE" -o -z "$OPENGNSYS_DBUSER" -o -z "$OPENGNSYS_DBPASSWORD" ]; then
61        echo "ERROR: set OPENGNSYS_DATABASE, OPENGNSYS_DBUSER and OPENGNSYS_DBPASSWORD"
62        echo "       variables, and run this script again."
63fi
64
65# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
66PROGRAMDIR=$(readlink -e $(dirname "$0"))
67PROGRAMNAME=$(basename "$0")
68OPENGNSYS_SERVER="www.opengnsys.es"
69if [ -d "$PROGRAMDIR/../installer" ]; then
70        USESVN=0
71else
72        USESVN=1
73fi
74SVN_URL="http://$OPENGNSYS_SERVER/svn/branches/version1.1/"
75
76WORKDIR=/tmp/opengnsys_update
77mkdir -p $WORKDIR
78
79# Registro de incidencias.
80OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log
81LOG_FILE=/tmp/$(basename $OGLOGFILE)
82
83
84
85#####################################################################
86####### Algunas funciones útiles de propósito general:
87#####################################################################
88
89# Generar variables de configuración del actualizador
90# Variables globales:
91# - OSDISTRIB - distribución Linux
92# - DEPENDENCIES - array de dependencias que deben estar instaladas
93# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKG - comandos para gestión de paquetes
94# - APACHECFGDIR, APACHESERV, DHCPSERV, INETDCFGDIR - configuración y servicios
95function autoConfigure()
96{
97local i
98
99# Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
100if [ -f /etc/os-release ]; then
101        source /etc/os-release
102        OSDISTRIB="$ID"
103        OSVERSION="$VERSION_ID"
104else
105        OSDISTRIB=$(lsb_release -is 2>/dev/null)
106        OSVERSION=$(lsb_release -rs 2>/dev/null)
107fi
108# Convertir distribución a minúsculas y obtener solo el 1er número de versión.
109OSDISTRIB="${OSDISTRIB,,}"
110OSVERSION="${OSVERSION%%.*}"
111
112# Configuración según la distribución de Linux.
113case "$OSDISTRIB" in
114        ubuntu|debian|linuxmint)
115                DEPENDENCIES=( php5-ldap xinetd rsync btrfs-tools procps arp-scan realpath php5-curl gettext )
116                UPDATEPKGLIST="apt-get update"
117                INSTALLPKGS="apt-get -y install --force-yes"
118                CHECKPKG="dpkg -s \$package 2>/dev/null | grep -q \"Status: install ok\""
119                if which service &>/dev/null; then
120                        STARTSERVICE="eval service \$service restart"
121                        STOPSERVICE="eval service \$service stop"
122                else
123                        STARTSERVICE="eval /etc/init.d/\$service restart"
124                        STOPSERVICE="eval /etc/init.d/\$service stop"
125                fi
126                ENABLESERVICE="eval update-rc.d \$service defaults"
127                APACHEUSER="www-data"
128                APACHEGROUP="www-data"
129                INETDCFGDIR=/etc/xinetd.d
130                ;;
131        fedora|centos)
132                DEPENDENCIES=( php-ldap xinetd rsync btrfs-progs procps-ng arp-scan gettext )
133                # En CentOS 7 instalar arp-scan de CentOS 6.
134                [ "$OSDISTRIB$OSVERSION" == "centos7" ] && DEPENDENCIES=( ${DEPENDENCIES[*]/arp-scan/http://dag.wieers.com/redhat/el6/en/$(arch)/dag/RPMS/arp-scan-1.9-1.el6.rf.$(arch).rpm} )
135                INSTALLPKGS="yum install -y"
136                CHECKPKG="rpm -q --quiet \$package"
137                if which systemctl &>/dev/null; then
138                        STARTSERVICE="eval systemctl start \$service.service"
139                        STOPSERVICE="eval systemctl stop \$service.service"
140                        ENABLESERVICE="eval systemctl enable \$service.service"
141                else
142                        STARTSERVICE="eval service \$service start"
143                        STOPSERVICE="eval service \$service stop"
144                        ENABLESERVICE="eval chkconfig \$service on"
145                fi
146                APACHEUSER="apache"
147                APACHEGROUP="apache"
148                INETDCFGDIR=/etc/xinetd.d
149                ;;
150        *)      # Otras distribuciones.
151                ;;
152esac
153for i in apache2 httpd; do
154        [ -f /etc/$i ] && APACHECFGDIR="/etc/$i"
155        [ -f /etc/init.d/$i ] && APACHESERV="/etc/init.d/$i"
156done
157for i in dhcpd dhcpd3-server isc-dhcp-server; do
158        [ -f /etc/init.d/$i ] && DHCPSERV="/etc/init.d/$i"
159done
160}
161
162
163# Comprobar auto-actualización.
164function checkAutoUpdate()
165{
166        local update=0
167
168        # Actaulizar el script si ha cambiado o no existe el original.
169        if [ $USESVN -eq 1 ]; then
170                svn export $SVN_URL/installer/$PROGRAMNAME
171                if ! diff -q $PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
172                        mv $PROGRAMNAME $INSTALL_TARGET/lib
173                        update=1
174                else
175                        rm -f $PROGRAMNAME
176                fi
177        else
178                if ! diff -q $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
179                        cp -a $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib
180                        update=1
181                fi
182        fi
183
184        return $update
185}
186
187
188function getDateTime()
189{
190        date "+%Y%m%d-%H%M%S"
191}
192
193# Escribe a fichero y muestra por pantalla
194function echoAndLog()
195{
196        echo $1
197        DATETIME=`getDateTime`
198        echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE
199}
200
201function errorAndLog()
202{
203        echo "ERROR: $1"
204        DATETIME=`getDateTime`
205        echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
206}
207
208# Escribe a fichero y muestra mensaje de aviso
209function warningAndLog()
210{
211        local DATETIME=`getDateTime`
212        echo "Warning: $1"
213        echo "$DATETIME;$SSH_CLIENT;Warning: $1" >> $LOG_FILE
214}
215
216
217#####################################################################
218####### Funciones de copia de seguridad y restauración de ficheros
219#####################################################################
220
221# Hace un backup del fichero pasado por parámetro
222# deja un -last y uno para el día
223function backupFile()
224{
225        if [ $# -ne 1 ]; then
226                errorAndLog "${FUNCNAME}(): invalid number of parameters"
227                exit 1
228        fi
229
230        local fichero=$1
231        local fecha=`date +%Y%m%d`
232
233        if [ ! -f $fichero ]; then
234                warningAndLog "${FUNCNAME}(): file $fichero doesn't exists"
235                return 1
236        fi
237
238        echoAndLog "${FUNCNAME}(): Making $fichero back-up"
239
240        # realiza una copia de la última configuración como last
241        cp -a $fichero "${fichero}-LAST"
242
243        # si para el día no hay backup lo hace, sino no
244        if [ ! -f "${fichero}-${fecha}" ]; then
245                cp -a $fichero "${fichero}-${fecha}"
246        fi
247}
248
249# Restaura un fichero desde su copia de seguridad
250function restoreFile()
251{
252        if [ $# -ne 1 ]; then
253                errorAndLog "${FUNCNAME}(): invalid number of parameters"
254                exit 1
255        fi
256
257        local fichero=$1
258
259        echoAndLog "${FUNCNAME}(): restoring file $fichero"
260        if [ -f "${fichero}-LAST" ]; then
261                cp -a "$fichero-LAST" "$fichero"
262        fi
263}
264
265
266#####################################################################
267####### Funciones de acceso a base de datos
268#####################################################################
269
270# Actualizar la base datos
271function importSqlFile()
272{
273        if [ $# -ne 4 ]; then
274                errorAndLog "${FNCNAME}(): invalid number of parameters"
275                exit 1
276        fi
277
278        local dbuser="$1"
279        local dbpassword="$2"
280        local database="$3"
281        local sqlfile="$4"
282        local tmpfile=$(mktemp)
283        local mycnf=/tmp/.my.cnf.$$
284        local status
285        local APIKEY=$(php -r 'echo md5(uniqid(rand(), true));')
286        REPOKEY=$(php -r 'echo md5(uniqid(rand(), true));')
287
288        if [ ! -r $sqlfile ]; then
289                errorAndLog "${FUNCNAME}(): Unable to read $sqlfile!!"
290                return 1
291        fi
292
293        echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..."
294        chmod 600 $tmpfile
295        sed -e "s/SERVERIP/$SERVERIP/g" -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
296            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
297            -e "s/APIKEY/$APIKEY/g" -e "s/REPOKEY/$REPOKEY/g" $sqlfile > $tmpfile
298        # Componer fichero con credenciales de conexión. 
299        touch $mycnf
300        chmod 600 $mycnf
301        cat << EOT > $mycnf
302[client]
303user=$dbuser
304password=$dbpassword
305EOT
306        # Ejecutar actualización y borrar fichero de credenciales.
307        mysql --defaults-extra-file=$mycnf --default-character-set=utf8 -D "$database" < $tmpfile
308        status=$?
309        rm -f $mycnf $tmpfile
310        if [ $status -ne 0 ]; then
311                errorAndLog "${FUNCNAME}(): error importing $sqlfile in database $database"
312                return 1
313        fi
314        echoAndLog "${FUNCNAME}(): file imported to database $database"
315        return 0
316}
317
318
319#####################################################################
320####### Funciones de instalación de paquetes
321#####################################################################
322
323# Instalar las deependencias necesarias para el actualizador.
324function installDependencies()
325{
326        local package
327
328        if [ $# = 0 ]; then
329                echoAndLog "${FUNCNAME}(): no deps needed."
330        else
331                while [ $# -gt 0 ]; do
332                        package="$1"
333                        eval $CHECKPKG || INSTALLDEPS="$INSTALLDEPS $1"
334                        shift
335                done
336                if [ -n "$INSTALLDEPS" ]; then
337                        $UPDATEPKGLIST
338                        $INSTALLPKGS $INSTALLDEPS
339                        if [ $? -ne 0 ]; then
340                                errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS."
341                                return 1
342                        fi
343                fi
344        fi
345}
346
347
348#####################################################################
349####### Funciones para el manejo de Subversion
350#####################################################################
351
352function svnExportCode()
353{
354        if [ $# -ne 1 ]; then
355                errorAndLog "${FUNCNAME}(): invalid number of parameters"
356                exit 1
357        fi
358
359        local url="$1"
360
361        echoAndLog "${FUNCNAME}(): downloading subversion code..."
362
363        svn checkout "${url}" opengnsys
364        if [ $? -ne 0 ]; then
365                errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
366                return 1
367        fi
368        echoAndLog "${FUNCNAME}(): subversion code downloaded"
369        return 0
370}
371
372
373############################################################
374###  Detectar red
375############################################################
376
377# Comprobar si existe conexión.
378function checkNetworkConnection()
379{
380        OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"}
381        wget --spider -q $OPENGNSYS_SERVER
382}
383
384# Obtener los parámetros de red del servidor.
385function getNetworkSettings()
386{
387        # Variables globales definidas:
388        # - SERVERIP:   IP local de la interfaz por defecto.
389
390        local DEVICES
391        local dev
392
393        echoAndLog "${FUNCNAME}(): Detecting network parameters."
394        SERVERIP="$ServidorAdm"
395        DEVICES="$(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}')"
396        for dev in $DEVICES; do
397                [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
398        done
399}
400
401
402#####################################################################
403####### Funciones específicas de la instalación de Opengnsys
404#####################################################################
405
406# Actualizar cliente OpenGnsys.
407function updateClientFiles()
408{
409        local ENGINECFG=$INSTALL_TARGET/client/etc/engine.cfg
410
411        # Actualizar ficheros del cliente.
412        backupFile $ENGINECFG
413        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Client files."
414        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
415        if [ $? -ne 0 ]; then
416                errorAndLog "${FUNCNAME}(): error while updating client structure"
417                exit 1
418        fi
419        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
420
421        # Actualizar librerías del motor de clonación.
422        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Cloning Engine files."
423        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
424        if [ $? -ne 0 ]; then
425                errorAndLog "${FUNCNAME}(): error while updating engine files"
426                exit 1
427        fi
428        # Actualizar fichero de configuración del motor de clonación.
429        if ! grep -q "^TZ" $ENGINECFG; then
430                TZ=$(timedatectl status | awk -F"[:()]" '/Time.*zone/ {print $2}')
431                cat << EOT >> $ENGINECFG
432# OpenGnsys Server timezone.
433TZ="${TZ// /}"
434EOT
435        fi
436        if ! diff -q ${ENGINECFG}{,-LAST} &>/dev/null; then
437                NEWFILES="$NEWFILES $ENGINECFG"
438        else
439                rm -f ${ENGINECFG}-LAST
440        fi
441
442        echoAndLog "${FUNCNAME}(): client files update success."
443}
444
445# Configurar HTTPS y exportar usuario y grupo del servicio Apache.
446function apacheConfiguration ()
447{
448        # Activar HTTPS (solo actualizando desde versiones anteriores a 1.0.2) y
449        #    activar módulo Rewrite (solo actualizaciones desde 1.0.x a 1.1.x).
450        if [ -e $APACHECFGDIR/sites-available/opengnsys.conf ]; then
451                echoAndLog "${FUNCNAME}(): Configuring Apache modules."
452                mv $APACHECFGDIR/sites-available/opengnsys.conf $APACHECFGDIR/sites-available/opengnsys
453                a2ensite default-ssl
454                a2enmod ssl
455                a2enmod rewrite
456                a2dissite opengnsys.conf
457                a2ensite opengnsys
458        elif [ -e $APACHECFGDIR/conf.modules.d ]; then
459                echoAndLog "${FUNCNAME}(): Configuring Apache modules."
460                sed -i '/rewrite/s/^#//' $APACHECFGDIR/*.conf
461        fi
462
463        # Actualizar configuración para acceso a API REST
464        #    (solo actualizaciones de 1.0.x a 1.1.x).
465        for config in $APACHECFGDIR/{,sites-available/}opengnsys.conf ]; do
466                if [ -e $config ] && ! grep -q "/rest" $config; then
467                        cat << EOT >> $config
468<Directory $INSTALL_TARGET/www/rest>
469        RewriteEngine On
470        RewriteBase /opengnsys/rest/
471        RewriteCond %{REQUEST_FILENAME} !-f
472        RewriteRule ^ index.php [QSA,L]
473</Directory>
474EOT
475                fi
476        done
477
478        # Reiniciar Apache.
479        $APACHESERV restart
480
481        # Variables de ejecución de Apache.
482        # - APACHE_RUN_USER
483        # - APACHE_RUN_GROUP
484        if [ -f $APACHECFGDIR/envvars ]; then
485                source $APACHECFGDIR/envvars
486        fi
487        APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"}
488        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
489}
490
491# Configurar servicio Rsync.
492function rsyncConfigure()
493{
494        local service
495
496        # Configurar acceso a Rsync.
497        if [ ! -f /etc/rsyncd.conf ]; then
498                echoAndLog "${FUNCNAME}(): Configuring Rsync service."
499                NEWFILES="$NEWFILES /etc/rsyncd.conf"
500                sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENTUSER/g" \
501                    $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > /etc/rsyncd.conf
502                # Habilitar Rsync.
503                if [ -f /etc/default/rsync ]; then
504                        perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
505                fi
506                if [ -f $INETDCFGDIR/rsync ]; then
507                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
508                else
509                        cat << EOT > $INETDCFGDIR/rsync
510service rsync
511{
512        disable = no
513        socket_type = stream
514        wait = no
515        user = root
516        server = $(which rsync)
517        server_args = --daemon
518        log_on_failure += USERID
519        flags = IPv6
520}
521EOT
522                fi
523                # Activar e iniciar Rsync.
524                service="rsync"  $ENABLESERVICE
525                service="xinetd"
526                $ENABLESERVICE; $STARTSERVICE
527        fi
528}
529
530# Copiar ficheros del OpenGnsys Web Console.
531function updateWebFiles()
532{
533        local ERRCODE COMPATDIR f
534
535        echoAndLog "${FUNCNAME}(): Updating web files..."
536
537        # Copiar los ficheros nuevos conservando el archivo de configuración de acceso.
538        backupFile $INSTALL_TARGET/www/controlacceso.php
539        mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
540        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
541        ERRCODE=$?
542        mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
543        unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
544        unzip -o $WORKDIR/opengnsys/admin/slim-2.6.1.zip -d $INSTALL_TARGET/www/rest
545        unzip -o $WORKDIR/opengnsys/admin/swagger-ui-2.2.5.zip -d $INSTALL_TARGET/www/rest
546        if [ $ERRCODE != 0 ]; then
547                errorAndLog "${FUNCNAME}(): Error updating web files."
548                exit 1
549        fi
550        restoreFile $INSTALL_TARGET/www/controlacceso.php
551
552        # Cambiar acceso a protocolo HTTPS.
553        if grep -q "http://" $INSTALL_TARGET/www/controlacceso.php 2>/dev/null; then
554                echoAndLog "${FUNCNAME}(): updating web access file"
555                perl -pi -e 's!http://!https://!g' $INSTALL_TARGET/www/controlacceso.php
556                NEWFILES="$NEWFILES $INSTALL_TARGET/www/controlacceso.php"
557        fi
558
559        # Compatibilidad con dispositivos móviles.
560        COMPATDIR="$INSTALL_TARGET/www/principal"
561        for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
562                sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
563        done
564        cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
565
566        # Cambiar permisos para ficheros especiales.
567        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
568        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/
569        # Fichero de logs del agente OGAgent.
570        touch $INSTALL_TARGET/log/ogagent.log
571        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/log/ogagent.log
572
573        echoAndLog "${FUNCNAME}(): Web files updated successfully."
574}
575
576# Copiar carpeta de Interface
577function updateInterfaceAdm()
578{
579        local errcode=0
580
581        # Crear carpeta y copiar Interface
582        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
583        mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
584        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
585        errcoce=$?
586        mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm
587        if [ $errcode -ne 0 ]; then
588                echoAndLog "${FUNCNAME}(): error while updating admin interface"
589                exit 1
590        fi
591        chmod -R +x $INSTALL_TARGET/client/interfaceAdm
592        chown $OPENGNSYS_CLIENTUSER:$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
593        chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
594        echoAndLog "${FUNCNAME}(): Admin interface updated successfully."
595}
596
597# Crear documentación Doxygen para la consola web.
598function makeDoxygenFiles()
599{
600        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
601        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
602                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
603        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
604                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files."
605                return 1
606        fi
607        rm -fr "$INSTALL_TARGET/www/api"
608        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
609        rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf}
610        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api
611        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully."
612}
613
614
615# Crea la estructura base de la instalación de opengnsys
616function createDirs()
617{
618        # Crear estructura de directorios.
619        echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}"
620        local dir
621
622        mkdir -p ${INSTALL_TARGET}/{bin,doc,etc,lib,sbin,www}
623        mkdir -p ${INSTALL_TARGET}/{client,images}
624        mkdir -p ${INSTALL_TARGET}/log/clients
625        ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys
626        # Detectar directorio de instalación de TFTP.
627        if [ ! -L ${INSTALL_TARGET}/tftpboot ]; then
628                for dir in /var/lib/tftpboot /srv/tftp; do
629                        [ -d $dir ] && ln -fs $dir ${INSTALL_TARGET}/tftpboot
630                done
631        fi
632        mkdir -p ${INSTALL_TARGET}/tftpboot/menu.lst
633        if [ $? -ne 0 ]; then
634                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
635                return 1
636        fi
637
638        # Crear usuario ficticio.
639        if id -u $OPENGNSYS_CLIENTUSER &>/dev/null; then
640                echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENTUSER\" is already created"
641        else
642                echoAndLog "${FUNCNAME}(): creating OpenGnsys user"
643                useradd $OPENGNSYS_CLIENTUSER 2>/dev/null
644                if [ $? -ne 0 ]; then
645                        errorAndLog "${FUNCNAME}(): error creating OpenGnsys user"
646                        return 1
647                fi
648        fi
649
650        # Establecer los permisos básicos.
651        echoAndLog "${FUNCNAME}(): setting directory permissions"
652        chmod -R 775 $INSTALL_TARGET/{log/clients,images,tftpboot/menu.lst}
653        mkdir -p $INSTALL_TARGET/tftpboot/menu.lst/examples
654        ! [ -f $INSTALL_TARGET/tftpboot/menu.lst/templates/00unknown ] && mv $INSTALL_TARGET/tftpboot/menu.lst/templates/* $INSTALL_TARGET/tftpboot/menu.lst/examples
655        chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/{log/clients,images,tftpboot/menu.lst}
656        if [ $? -ne 0 ]; then
657                errorAndLog "${FUNCNAME}(): error while setting permissions"
658                return 1
659        fi
660
661        # Mover el fichero de registro al directorio de logs.
662        echoAndLog "${FUNCNAME}(): moving update log file"
663        mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
664        chmod 600 $LOG_FILE
665
666        echoAndLog "${FUNCNAME}(): directory paths created"
667        return 0
668}
669
670# Actualización incremental de la BD (versión actaul a actaul+1, hasta final-1 a final).
671function updateDatabase()
672{
673        local OLDVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
674        local NEWVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
675        local DBDIR="$WORKDIR/opengnsys/admin/Database"
676        local file FILES=""
677
678        echoAndLog "${FUNCNAME}(): looking for database updates"
679        pushd $DBDIR >/dev/null
680        # Bucle de actualización incremental desde versión actual a la final.
681        for file in $OPENGNSYS_DATABASE-*-*.sql; do
682                case "$file" in
683                        $OPENGNSYS_DATABASE-$OLDVERSION-$NEWVERSION.sql)
684                                # Actualización única de versión inicial y final.
685                                FILES="$FILES $file"
686                                break
687                                ;;
688                        $OPENGNSYS_DATABASE-*-postinst.sql)
689                                # Ignorar fichero específico de post-instalación.
690                                ;;
691                        $OPENGNSYS_DATABASE-$OLDVERSION-*.sql)
692                                # Actualización de versión n a n+1.
693                                FILES="$FILES $file"
694                                OLDVERSION="$(echo $file | cut -f3 -d-)"
695                                ;;
696                        $OPENGNSYS_DATABASE-*-$NEWVERSION.sql)
697                                # Última actualización de versión final-1 a final.
698                                if [ -n "$FILES" ]; then
699                                        FILES="$FILES $file"
700                                        break
701                                fi
702                                ;;
703                esac
704        done
705        # Aplicar posible actualización propia para la versión final.
706        file=$OPENGNSYS_DATABASE-$NEWVERSION.sql
707        if [ -n "$FILES" -o "$OLDVERSION" = "$NEWVERSION" -a -r $file ]; then
708                FILES="$FILES $file"
709        fi
710
711        popd >/dev/null
712        if [ -n "$FILES" ]; then
713                for file in $FILES; do
714                        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $DBDIR/$file
715                done
716                echoAndLog "${FUNCNAME}(): database is update"
717        else
718                echoAndLog "${FUNCNAME}(): database unchanged"
719        fi
720}
721
722# Copia ficheros de configuración y ejecutables genéricos del servidor.
723function updateServerFiles()
724{
725        # No copiar ficheros del antiguo cliente Initrd
726        local SOURCES=( repoman/bin \
727                        server/bin \
728                        server/lib \
729                        admin/Sources/Services/ogAdmServerAux \
730                        admin/Sources/Services/ogAdmRepoAux \
731                        server/tftpboot \
732                        installer/opengnsys_uninstall.sh \
733                        installer/opengnsys_export.sh \
734                        installer/opengnsys_import.sh \
735                        doc )
736        local TARGETS=( bin \
737                        bin \
738                        lib \
739                        sbin/ogAdmServerAux \
740                        sbin/ogAdmRepoAux \
741                        tftpboot \
742                        lib/opengnsys_uninstall.sh \
743                        lib/opengnsys_export.sh \
744                        lib/opengnsys_import.sh \
745                        doc )
746
747        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
748                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
749                exit 1
750        fi
751
752        echoAndLog "${FUNCNAME}(): updating files in server directories"
753        pushd $WORKDIR/opengnsys >/dev/null
754        local i
755        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
756                if [ -d "$INSTALL_TARGET/${TARGETS[i]}" ]; then
757                        rsync --exclude .svn -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}"))
758                else
759                        rsync -irplt "${SOURCES[i]}" $(readlink -m "$INSTALL_TARGET/${TARGETS[i]}")
760                fi
761        done
762        popd >/dev/null
763        NEWFILES=""             # Ficheros de configuración que han cambiado de formato.
764        if grep -q 'pxelinux.0' /etc/dhcp*/dhcpd*.conf; then
765                echoAndLog "${FUNCNAME}(): updating DHCP files"
766                perl -pi -e 's/pxelinux.0/grldr/' /etc/dhcp*/dhcpd*.conf
767                $DHCPSERV restart
768                NEWFILES="/etc/dhcp*/dhcpd*.conf"
769        fi
770        if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then
771                echoAndLog "${FUNCNAME}(): updating new init file"
772                backupFile /etc/init.d/opengnsys
773                cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
774                NEWFILES="$NEWFILES /etc/init.d/opengnsys"
775        fi
776        if egrep -q "(UrlMsg=.*msgbrowser.php)|(UrlMenu=http://)" $INSTALL_TARGET/client/etc/ogAdmClient.cfg 2>/dev/null; then
777                echoAndLog "${FUNCNAME}(): updating new client config file"
778                backupFile $INSTALL_TARGET/client/etc/ogAdmClient.cfg
779                perl -pi -e 's!UrlMsg=.*msgbrowser\.php!UrlMsg=http://localhost/cgi-bin/httpd-log\.sh!g; s!UrlMenu=http://!UrlMenu=https://!g' $INSTALL_TARGET/client/etc/ogAdmClient.cfg
780                NEWFILES="$NEWFILES $INSTALL_TARGET/client/etc/ogAdmClient.cfg"
781        fi
782
783        echoAndLog "${FUNCNAME}(): updating cron files"
784        [ ! -f /etc/cron.d/opengnsys ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
785        [ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
786        [ ! -f /etc/cron.d/torrenttracker ] && echo "5 * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
787        [ ! -f /etc/cron.d/imagedelete ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
788        echoAndLog "${FUNCNAME}(): server files updated successfully."
789}
790
791####################################################################
792### Funciones de compilación de código fuente de servicios
793####################################################################
794
795# Mueve el fichero del nuevo servicio si es distinto al del directorio destino.
796function moveNewService()
797{
798        local service
799
800        # Recibe 2 parámetros: fichero origen y directorio destino.
801        [ $# == 2 ] || return 1
802        [ -f  $1 -a -d $2 ] || return 1
803
804        # Comparar los ficheros.
805        if ! diff -q $1 $2/$(basename $1) &>/dev/null; then
806                # Parar los servicios si fuese necesario.
807                [ -z "$NEWSERVICES" ] && service="opengnsys" $STOPSERVICE
808                # Nuevo servicio.
809                NEWSERVICES="$NEWSERVICES $(basename $1)"
810                # Mover el nuevo fichero de servicio
811                mv $1 $2
812        fi
813}
814
815
816# Recompilar y actualiza los serivicios y clientes.
817function compileServices()
818{
819        local hayErrores=0
820
821        # Compilar OpenGnsys Server
822        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Admin Server"
823        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
824        make && moveNewService ogAdmServer $INSTALL_TARGET/sbin
825        if [ $? -ne 0 ]; then
826                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server"
827                hayErrores=1
828        fi
829        popd
830        # Compilar OpenGnsys Repository Manager
831        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Repository Manager"
832        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo
833        make && moveNewService ogAdmRepo $INSTALL_TARGET/sbin
834        if [ $? -ne 0 ]; then
835                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Repository Manager"
836                hayErrores=1
837        fi
838        popd
839        # Actualizar o insertar clave de acceso REST en el fichero de configuración del repositorio.
840        grep -q '^ApiToken=' $INSTALL_TARGET/etc/ogAdmRepo.cfg && \
841                sed -i "s/^ApiToken=.*$/ApiToken=$REPOKEY/" $INSTALL_TARGET/etc/ogAdmRepo.cfg || \
842                sed -i "$ a\ApiToken=$REPOKEY/" $INSTALL_TARGET/etc/ogAdmRepo.cfg
843        # Compilar OpenGnsys Agent
844        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Agent"
845        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
846        make && moveNewService ogAdmAgent $INSTALL_TARGET/sbin
847        if [ $? -ne 0 ]; then
848                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Agent"
849                hayErrores=1
850        fi
851        popd
852
853        # Compilar OpenGnsys Client
854        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Client"
855        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
856        make && mv ogAdmClient $INSTALL_TARGET/client/bin
857        if [ $? -ne 0 ]; then
858                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Client"
859                hayErrores=1
860        fi
861        popd
862
863        return $hayErrores
864}
865
866
867####################################################################
868### Funciones instalacion cliente OpenGnsys
869####################################################################
870
871# Actualizar cliente OpenGnsys
872function updateClient()
873{
874        local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads"
875        #local FILENAME=ogLive-wily-4.2.0-35-generic-r4919.iso          # 1.1.0-rc3
876        local FILENAME=ogLive-xenial-4.4.0-34-generic-r4999.iso         # 1.1.0-rc4
877        local SOURCEFILE=$DOWNLOADURL/$FILENAME
878        local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME
879        local SOURCELENGTH
880        local TARGETLENGTH
881        local OGINITRD=$INSTALL_TARGET/tftpboot/ogclient/oginitrd.img
882        local OGVMLINUZ=$INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz
883        local SAMBAPASS
884        local KERNELVERSION
885
886        # Comprobar si debe actualizarse el cliente.
887        SOURCELENGTH=$(LANG=C wget --spider $SOURCEFILE 2>&1 | awk '/Length:/ {print $2}')
888        TARGETLENGTH=$(ls -l $TARGETFILE 2>/dev/null | awk '{print $5}')
889        [ -z $TARGETLENGTH ] && TARGETLENGTH=0
890        if [ "$SOURCELENGTH" != "$TARGETLENGTH" ]; then
891                echoAndLog "${FUNCNAME}(): Loading Client"
892                wget $DOWNLOADURL/$FILENAME -O $TARGETFILE
893                if [ ! -s $TARGETFILE ]; then
894                        errorAndLog "${FUNCNAME}(): Error loading OpenGnsys Client"
895                        return 1
896                fi
897                # Actaulizar la imagen ISO del ogclient.
898                echoAndLog "${FUNCNAME}(): Updatting ogclient files"
899                $INSTALL_TARGET/bin/installoglive $TARGETFILE
900               
901                # Obtiene versión del Kernel del cliente (con 2 decimales).
902                KERNELVERSION=$(file -bkr $OGVMLINUZ 2>/dev/null | \
903                                awk '/Linux/ { for (i=1; i<=NF; i++)
904                                                   if ($i~/version/) {
905                                                      v=$(i+1);
906                                                      printf ("%d",v);
907                                                      sub (/[0-9]*\./,"",v);
908                                                      printf (".%02d",v)
909                                             } }')
910                # Actaulizar la base de datos adaptada al Kernel del cliente.
911                OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-postinst.sql"
912                if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
913                        perl -pi -e "s/KERNELVERSION/$KERNELVERSION/g" $OPENGNSYS_DBUPDATEFILE
914                        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
915                fi
916
917                echoAndLog "${FUNCNAME}(): Client update successfully"
918        else
919                # Si no existe, crear el fichero de claves de Rsync.
920                if [ ! -f /etc/rsyncd.secrets ]; then
921                        echoAndLog "${FUNCNAME}(): Restoring client access key"
922                        SAMBAPASS=$(gzip -dc $OGINITRD | \
923                                    cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
924                                    grep "^[    ].*OPTIONS=" | \
925                                    sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
926                        echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | \
927                                        $INSTALL_TARGET/bin/setsmbpass
928                else
929                        echoAndLog "${FUNCNAME}(): Client is already updated"
930                fi
931        fi
932}
933
934# Comprobar permisos y ficheros.
935function checkFiles()
936{
937        # Comprobar permisos adecuados.
938        if [ -x $INSTALL_TARGET/bin/checkperms ]; then
939                echoAndLog "${FUNCNAME}(): Checking permissions."
940                OPENGNSYS_DIR="$INSTALL_TARGET" OPENGNSYS_USER="$OPENGNSYS_CLIENTUSER" APACHE_USER="$APACHE_RUN_USER" APACHE_GROUP="$APACHE_RUN_GROUP" $INSTALL_TARGET/bin/checkperms
941        fi
942
943        # Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes
944        if [ -f /tmp/dstate ]; then
945                echoAndLog "${FUNCNAME}(): Delete unused files."
946                rm -f /tmp/dstate
947        fi
948}
949
950# Resumen de actualización.
951function updateSummary()
952{
953        # Actualizar fichero de versión y revisión.
954        local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
955        local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
956
957        [ -f $VERSIONFILE ] || echo "OpenGnsys" >$VERSIONFILE
958        perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
959
960        echo
961        echoAndLog "OpenGnsys Update Summary"
962        echo       "========================"
963        echoAndLog "Project version:                  $(cat $VERSIONFILE)"
964        echoAndLog "Update log file:                  $LOG_FILE"
965        if [ -n "$NEWFILES" ]; then
966                echoAndLog "Check new config files:           $(echo $NEWFILES)"
967        fi
968        if [ -n "$NEWSERVICES" ]; then
969                echoAndLog "New compiled services:            $(echo $NEWSERVICES)"
970                # Indicar si se debe reiniciar servicios manualmente o usando el Cron.
971                [ -f /etc/default/opengnsys ] && source /etc/default/opengnsys
972                if [ "$RUN_CRONJOB" == "no" ]; then
973                        echoAndLog "        WARNING: you must restart OpenGnsys services manually."
974                else
975                        echoAndLog "        New OpenGnsys services will be restarted by the cronjob."
976                fi
977        fi
978        echoAndLog "Warning: You must to clear web browser cache before loading OpenGnSys page."
979        echo
980}
981
982
983
984#####################################################################
985####### Proceso de actualización de OpenGnsys
986#####################################################################
987
988
989echoAndLog "OpenGnsys update begins at $(date)"
990
991pushd $WORKDIR
992
993# Comprobar si hay conexión y detectar parámetros de red por defecto.
994checkNetworkConnection
995if [ $? -ne 0 ]; then
996        errorAndLog "Error connecting to server. Causes:"
997        errorAndLog " - Network is unreachable, review devices parameters."
998        errorAndLog " - You are inside a private network, configure the proxy service."
999        errorAndLog " - Server is temporally down, try agian later."
1000        exit 1
1001fi
1002getNetworkSettings
1003
1004# Comprobar auto-actualización del programa.
1005if [ "$PROGRAMDIR" != "$INSTALL_TARGET/bin" ]; then
1006        checkAutoUpdate
1007        if [ $? -ne 0 ]; then
1008                echoAndLog "OpenGnsys updater has been overwritten."
1009                echoAndLog "Please, re-execute this script."
1010                exit
1011        fi
1012fi
1013
1014# Detectar datos de auto-configuración del instalador.
1015autoConfigure
1016
1017# Instalar dependencias.
1018installDependencies ${DEPENDENCIES[*]}
1019if [ $? -ne 0 ]; then
1020        errorAndLog "Error: you may install all needed dependencies."
1021        exit 1
1022fi
1023
1024# Arbol de directorios de OpenGnsys.
1025createDirs ${INSTALL_TARGET}
1026if [ $? -ne 0 ]; then
1027        errorAndLog "Error while creating directory paths!"
1028        exit 1
1029fi
1030
1031# Si es necesario, descarga el repositorio de código en directorio temporal
1032if [ $USESVN -eq 1 ]; then
1033        svnExportCode $SVN_URL
1034        if [ $? -ne 0 ]; then
1035                errorAndLog "Error while getting code from svn"
1036                exit 1
1037        fi
1038else
1039        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
1040fi
1041
1042# Actualizar la BD.
1043updateDatabase
1044
1045# Actualizar ficheros complementarios del servidor
1046updateServerFiles
1047if [ $? -ne 0 ]; then
1048        errorAndLog "Error updating OpenGnsys Server files"
1049        exit 1
1050fi
1051
1052# Configurar Rsync.
1053rsyncConfigure
1054
1055# Actualizar ficheros del cliente
1056updateClientFiles
1057updateInterfaceAdm
1058
1059# Actualizar páqinas web
1060apacheConfiguration
1061updateWebFiles
1062if [ $? -ne 0 ]; then
1063        errorAndLog "Error updating OpenGnsys Web Admin files"
1064        exit 1
1065fi
1066# Generar páginas Doxygen para instalar en el web
1067makeDoxygenFiles
1068
1069# Recompilar y actualizar los servicios del sistema
1070compileServices
1071
1072# Actaulizar ficheros auxiliares del cliente
1073updateClient
1074if [ $? -ne 0 ]; then
1075        errorAndLog "Error updating clients"
1076        exit 1
1077fi
1078
1079# Comprobar permisos y ficheros.
1080checkFiles
1081
1082# Mostrar resumen de actualización.
1083updateSummary
1084
1085#rm -rf $WORKDIR
1086echoAndLog "OpenGnsys update finished at $(date)"
1087
1088popd
1089
Note: See TracBrowser for help on using the repository browser.