source: installer/opengnsys_update.sh @ dee9fac

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

#718 #774: Borrar ficheros antiguos de OGAgent y descargar los nuevos durante la instalación/actualización; usar por defecto ogLive basado en kernel 4.8 de 64 bits.

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

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