source: installer/opengnsys_update.sh @ bcfd3ad

opengnsys-1.0
Last change on this file since bcfd3ad was bcfd3ad, checked in by ramon <ramongomez@…>, 14 years ago

Congelado OpenGnSys 1.0 en trunk/opengnsys-1.0 (modificar #413).

git-svn-id: https://opengnsys.es/svn/tags/opengnsys-1.0@2049 a21b9725-9963-47de-94b9-378ad31fedc9

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