source: installer/opengnsys_update.sh @ 80fd30e

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 80fd30e was 103bc82, checked in by ramon <ramongomez@…>, 8 years ago

#718: Instalador y actualizador configuran tipo MIME para que descargar paquetes macOS como binarios.

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

  • Property mode set to 100755
File size: 35.3 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 moreutils jq )
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 moreutils jq )
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                PHP5VERSION=$(apt-cache pkgnames php5 2>/dev/null | sort | head -1)
332                while [ $# -gt 0 ]; do
333                        package="${1/php5/$PHP5VERSION}"
334                        eval $CHECKPKG || INSTALLDEPS="$INSTALLDEPS $package"
335                        shift
336                done
337                if [ -n "$INSTALLDEPS" ]; then
338                        $UPDATEPKGLIST
339                        $INSTALLPKGS $INSTALLDEPS
340                        if [ $? -ne 0 ]; then
341                                errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS."
342                                return 1
343                        fi
344                fi
345        fi
346}
347
348
349#####################################################################
350####### Funciones para el manejo de Subversion
351#####################################################################
352
353function svnExportCode()
354{
355        if [ $# -ne 1 ]; then
356                errorAndLog "${FUNCNAME}(): invalid number of parameters"
357                exit 1
358        fi
359
360        local url="$1"
361
362        echoAndLog "${FUNCNAME}(): downloading subversion code..."
363
364        svn checkout "${url}" opengnsys
365        if [ $? -ne 0 ]; then
366                errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
367                return 1
368        fi
369        echoAndLog "${FUNCNAME}(): subversion code downloaded"
370        return 0
371}
372
373
374############################################################
375###  Detectar red
376############################################################
377
378# Comprobar si existe conexión.
379function checkNetworkConnection()
380{
381        OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"}
382        wget --spider -q $OPENGNSYS_SERVER
383}
384
385# Obtener los parámetros de red del servidor.
386function getNetworkSettings()
387{
388        # Variables globales definidas:
389        # - SERVERIP:   IP local de la interfaz por defecto.
390
391        local DEVICES
392        local dev
393
394        echoAndLog "${FUNCNAME}(): Detecting network parameters."
395        SERVERIP="$ServidorAdm"
396        DEVICES="$(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}')"
397        for dev in $DEVICES; do
398                [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
399        done
400}
401
402
403#####################################################################
404####### Funciones específicas de la instalación de Opengnsys
405#####################################################################
406
407# Actualizar cliente OpenGnsys.
408function updateClientFiles()
409{
410        local ENGINECFG=$INSTALL_TARGET/client/etc/engine.cfg
411
412        # Actualizar ficheros del cliente.
413        backupFile $ENGINECFG
414        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Client files."
415        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
416        if [ $? -ne 0 ]; then
417                errorAndLog "${FUNCNAME}(): error while updating client structure"
418                exit 1
419        fi
420        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
421
422        # Actualizar librerías del motor de clonación.
423        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Cloning Engine files."
424        rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
425        if [ $? -ne 0 ]; then
426                errorAndLog "${FUNCNAME}(): error while updating engine files"
427                exit 1
428        fi
429        # Actualizar fichero de configuración del motor de clonación.
430        if ! grep -q "^TZ" $ENGINECFG; then
431                TZ=$(timedatectl status | awk -F"[:()]" '/Time.*zone/ {print $2}')
432                cat << EOT >> $ENGINECFG
433# OpenGnsys Server timezone.
434TZ="${TZ// /}"
435EOT
436        fi
437        if ! diff -q ${ENGINECFG}{,-LAST} &>/dev/null; then
438                NEWFILES="$NEWFILES $ENGINECFG"
439        else
440                rm -f ${ENGINECFG}-LAST
441        fi
442
443        echoAndLog "${FUNCNAME}(): client files update success."
444}
445
446# Configurar HTTPS y exportar usuario y grupo del servicio Apache.
447function apacheConfiguration ()
448{
449        # Activar HTTPS (solo actualizando desde versiones anteriores a 1.0.2) y
450        #    activar módulo Rewrite (solo actualizaciones desde 1.0.x a 1.1.x).
451        if [ -e $APACHECFGDIR/sites-available/opengnsys.conf ]; then
452                echoAndLog "${FUNCNAME}(): Configuring Apache modules."
453                mv $APACHECFGDIR/sites-available/opengnsys.conf $APACHECFGDIR/sites-available/opengnsys
454                a2ensite default-ssl
455                a2enmod ssl
456                a2enmod rewrite
457                a2dissite opengnsys.conf
458                a2ensite opengnsys
459        elif [ -e $APACHECFGDIR/conf.modules.d ]; then
460                echoAndLog "${FUNCNAME}(): Configuring Apache modules."
461                sed -i '/rewrite/s/^#//' $APACHECFGDIR/*.conf
462        fi
463        # Definir ficheros .pkg como binarios para descargar paquetes macOS.
464        sed -i '/pkg/! s/octet-stream\(.*\)/octet-stream\1 pkg/' /etc/mime-types
465        # Actualizar configuración para acceso a API REST
466        #    (solo actualizaciones de 1.0.x a 1.1.x).
467        for config in $APACHECFGDIR/{,sites-available/}opengnsys.conf ]; do
468                if [ -e $config ] && ! grep -q "/rest" $config; then
469                        cat << EOT >> $config
470<Directory $INSTALL_TARGET/www/rest>
471        RewriteEngine On
472        RewriteBase /opengnsys/rest/
473        RewriteCond %{REQUEST_FILENAME} !-f
474        RewriteRule ^ index.php [QSA,L]
475</Directory>
476EOT
477                fi
478        done
479
480        # Reiniciar Apache.
481        $APACHESERV restart
482
483        # Variables de ejecución de Apache.
484        # - APACHE_RUN_USER
485        # - APACHE_RUN_GROUP
486        if [ -f $APACHECFGDIR/envvars ]; then
487                source $APACHECFGDIR/envvars
488        fi
489        APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"}
490        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
491}
492
493# Configurar servicio Rsync.
494function rsyncConfigure()
495{
496        local service
497
498        # Configurar acceso a Rsync.
499        if [ ! -f /etc/rsyncd.conf ]; then
500                echoAndLog "${FUNCNAME}(): Configuring Rsync service."
501                NEWFILES="$NEWFILES /etc/rsyncd.conf"
502                sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENTUSER/g" \
503                    $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > /etc/rsyncd.conf
504                # Habilitar Rsync.
505                if [ -f /etc/default/rsync ]; then
506                        perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
507                fi
508                if [ -f $INETDCFGDIR/rsync ]; then
509                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
510                else
511                        cat << EOT > $INETDCFGDIR/rsync
512service rsync
513{
514        disable = no
515        socket_type = stream
516        wait = no
517        user = root
518        server = $(which rsync)
519        server_args = --daemon
520        log_on_failure += USERID
521        flags = IPv6
522}
523EOT
524                fi
525                # Activar e iniciar Rsync.
526                service="rsync"  $ENABLESERVICE
527                service="xinetd"
528                $ENABLESERVICE; $STARTSERVICE
529        fi
530}
531
532# Copiar ficheros del OpenGnsys Web Console.
533function updateWebFiles()
534{
535        local ERRCODE COMPATDIR f
536
537        echoAndLog "${FUNCNAME}(): Updating web files..."
538
539        # Copiar los ficheros nuevos conservando el archivo de configuración de acceso.
540        backupFile $INSTALL_TARGET/www/controlacceso.php
541        mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
542        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
543        ERRCODE=$?
544        mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
545        unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
546        unzip -o $WORKDIR/opengnsys/admin/slim-2.6.1.zip -d $INSTALL_TARGET/www/rest
547        unzip -o $WORKDIR/opengnsys/admin/swagger-ui-2.2.5.zip -d $INSTALL_TARGET/www/rest
548        if [ $ERRCODE != 0 ]; then
549                errorAndLog "${FUNCNAME}(): Error updating web files."
550                exit 1
551        fi
552        restoreFile $INSTALL_TARGET/www/controlacceso.php
553
554        # Cambiar acceso a protocolo HTTPS.
555        if grep -q "http://" $INSTALL_TARGET/www/controlacceso.php 2>/dev/null; then
556                echoAndLog "${FUNCNAME}(): updating web access file"
557                perl -pi -e 's!http://!https://!g' $INSTALL_TARGET/www/controlacceso.php
558                NEWFILES="$NEWFILES $INSTALL_TARGET/www/controlacceso.php"
559        fi
560
561        # Compatibilidad con dispositivos móviles.
562        COMPATDIR="$INSTALL_TARGET/www/principal"
563        for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
564                sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
565        done
566        cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
567
568        # Cambiar permisos para ficheros especiales.
569        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
570        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/
571        # Fichero de logs del agente OGAgent.
572        touch $INSTALL_TARGET/log/ogagent.log
573        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/log/ogagent.log
574
575        echoAndLog "${FUNCNAME}(): Web files updated successfully."
576}
577
578# Copiar carpeta de Interface
579function updateInterfaceAdm()
580{
581        local errcode=0
582
583        # Crear carpeta y copiar Interface
584        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
585        mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
586        rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
587        errcoce=$?
588        mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm
589        if [ $errcode -ne 0 ]; then
590                echoAndLog "${FUNCNAME}(): error while updating admin interface"
591                exit 1
592        fi
593        chmod -R +x $INSTALL_TARGET/client/interfaceAdm
594        chown $OPENGNSYS_CLIENTUSER:$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
595        chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
596        echoAndLog "${FUNCNAME}(): Admin interface updated successfully."
597}
598
599# Crear documentación Doxygen para la consola web.
600function makeDoxygenFiles()
601{
602        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
603        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
604                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
605        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
606                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files."
607                return 1
608        fi
609        rm -fr "$INSTALL_TARGET/www/api"
610        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
611        rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf}
612        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api
613        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully."
614}
615
616
617# Crea la estructura base de la instalación de opengnsys
618function createDirs()
619{
620        # Crear estructura de directorios.
621        echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}"
622        local dir
623
624        mkdir -p ${INSTALL_TARGET}/{bin,doc,etc,lib,sbin,www}
625        mkdir -p ${INSTALL_TARGET}/{client,images}
626        mkdir -p ${INSTALL_TARGET}/log/clients
627        ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys
628        # Detectar directorio de instalación de TFTP.
629        if [ ! -L ${INSTALL_TARGET}/tftpboot ]; then
630                for dir in /var/lib/tftpboot /srv/tftp; do
631                        [ -d $dir ] && ln -fs $dir ${INSTALL_TARGET}/tftpboot
632                done
633        fi
634        mkdir -p ${INSTALL_TARGET}/tftpboot/menu.lst
635        if [ $? -ne 0 ]; then
636                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
637                return 1
638        fi
639
640        # Crear usuario ficticio.
641        if id -u $OPENGNSYS_CLIENTUSER &>/dev/null; then
642                echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENTUSER\" is already created"
643        else
644                echoAndLog "${FUNCNAME}(): creating OpenGnsys user"
645                useradd $OPENGNSYS_CLIENTUSER 2>/dev/null
646                if [ $? -ne 0 ]; then
647                        errorAndLog "${FUNCNAME}(): error creating OpenGnsys user"
648                        return 1
649                fi
650        fi
651
652        # Establecer los permisos básicos.
653        echoAndLog "${FUNCNAME}(): setting directory permissions"
654        chmod -R 775 $INSTALL_TARGET/{log/clients,images,tftpboot/menu.lst}
655        mkdir -p $INSTALL_TARGET/tftpboot/menu.lst/examples
656        ! [ -f $INSTALL_TARGET/tftpboot/menu.lst/templates/00unknown ] && mv $INSTALL_TARGET/tftpboot/menu.lst/templates/* $INSTALL_TARGET/tftpboot/menu.lst/examples
657        chown -R :$OPENGNSYS_CLIENTUSER $INSTALL_TARGET/{log/clients,images,tftpboot/menu.lst}
658        if [ $? -ne 0 ]; then
659                errorAndLog "${FUNCNAME}(): error while setting permissions"
660                return 1
661        fi
662
663        # Mover el fichero de registro al directorio de logs.
664        echoAndLog "${FUNCNAME}(): moving update log file"
665        mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
666        chmod 600 $LOG_FILE
667
668        echoAndLog "${FUNCNAME}(): directory paths created"
669        return 0
670}
671
672# Actualización incremental de la BD (versión actaul a actaul+1, hasta final-1 a final).
673function updateDatabase()
674{
675        local OLDVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
676        local NEWVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
677        local DBDIR="$WORKDIR/opengnsys/admin/Database"
678        local file FILES=""
679
680        echoAndLog "${FUNCNAME}(): looking for database updates"
681        pushd $DBDIR >/dev/null
682        # Bucle de actualización incremental desde versión actual a la final.
683        for file in $OPENGNSYS_DATABASE-*-*.sql; do
684                case "$file" in
685                        $OPENGNSYS_DATABASE-$OLDVERSION-$NEWVERSION.sql)
686                                # Actualización única de versión inicial y final.
687                                FILES="$FILES $file"
688                                break
689                                ;;
690                        $OPENGNSYS_DATABASE-*-postinst.sql)
691                                # Ignorar fichero específico de post-instalación.
692                                ;;
693                        $OPENGNSYS_DATABASE-$OLDVERSION-*.sql)
694                                # Actualización de versión n a n+1.
695                                FILES="$FILES $file"
696                                OLDVERSION="$(echo $file | cut -f3 -d-)"
697                                ;;
698                        $OPENGNSYS_DATABASE-*-$NEWVERSION.sql)
699                                # Última actualización de versión final-1 a final.
700                                if [ -n "$FILES" ]; then
701                                        FILES="$FILES $file"
702                                        break
703                                fi
704                                ;;
705                esac
706        done
707        # Aplicar posible actualización propia para la versión final.
708        file=$OPENGNSYS_DATABASE-$NEWVERSION.sql
709        if [ -n "$FILES" -o "$OLDVERSION" = "$NEWVERSION" -a -r $file ]; then
710                FILES="$FILES $file"
711        fi
712
713        popd >/dev/null
714        if [ -n "$FILES" ]; then
715                for file in $FILES; do
716                        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $DBDIR/$file
717                done
718                echoAndLog "${FUNCNAME}(): database is update"
719        else
720                echoAndLog "${FUNCNAME}(): database unchanged"
721        fi
722}
723
724# Copia ficheros de configuración y ejecutables genéricos del servidor.
725function updateServerFiles()
726{
727        # No copiar ficheros del antiguo cliente Initrd
728        local SOURCES=( repoman/bin \
729                        server/bin \
730                        server/lib \
731                        admin/Sources/Services/ogAdmServerAux \
732                        admin/Sources/Services/ogAdmRepoAux \
733                        server/tftpboot \
734                        installer/opengnsys_uninstall.sh \
735                        installer/opengnsys_export.sh \
736                        installer/opengnsys_import.sh \
737                        doc )
738        local TARGETS=( bin \
739                        bin \
740                        lib \
741                        sbin/ogAdmServerAux \
742                        sbin/ogAdmRepoAux \
743                        tftpboot \
744                        lib/opengnsys_uninstall.sh \
745                        lib/opengnsys_export.sh \
746                        lib/opengnsys_import.sh \
747                        doc )
748
749        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
750                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
751                exit 1
752        fi
753
754        echoAndLog "${FUNCNAME}(): updating files in server directories"
755        pushd $WORKDIR/opengnsys >/dev/null
756        local i
757        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
758                if [ -d "$INSTALL_TARGET/${TARGETS[i]}" ]; then
759                        rsync --exclude .svn -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}"))
760                else
761                        rsync -irplt "${SOURCES[i]}" $(readlink -m "$INSTALL_TARGET/${TARGETS[i]}")
762                fi
763        done
764        popd >/dev/null
765        NEWFILES=""             # Ficheros de configuración que han cambiado de formato.
766        if grep -q 'pxelinux.0' /etc/dhcp*/dhcpd*.conf; then
767                echoAndLog "${FUNCNAME}(): updating DHCP files"
768                perl -pi -e 's/pxelinux.0/grldr/' /etc/dhcp*/dhcpd*.conf
769                $DHCPSERV restart
770                NEWFILES="/etc/dhcp*/dhcpd*.conf"
771        fi
772        if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then
773                echoAndLog "${FUNCNAME}(): updating new init file"
774                backupFile /etc/init.d/opengnsys
775                cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
776                NEWFILES="$NEWFILES /etc/init.d/opengnsys"
777        fi
778        if egrep -q "(UrlMsg=.*msgbrowser.php)|(UrlMenu=http://)" $INSTALL_TARGET/client/etc/ogAdmClient.cfg 2>/dev/null; then
779                echoAndLog "${FUNCNAME}(): updating new client config file"
780                backupFile $INSTALL_TARGET/client/etc/ogAdmClient.cfg
781                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
782                NEWFILES="$NEWFILES $INSTALL_TARGET/client/etc/ogAdmClient.cfg"
783        fi
784
785        echoAndLog "${FUNCNAME}(): updating cron files"
786        [ ! -f /etc/cron.d/opengnsys ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
787        [ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
788        [ ! -f /etc/cron.d/torrenttracker ] && echo "5 * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
789        [ ! -f /etc/cron.d/imagedelete ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
790        echoAndLog "${FUNCNAME}(): server files updated successfully."
791}
792
793####################################################################
794### Funciones de compilación de código fuente de servicios
795####################################################################
796
797# Mueve el fichero del nuevo servicio si es distinto al del directorio destino.
798function moveNewService()
799{
800        local service
801
802        # Recibe 2 parámetros: fichero origen y directorio destino.
803        [ $# == 2 ] || return 1
804        [ -f  $1 -a -d $2 ] || return 1
805
806        # Comparar los ficheros.
807        if ! diff -q $1 $2/$(basename $1) &>/dev/null; then
808                # Parar los servicios si fuese necesario.
809                [ -z "$NEWSERVICES" ] && service="opengnsys" $STOPSERVICE
810                # Nuevo servicio.
811                NEWSERVICES="$NEWSERVICES $(basename $1)"
812                # Mover el nuevo fichero de servicio
813                mv $1 $2
814        fi
815}
816
817
818# Recompilar y actualiza los serivicios y clientes.
819function compileServices()
820{
821        local hayErrores=0
822
823        # Compilar OpenGnsys Server
824        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Admin Server"
825        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
826        make && moveNewService ogAdmServer $INSTALL_TARGET/sbin
827        if [ $? -ne 0 ]; then
828                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server"
829                hayErrores=1
830        fi
831        popd
832        # Compilar OpenGnsys Repository Manager
833        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Repository Manager"
834        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo
835        make && moveNewService ogAdmRepo $INSTALL_TARGET/sbin
836        if [ $? -ne 0 ]; then
837                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Repository Manager"
838                hayErrores=1
839        fi
840        popd
841        # Actualizar o insertar clave de acceso REST en el fichero de configuración del repositorio.
842        grep -q '^ApiToken=' $INSTALL_TARGET/etc/ogAdmRepo.cfg && \
843                sed -i "s/^ApiToken=.*$/ApiToken=$REPOKEY/" $INSTALL_TARGET/etc/ogAdmRepo.cfg || \
844                sed -i "$ a\ApiToken=$REPOKEY/" $INSTALL_TARGET/etc/ogAdmRepo.cfg
845        # Compilar OpenGnsys Agent
846        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Agent"
847        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
848        make && moveNewService ogAdmAgent $INSTALL_TARGET/sbin
849        if [ $? -ne 0 ]; then
850                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Agent"
851                hayErrores=1
852        fi
853        popd
854
855        # Compilar OpenGnsys Client
856        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Client"
857        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
858        make && mv ogAdmClient $INSTALL_TARGET/client/bin
859        if [ $? -ne 0 ]; then
860                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Client"
861                hayErrores=1
862        fi
863        popd
864
865        return $hayErrores
866}
867
868
869####################################################################
870### Funciones instalacion cliente OpenGnsys
871####################################################################
872
873# Actualizar cliente OpenGnsys
874function updateClient()
875{
876        PATH=$PATH:$INSTALL_TARGET/bin
877        local DOWNLOADURL=$(oglivecli config download-url)
878        #local FILENAME=ogLive-wily-4.2.0-35-generic-r4919.iso          # 1.1.0-rc3
879        local FILENAME=ogLive-xenial-4.4.0-34-generic-r4999.iso         # 1.1.0-rc4
880        local SOURCEFILE=$DOWNLOADURL/$FILENAME
881        local TARGETFILE=$(oglivecli config download-dir)/$FILENAME
882        local SOURCELENGTH
883        local TARGETLENGTH
884        local OGINITRD
885        local SAMBAPASS
886        local KERNELVERSION
887
888        # Comprobar si debe convertirse el antiguo cliente al nuevo formato ogLive.
889        if oglivecli check | grep -q "oglivecli convert"; then
890                echoAndLog "${FUNCNAME}(): Converting OpenGnsys Client to default ogLive"
891                oglivecli convert
892        fi
893        # Comprobar si debe actualizarse el cliente.
894        SOURCELENGTH=$(LANG=C wget --spider $SOURCEFILE 2>&1 | awk '/Length:/ {print $2}')
895        TARGETLENGTH=$(stat -c "%s" $TARGETFILE 2>/dev/null)
896        [ -z $TARGETLENGTH ] && TARGETLENGTH=0
897        if [ "$SOURCELENGTH" != "$TARGETLENGTH" ]; then
898                echoAndLog "${FUNCNAME}(): Downloading ogLive"
899                oglivecli download $FILENAME
900                if [ ! -s $TARGETFILE ]; then
901                        errorAndLog "${FUNCNAME}(): Error loading OpenGnsys Client"
902                        return 1
903                fi
904                # Actaulizar la imagen ISO del ogclient.
905                echoAndLog "${FUNCNAME}(): Updatting ogLive"
906                oglivecli install $FILENAME
907               
908                # Obtiene versión del Kernel del cliente (con 2 decimales).
909                KERNELVERSION=$(jq -r ".oglive[.default].kernel" |
910                                awk -F. '{printf("%d",$1); $1=""; printf(".%02d",$0)}')
911                # Actaulizar la base de datos adaptada al Kernel del cliente.
912                OPENGNSYS_DBUPDATEFILE="$WORKDIR/opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-postinst.sql"
913                if [ -f $OPENGNSYS_DBUPDATEFILE ]; then
914                        perl -pi -e "s/KERNELVERSION/$KERNELVERSION/g" $OPENGNSYS_DBUPDATEFILE
915                        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $OPENGNSYS_DBUPDATEFILE
916                fi
917                CLIENTUPDATED=${FILENAME%.*}
918
919                echoAndLog "${FUNCNAME}(): Client update successfully"
920        else
921                # Si no existe, crear el fichero de claves de Rsync.
922                if [ ! -f /etc/rsyncd.secrets ]; then
923                        echoAndLog "${FUNCNAME}(): Restoring client access key"
924                        OGINITRD=$(oglivecli config install-dir)/$(jq -r ".oglive[.default].directory")/oginitrd.img
925                        SAMBAPASS=$(gzip -dc $OGINITRD | \
926                                    cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
927                                    grep "^[    ].*OPTIONS=" | \
928                                    sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
929                        echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | setsmbpass
930                else
931                        echoAndLog "${FUNCNAME}(): Client is already updated"
932                fi
933                # Versión del ogLive instalado.
934                echo "${FILENAME%.*}" > $INSTALL_TARGET/doc/veroglive.txt
935        fi
936}
937
938# Comprobar permisos y ficheros.
939function checkFiles()
940{
941        # Comprobar permisos adecuados.
942        if [ -x $INSTALL_TARGET/bin/checkperms ]; then
943                echoAndLog "${FUNCNAME}(): Checking permissions."
944                OPENGNSYS_DIR="$INSTALL_TARGET" OPENGNSYS_USER="$OPENGNSYS_CLIENTUSER" APACHE_USER="$APACHE_RUN_USER" APACHE_GROUP="$APACHE_RUN_GROUP" $INSTALL_TARGET/bin/checkperms
945        fi
946
947        # Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes
948        if [ -f /tmp/dstate ]; then
949                echoAndLog "${FUNCNAME}(): Delete unused files."
950                rm -f /tmp/dstate
951        fi
952}
953
954# Resumen de actualización.
955function updateSummary()
956{
957        # Actualizar fichero de versión y revisión.
958        local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
959        local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
960
961        [ -f $VERSIONFILE ] || echo "OpenGnsys" >$VERSIONFILE
962        perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
963
964        echo
965        echoAndLog "OpenGnsys Update Summary"
966        echo       "========================"
967        echoAndLog "Project version:                  $(cat $VERSIONFILE)"
968        echoAndLog "Update log file:                  $LOG_FILE"
969        if [ -n "$NEWFILES" ]; then
970                echoAndLog "Check new config files:           $(echo $NEWFILES)"
971        fi
972        if [ -n "$NEWSERVICES" ]; then
973                echoAndLog "New compiled services:            $(echo $NEWSERVICES)"
974                # Indicar si se debe reiniciar servicios manualmente o usando el Cron.
975                [ -f /etc/default/opengnsys ] && source /etc/default/opengnsys
976                if [ "$RUN_CRONJOB" == "no" ]; then
977                        echoAndLog "        WARNING: you must restart OpenGnsys services manually."
978                else
979                        echoAndLog "        New OpenGnsys services will be restarted by the cronjob."
980                fi
981        fi
982        echoAndLog "Warnings:"
983        echoAndLog " - You must to clear web browser cache before loading OpenGnSys page."
984        if [ -n "$CLIENTUPDATED" ]; then
985                echoAndLog " - ogLive Client is updated to: $CLIENTUPDATED"
986        fi
987        echo
988}
989
990
991
992#####################################################################
993####### Proceso de actualización de OpenGnsys
994#####################################################################
995
996
997echoAndLog "OpenGnsys update begins at $(date)"
998
999pushd $WORKDIR
1000
1001# Comprobar si hay conexión y detectar parámetros de red por defecto.
1002checkNetworkConnection
1003if [ $? -ne 0 ]; then
1004        errorAndLog "Error connecting to server. Causes:"
1005        errorAndLog " - Network is unreachable, review devices parameters."
1006        errorAndLog " - You are inside a private network, configure the proxy service."
1007        errorAndLog " - Server is temporally down, try agian later."
1008        exit 1
1009fi
1010getNetworkSettings
1011
1012# Comprobar auto-actualización del programa.
1013if [ "$PROGRAMDIR" != "$INSTALL_TARGET/bin" ]; then
1014        checkAutoUpdate
1015        if [ $? -ne 0 ]; then
1016                echoAndLog "OpenGnsys updater has been overwritten."
1017                echoAndLog "Please, re-execute this script."
1018                exit
1019        fi
1020fi
1021
1022# Detectar datos de auto-configuración del instalador.
1023autoConfigure
1024
1025# Instalar dependencias.
1026installDependencies ${DEPENDENCIES[*]}
1027if [ $? -ne 0 ]; then
1028        errorAndLog "Error: you may install all needed dependencies."
1029        exit 1
1030fi
1031
1032# Arbol de directorios de OpenGnsys.
1033createDirs ${INSTALL_TARGET}
1034if [ $? -ne 0 ]; then
1035        errorAndLog "Error while creating directory paths!"
1036        exit 1
1037fi
1038
1039# Si es necesario, descarga el repositorio de código en directorio temporal
1040if [ $USESVN -eq 1 ]; then
1041        svnExportCode $SVN_URL
1042        if [ $? -ne 0 ]; then
1043                errorAndLog "Error while getting code from svn"
1044                exit 1
1045        fi
1046else
1047        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
1048fi
1049
1050# Actualizar la BD.
1051updateDatabase
1052
1053# Actualizar ficheros complementarios del servidor
1054updateServerFiles
1055if [ $? -ne 0 ]; then
1056        errorAndLog "Error updating OpenGnsys Server files"
1057        exit 1
1058fi
1059
1060# Configurar Rsync.
1061rsyncConfigure
1062
1063# Actualizar ficheros del cliente
1064updateClientFiles
1065updateInterfaceAdm
1066
1067# Actualizar páqinas web
1068apacheConfiguration
1069updateWebFiles
1070if [ $? -ne 0 ]; then
1071        errorAndLog "Error updating OpenGnsys Web Admin files"
1072        exit 1
1073fi
1074# Generar páginas Doxygen para instalar en el web
1075makeDoxygenFiles
1076
1077# Recompilar y actualizar los servicios del sistema
1078compileServices
1079
1080# Actaulizar ficheros auxiliares del cliente
1081updateClient
1082if [ $? -ne 0 ]; then
1083        errorAndLog "Error updating clients"
1084        exit 1
1085fi
1086
1087# Comprobar permisos y ficheros.
1088checkFiles
1089
1090# Mostrar resumen de actualización.
1091updateSummary
1092
1093#rm -rf $WORKDIR
1094echoAndLog "OpenGnsys update finished at $(date)"
1095
1096popd
1097
Note: See TracBrowser for help on using the repository browser.