source: installer/opengnsys_update.sh @ 8c22cff

918-git-images-111dconfigure-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-instalacion
Last change on this file since 8c22cff was c3e4ff1, checked in by Ramón M. Gómez <ramongomez@…>, 5 years ago

#972: Remove cron job definition from the default file; then updater checks if service code has changed to restart it automatically.

  • Property mode set to 100755
File size: 44.9 KB
RevLine 
[a0867b37]1#!/bin/bash
2#/**
3#@file    opengnsys_update.sh
[5f21d34]4#@brief   Script actualización de OpenGnsys
[a0867b37]5#@version 0.9 - basado en opengnsys_installer.sh
6#@author  Ramón Gómez - ETSII Univ. Sevilla
7#@date    2010/01/27
[c1e00e4]8#@version 1.0 - adaptación a OpenGnSys 1.0
9#@author  Ramón Gómez - ETSII Univ. Sevilla
10#@date    2011/03/02
[64dd765]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
[739fb00]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
[1175096]17#@version 1.0.3 - Compatibilidad con Debian y auto configuración de acceso a BD.
[7bb72f7]18#@author  Ramón Gómez - ETSII Univ. Sevilla
[1175096]19#@date    2012/03/12
[db9e706]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
[dde65c7]23#@version 1.0.5 - Actualizar BD en la misma versión, compatibilidad con Fedora (systemd) y configuración de Rsync.
[0b8a1f1]24#@author  Ramón Gómez - ETSII Univ. Sevilla
[dde65c7]25#@date    2014/04/03
[1a2fa9d8]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
[a3855dc]29#@version 1.1.0 - Instalación de API REST y configuración de zona horaria.
[900be258]30#@author  Ramón Gómez - ETSII Univ. Sevilla
[a3855dc]31#@date    2015/11/09
[fd45e9a]32#@version 1.1.1a - Elegir versión a actualizar.
33#@author  Ramón Gómez - ETSII Univ. Sevilla
34#@date    2019/12/13
[a0867b37]35#*/
36
37
[1175096]38####  AVISO: NO EDITAR variables de configuración.
39####  WARNING: DO NOT EDIT configuration variables.
40INSTALL_TARGET=/opt/opengnsys           # Directorio de instalación
[ec045b1]41PATH=$PATH:$INSTALL_TARGET/bin
[295b4ab]42OPENGNSYS_CLIENTUSER="opengnsys"        # Usuario Samba
43
44
[a0867b37]45# Sólo ejecutable por usuario root
[6ef01d9]46if [ "$(whoami)" != 'root' ]; then
[a0867b37]47        echo "ERROR: this program must run under root privileges!!"
48        exit 1
49fi
[5f21d34]50# Error si OpenGnsys no está instalado (no existe el directorio del proyecto)
[4e51cb0]51if [ ! -d $INSTALL_TARGET ]; then
[5f21d34]52        echo "ERROR: OpenGnsys is not installed, cannot update!!"
[4e51cb0]53        exit 1
54fi
[1175096]55# Cargar configuración de acceso a la base de datos.
56if [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then
57        source $INSTALL_TARGET/etc/ogAdmServer.cfg
58elif [ -r $INSTALL_TARGET/etc/ogAdmAgent.cfg ]; then
59        source $INSTALL_TARGET/etc/ogAdmAgent.cfg
60fi
[42a0e41]61OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"}            # Base de datos
[1175096]62OPENGNSYS_DBUSER=${OPENGNSYS_DBUSER:-"$USUARIO"}                # Usuario de acceso
63OPENGNSYS_DBPASSWORD=${OPENGNSYS_DBPASSWORD:-"$PASSWORD"}       # Clave del usuario
64if [ -z "$OPENGNSYS_DATABASE" -o -z "$OPENGNSYS_DBUSER" -o -z "$OPENGNSYS_DBPASSWORD" ]; then
65        echo "ERROR: set OPENGNSYS_DATABASE, OPENGNSYS_DBUSER and OPENGNSYS_DBPASSWORD"
66        echo "       variables, and run this script again."
[0304465]67        exit 1
[1175096]68fi
[a0867b37]69
[884b6ce]70# Comprobar si se ha descargado el paquete comprimido (REMOTE=0) o sólo el instalador (REMOTE=1).
[a0867b37]71PROGRAMDIR=$(readlink -e $(dirname "$0"))
[64dd765]72PROGRAMNAME=$(basename "$0")
[a0081b7]73OPENGNSYS_SERVER="opengnsys.es"
[a0867b37]74if [ -d "$PROGRAMDIR/../installer" ]; then
[884b6ce]75        REMOTE=0
[a0867b37]76else
[884b6ce]77        REMOTE=1
[a0867b37]78fi
79
80WORKDIR=/tmp/opengnsys_update
81mkdir -p $WORKDIR
82
[42a0e41]83# Registro de incidencias.
84OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log
[57f7e9c]85LOG_FILE=/tmp/$(basename $OGLOGFILE)
[a0867b37]86
87
88
89#####################################################################
90####### Algunas funciones útiles de propósito general:
91#####################################################################
[295b4ab]92
[db9e706]93# Generar variables de configuración del actualizador
94# Variables globales:
[2e38f60]95# - OSDISTRIB - distribución Linux
[db9e706]96# - DEPENDENCIES - array de dependencias que deben estar instaladas
97# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKG - comandos para gestión de paquetes
[3b0436d]98# - APACHECFGDIR, APACHESERV, PHPFPMSERV, DHCPSERV, MYSQLSERV, MYSQLCFGDIR, INETDCFGDIR - configuración y servicios
[ec536c6]99
[db9e706]100function autoConfigure()
101{
[a37e5fc4]102        local service
[2e38f60]103
[a37e5fc4]104        # Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
105        if [ -f /etc/os-release ]; then
106                source /etc/os-release
107                OSDISTRIB="$ID"
108                OSVERSION="$VERSION_ID"
109        else
110                OSDISTRIB=$(lsb_release -is 2>/dev/null)
111                OSVERSION=$(lsb_release -rs 2>/dev/null)
112        fi
113        # Convertir distribución a minúsculas y obtener solo el 1er número de versión.
114        OSDISTRIB="${OSDISTRIB,,}"
115        OSVERSION="${OSVERSION%%.*}"
116
117        # Configuración según la distribución de Linux.
118        if [ -f /etc/debian_version ]; then
[884b6ce]119                # Distribución basada en paquetes Deb.
[c089f29]120                DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed php-fpm gawk libdbi-dev libdbi1 libdbd-mysql)
[42c7e5f]121                # Paquete correcto para realpath.
122                [ -z "$(apt-cache pkgnames realpath)" ] && DEPENDENCIES=( ${DEPENDENCIES[@]//realpath/coreutils} )
[0304465]123                UPDATEPKGLIST="add-apt-repository -y ppa:ondrej/php; apt-get update"
[a37e5fc4]124                INSTALLPKGS="apt-get -y install"
125                DELETEPKGS="apt-get -y purge"
[db9e706]126                CHECKPKG="dpkg -s \$package 2>/dev/null | grep -q \"Status: install ok\""
[4b96166]127                if which service &>/dev/null; then
128                        STARTSERVICE="eval service \$service restart"
[dde65c7]129                        STOPSERVICE="eval service \$service stop"
[a37e5fc4]130                        SERVICESTATUS="eval service \$service status"
[4b96166]131                else
132                        STARTSERVICE="eval /etc/init.d/\$service restart"
[dde65c7]133                        STOPSERVICE="eval /etc/init.d/\$service stop"
[a37e5fc4]134                        SERVICESTATUS="eval /etc/init.d/\$service status"
[4b96166]135                fi
136                ENABLESERVICE="eval update-rc.d \$service defaults"
[9215580]137                APACHEENABLEMODS="ssl rewrite proxy_fcgi fastcgi actions alias"
138                APACHEDISABLEMODS="php"
[2e38f60]139                APACHEUSER="www-data"
140                APACHEGROUP="www-data"
[3b0436d]141                MYSQLCFGDIR=/etc/mysql/mysql.conf.d
142                MYSQLSERV="mysql"
[ec536c6]143                PHPFPMSERV="php-fpm"
[65baf16]144                INETDCFGDIR=/etc/xinetd.d
[a37e5fc4]145        elif [ -f /etc/redhat-release ]; then
[884b6ce]146                # Distribución basada en paquetes rpm.
[c089f29]147                DEPENDENCIES=( curl rsync btrfs-progs procps-ng arp-scan gettext moreutils jq net-tools udpcast libev-devel jansson-devel openssl-devel shim-x64 grub2-efi-x64 grub2-efi-x64-modules gawk libdbi-devel libdbi libdbi-dbd-mysql)
[ec536c6]148                # Repositorios para PHP 7 en CentOS.
149                [ "$OSDISTRIB" == "centos" ] && UPDATEPKGLIST="yum update -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$OSVERSION.noarch.rpm http://rpms.remirepo.net/enterprise/remi-release-$OSVERSION.rpm"
[db9e706]150                INSTALLPKGS="yum install -y"
[a37e5fc4]151                DELETEPKGS="yum remove -y"
[db9e706]152                CHECKPKG="rpm -q --quiet \$package"
[4b96166]153                if which systemctl &>/dev/null; then
[a37e5fc4]154                        STARTSERVICE="eval systemctl restart \$service.service"
[dde65c7]155                        STOPSERVICE="eval systemctl stop \$service.service"
[4b96166]156                        ENABLESERVICE="eval systemctl enable \$service.service"
[a37e5fc4]157                        SERVICESTATUS="eval systemctl status \$service.service"
[4b96166]158                else
[a37e5fc4]159                        STARTSERVICE="eval service \$service restart"
[dde65c7]160                        STOPSERVICE="eval service \$service stop"
[4b96166]161                        ENABLESERVICE="eval chkconfig \$service on"
[a37e5fc4]162                        SERVICESTATUS="eval service \$service status"
[4b96166]163                fi
[2a5c1a4]164                APACHEUSER="apache"
165                APACHEGROUP="apache"
[3b0436d]166                MYSQLCFGDIR=/etc/my.cnf.d
167                MYSQLSERV="mariadb"
[ec536c6]168                PHPFPMSERV="php-fpm"
[65baf16]169                INETDCFGDIR=/etc/xinetd.d
[a37e5fc4]170        else
171                # Otras distribuciones.
172                :
173        fi
174        for service in apache2 httpd; do
[5050850]175                [ -d "/etc/$service" ] && APACHECFGDIR="/etc/$service"
[a37e5fc4]176                if $SERVICESTATUS &>/dev/null; then APACHESERV="$service"; fi
177        done
178        for service in dhcpd dhcpd3-server isc-dhcp-server; do
179                if $SERVICESTATUS &>/dev/null; then DHCPSERV="$service"; fi
180        done
[db9e706]181}
182
183
[fd45e9a]184# Choose an available version to update.
185function chooseVersion()
186{
187    local RELEASES DOWNLOADS INSTVERSION INSTRELEASE
188
189    # Development branch.
190    BRANCH="master"
191    API_URL="https://api.github.com/repos/opengnsys/OpenGnsys/branches/$BRANCH"
[66432fb]192
193    RELEASES=( )
194    DOWNLOADS=( )
[fd45e9a]195    # If updating from a local or very old version, use the default data.
196    if [ $REMOTE -eq 1 ] && which jq &>/dev/null && [ -f $INSTALL_TARGET/doc/VERSION.json ]; then
197        # Installed release.
198        read -pe INSTVERSION INSTRELEASE <<< $(jq -r '.version+" "+.release' $INSTALL_TARGET/doc/VERSION.json)
199        # Fetch tags (releases) data from GitHub.
200        while read -pe TAG URL; do
201            if [[ $TAG =~ ^opengnsys- ]]; then
202                [ "${TAG#opengnsys-}" \< "${INSTVERSION%pre}" ] && break
203                RELEASES+=( "${TAG}" )
204                DOWNLOADS+=( "$URL" )
205                #RELDATE=$(curl -s "$URL" | jq -r '.commit.committer.date | split("-") | join("")[:8]')
206            fi
207        done <<< $(curl -s "$API_URL/../../tags" | jq -r '.[] | .name+" "+.commit.url')
[66432fb]208        # Add development (master) branch.
209        RELEASES+=( "$BRANCH" )
210        DOWNLOADS+=( "$API_URL" )
[fd45e9a]211        # Show selection menu, if needed.
[ecdb637]212        if [ ${#RELEASES[@]} -gt 1 ]; then
[fd45e9a]213            echo "Installed version: $INSTVERSION $INSTRELEASE"
[66432fb]214            echo "Versions available for update (\"$BRANCH\" is the latest development branch):"
[fd45e9a]215            PS3="Enter a number: "
216            select opt in "${RELEASES[@]}"; do
217                if [ -n "$opt" ]; then
218                    BRANCH="$opt"
219                    API_URL="${DOWNLOADS[REPLY-1]}"
220                    break
221                fi
222            done
223        fi
224    fi
225    # Download URLs.
226    CODE_URL="https://codeload.github.com/opengnsys/OpenGnsys/zip/$BRANCH"
227    RAW_URL="https://raw.githubusercontent.com/opengnsys/OpenGnsys/$BRANCH"
228}
229
230
[64dd765]231# Comprobar auto-actualización.
232function checkAutoUpdate()
233{
234        local update=0
235
236        # Actaulizar el script si ha cambiado o no existe el original.
[884b6ce]237        if [ $REMOTE -eq 1 ]; then
238                curl -s $RAW_URL/installer/$PROGRAMNAME -o $PROGRAMNAME
[a3a1ff2]239                chmod +x $PROGRAMNAME
[d372e6e]240                if ! diff -q $PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
[64dd765]241                        mv $PROGRAMNAME $INSTALL_TARGET/lib
242                        update=1
243                else
244                        rm -f $PROGRAMNAME
245                fi
246        else
[d372e6e]247                if ! diff -q $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
[64dd765]248                        cp -a $PROGRAMDIR/$PROGRAMNAME $INSTALL_TARGET/lib
249                        update=1
250                fi
251        fi
252
253        return $update
254}
255
256
[a0867b37]257function getDateTime()
258{
[5eb61a6]259        date "+%Y%m%d-%H%M%S"
[a0867b37]260}
261
262# Escribe a fichero y muestra por pantalla
263function echoAndLog()
264{
[a3a1ff2]265        echo "$1"
[6ef01d9]266        DATETIME=`getDateTime`
267        echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE
[a0867b37]268}
269
270function errorAndLog()
271{
[5eb61a6]272        echo "ERROR: $1"
273        DATETIME=`getDateTime`
[6ef01d9]274        echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
[a0867b37]275}
276
[cd86637]277# Escribe a fichero y muestra mensaje de aviso
278function warningAndLog()
279{
280        local DATETIME=`getDateTime`
281        echo "Warning: $1"
282        echo "$DATETIME;$SSH_CLIENT;Warning: $1" >> $LOG_FILE
283}
284
[a0867b37]285
286#####################################################################
287####### Funciones de copia de seguridad y restauración de ficheros
288#####################################################################
289
290# Hace un backup del fichero pasado por parámetro
291# deja un -last y uno para el día
292function backupFile()
293{
294        if [ $# -ne 1 ]; then
295                errorAndLog "${FUNCNAME}(): invalid number of parameters"
296                exit 1
297        fi
298
299        local fichero=$1
300        local fecha=`date +%Y%m%d`
301
302        if [ ! -f $fichero ]; then
[cd86637]303                warningAndLog "${FUNCNAME}(): file $fichero doesn't exists"
[a0867b37]304                return 1
305        fi
306
[ebbbfc01]307        echoAndLog "${FUNCNAME}(): Making $fichero back-up"
[a0867b37]308
309        # realiza una copia de la última configuración como last
[6ef01d9]310        cp -a $fichero "${fichero}-LAST"
[a0867b37]311
312        # si para el día no hay backup lo hace, sino no
313        if [ ! -f "${fichero}-${fecha}" ]; then
[6ef01d9]314                cp -a $fichero "${fichero}-${fecha}"
[a0867b37]315        fi
316}
317
318# Restaura un fichero desde su copia de seguridad
319function restoreFile()
320{
321        if [ $# -ne 1 ]; then
322                errorAndLog "${FUNCNAME}(): invalid number of parameters"
323                exit 1
324        fi
325
326        local fichero=$1
327
[ebbbfc01]328        echoAndLog "${FUNCNAME}(): restoring file $fichero"
[a0867b37]329        if [ -f "${fichero}-LAST" ]; then
[6ef01d9]330                cp -a "$fichero-LAST" "$fichero"
[a0867b37]331        fi
332}
333
334
335#####################################################################
[295b4ab]336####### Funciones de acceso a base de datos
337#####################################################################
338
339# Actualizar la base datos
340function importSqlFile()
341{
342        if [ $# -ne 4 ]; then
343                errorAndLog "${FNCNAME}(): invalid number of parameters"
344                exit 1
345        fi
346
347        local dbuser="$1"
348        local dbpassword="$2"
349        local database="$3"
350        local sqlfile="$4"
351        local tmpfile=$(mktemp)
[632bd45]352        local mycnf=/tmp/.my.cnf.$$
[295b4ab]353        local status
354
355        if [ ! -r $sqlfile ]; then
356                errorAndLog "${FUNCNAME}(): Unable to read $sqlfile!!"
357                return 1
358        fi
359
360        echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..."
361        chmod 600 $tmpfile
362        sed -e "s/SERVERIP/$SERVERIP/g" -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
[dde2db1]363            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" $sqlfile > $tmpfile
[632bd45]364        # Componer fichero con credenciales de conexión. 
365        touch $mycnf
366        chmod 600 $mycnf
367        cat << EOT > $mycnf
[c073224]368[client]
[09bf701]369user=$dbuser
370password=$dbpassword
[632bd45]371EOT
[785085b]372        # Antes de actualizar, reasignar valores para campos no nulos con nulo por defecto.
373        mysql --defaults-extra-file=$MYCNF -D "$database" -e \
374                "$(mysql --defaults-extra-file=$MYCNF -Nse "
375SELECT CASE WHEN DATA_TYPE LIKE '%int' THEN
376                 CONCAT_WS(' ', 'ALTER TABLE', TABLE_NAME, 'ALTER', COLUMN_NAME, 'SET DEFAULT 0;')
377            WHEN DATA_TYPE LIKE '%char' THEN
378                 CONCAT_WS(' ', 'ALTER TABLE', TABLE_NAME, 'ALTER', COLUMN_NAME, 'SET DEFAULT \'\';')
379            WHEN DATA_TYPE = 'text' THEN
380                 CONCAT_WS(' ', 'ALTER TABLE', TABLE_NAME, 'MODIFY', COLUMN_NAME, 'TEXT NOT NULL;')
381            ELSE ''
382       END
383  FROM information_schema.COLUMNS
384 WHERE TABLE_SCHEMA='$database'
385   AND IS_NULLABLE='NO'
386   AND COLUMN_DEFAULT IS NULL
387   AND COLUMN_KEY='';")"
[632bd45]388        # Ejecutar actualización y borrar fichero de credenciales.
[09bf701]389        mysql --defaults-extra-file=$mycnf --default-character-set=utf8 -D "$database" < $tmpfile
[295b4ab]390        status=$?
[632bd45]391        rm -f $mycnf $tmpfile
[295b4ab]392        if [ $status -ne 0 ]; then
393                errorAndLog "${FUNCNAME}(): error importing $sqlfile in database $database"
394                return 1
395        fi
396        echoAndLog "${FUNCNAME}(): file imported to database $database"
397        return 0
398}
399
[21372e8]400# Comprobar configuración de MySQL y recomendar cambios necesarios.
401function checkMysqlConfig()
402{
[0304465]403        echoAndLog "${FUNCNAME}(): checking MySQL configuration"
[3b0436d]404
405        cp -a $WORKDIR/opengnsys/server/etc/mysqld-og.cnf $MYSQLCFGDIR 2>/dev/null
406        service=$MYSQLSERV; $STARTSERVICE
[21372e8]407
408        echoAndLog "${FUNCNAME}(): MySQL configuration has checked"
409        return 0
410}
[295b4ab]411
412#####################################################################
[a0867b37]413####### Funciones de instalación de paquetes
414#####################################################################
415
416# Instalar las deependencias necesarias para el actualizador.
[64dd765]417function installDependencies()
[a0867b37]418{
[db9e706]419        local package
420
[a37e5fc4]421        # Comprobar si hay que actualizar PHP 5 a PHP 7.
422        eval $UPDATEPKGLIST
423        if [ -f /etc/debian_version ]; then
424                # Basado en paquetes Deb.
425                PHP7VERSION=$(apt-cache pkgnames php7 2>/dev/null | sort | head -1)
[ec536c6]426                PHPFPMSERV="${PHP7VERSION}-fpm"
427                PHP5PKGS=( $(dpkg -l | awk '$2~/^php5/ {print $2}') )
[a37e5fc4]428                if [ -n "$PHP5PKGS" ]; then
429                        $DELETEPKGS ${PHP5PKGS[@]}
[ec536c6]430                        PHP5PKGS[0]="$PHP7VERSION"
[a37e5fc4]431                        INSTALLDEPS=${PHP5PKGS[@]//php5*-/${PHP7VERSION}-}
432                fi
433        fi
[ec536c6]434        if [ "$OSDISTRIB" == "centos" ]; then
435                PHP7VERSION=$(yum list -q php7\* 2>/dev/null | awk -F. '/^php/ {print $1; exit;}')
[97b6579]436                PHPFPMSERV="${PHP7VERSION}-${PHPFPMSERV}"
[ec536c6]437                PHP5PKGS=( $(yum list installed | awk '$1~/^php/ && $2~/^5\./ {sub(/\..*$/, "", $1); print $1}') )
438                if [ -n "$PHP5PKGS" ]; then
439                        $DELETEPKGS ${PHP5PKGS[@]}
440                        PHP5PKGS[0]="$PHP7VERSION-php"
441                        INSTALLDEPS=${PHP5PKGS[@]//php-/${PHP7VERSION}-php}
442                fi
443        fi
[a37e5fc4]444
[a0867b37]445        if [ $# = 0 ]; then
[0304465]446                echoAndLog "${FUNCNAME}(): no dependencies are needed"
[c1e00e4]447        else
448                while [ $# -gt 0 ]; do
[a37e5fc4]449                        package="${1/php/$PHP7VERSION}"
[b6fd406]450                        eval $CHECKPKG || INSTALLDEPS="$INSTALLDEPS $package"
[c1e00e4]451                        shift
452                done
453                if [ -n "$INSTALLDEPS" ]; then
[db9e706]454                        $INSTALLPKGS $INSTALLDEPS
[c1e00e4]455                        if [ $? -ne 0 ]; then
[0304465]456                                errorAndLog "${FUNCNAME}(): cannot install some dependencies: $INSTALLDEPS"
[c1e00e4]457                                return 1
458                        fi
459                fi
460        fi
[a0867b37]461}
462
463
464#####################################################################
[884b6ce]465####### Funciones para descargar código
[a0867b37]466#####################################################################
467
[884b6ce]468function downloadCode()
[a0867b37]469{
470        if [ $# -ne 1 ]; then
471                errorAndLog "${FUNCNAME}(): invalid number of parameters"
472                exit 1
473        fi
474
[27dc5ff]475        local url="$1"
[a0867b37]476
[884b6ce]477        echoAndLog "${FUNCNAME}(): downloading code..."
[a0867b37]478
[4f64fa1]479        curl "$url" -o opengnsys.zip && \
480                unzip -qo opengnsys.zip && \
481                rm -fr opengnsys && \
482                mv "OpenGnsys-$BRANCH" opengnsys
[a0867b37]483        if [ $? -ne 0 ]; then
484                errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
485                return 1
486        fi
[884b6ce]487        rm -f opengnsys.zip
488        echoAndLog "${FUNCNAME}(): code was downloaded"
[a0867b37]489        return 0
490}
491
492
493############################################################
494###  Detectar red
495############################################################
496
[07c3a59]497# Comprobar si existe conexión.
498function checkNetworkConnection()
499{
[a0081b7]500        OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"opengnsys.es"}
[884b6ce]501        if which curl &>/dev/null; then
[506c670]502                curl --connect-timeout 10 -s "https://$OPENGNSYS_SERVER" -o /dev/null && \
503                        curl --connect-timeout 10 -s "http://$OPENGNSYS_SERVER" -o /dev/null
[884b6ce]504        elif which wget &>/dev/null; then
[506c670]505                wget --spider -q "https://$OPENGNSYS_SERVER" && \
506                        wget --spider -q "http://$OPENGNSYS_SERVER"
[884b6ce]507        else
508                echoAndLog "${FUNCNAME}(): Cannot execute \"wget\" nor \"curl\"."
509                return 1
510        fi
[07c3a59]511}
512
[0304465]513# Comprobar si la versión es anterior a la actual.
514function checkVersion()
515{
516        local PRE
517
518        # Obtener versión actual y versión a actualizar.
[9815cac]519        [ -f $INSTALL_TARGET/doc/VERSION.txt ] && OLDVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt 2>/dev/null)
520        [ -f $INSTALL_TARGET/doc/VERSION.json ] && OLDVERSION=$(jq -r '.version' $INSTALL_TARGET/doc/VERSION.json 2>/dev/null)
[884b6ce]521        if [ $REMOTE -eq 1 ]; then
[9815cac]522                NEWVERSION=$(curl -s $RAW_URL/doc/VERSION.json 2>/dev/null | jq -r '.version')
[0304465]523        else
[5f0c2dd]524                NEWVERSION=$(jq -r '.version' $PROGRAMDIR/../doc/VERSION.json 2>/dev/null)
[0304465]525        fi
526        [[ "$NEWVERSION" =~ pre ]] && PRE=1
527
528        # Comparar versiones.
529        [[ "$NEWVERSION" < "${OLDVERSION/pre/}" ]] && return 1
530        [ "${NEWVERSION/pre/}" == "$OLDVERSION" -a "$PRE" == "1" ] && return 1
531
532        return 0
533}
534
[739fb00]535# Obtener los parámetros de red del servidor.
536function getNetworkSettings()
537{
538        # Variables globales definidas:
539        # - SERVERIP:   IP local de la interfaz por defecto.
540
541        local DEVICES
542        local dev
543
[90b507d]544        SERVERIP="$ServidorAdm"
[739fb00]545        DEVICES="$(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}')"
546        for dev in $DEVICES; do
[2c1b0cf]547                [ -z "$SERVERIP" ] && SERVERIP=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4); exit;}')
[739fb00]548        done
549}
550
[a0867b37]551
552#####################################################################
553####### Funciones específicas de la instalación de Opengnsys
554#####################################################################
555
[5f21d34]556# Actualizar cliente OpenGnsys.
[295b4ab]557function updateClientFiles()
[45f1fe8]558{
[74cd321]559        local ENGINECFG=$INSTALL_TARGET/client/etc/engine.cfg
560
[a43e90d]561        # Actualizar ficheros del cliente.
[74cd321]562        backupFile $ENGINECFG
[0304465]563        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Client files"
[884b6ce]564        rsync -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
[45f1fe8]565        if [ $? -ne 0 ]; then
566                errorAndLog "${FUNCNAME}(): error while updating client structure"
[51b179a]567                exit 1
[45f1fe8]568        fi
[a43e90d]569
570        # Actualizar librerías del motor de clonación.
[0304465]571        echoAndLog "${FUNCNAME}(): Updating OpenGnsys Cloning Engine files"
[884b6ce]572        rsync -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
[45f1fe8]573        if [ $? -ne 0 ]; then
574                errorAndLog "${FUNCNAME}(): error while updating engine files"
[51b179a]575                exit 1
[45f1fe8]576        fi
[a3855dc]577        # Actualizar fichero de configuración del motor de clonación.
[c40710e]578        if ! grep -q "^TZ" $ENGINECFG; then
[a3855dc]579                TZ=$(timedatectl status | awk -F"[:()]" '/Time.*zone/ {print $2}')
[c40710e]580                cat << EOT >> $ENGINECFG
[a3855dc]581# OpenGnsys Server timezone.
582TZ="${TZ// /}"
583EOT
584        fi
[8fc7ce1]585        if ! diff -q ${ENGINECFG}{,-LAST} &>/dev/null; then
[c40710e]586                NEWFILES="$NEWFILES $ENGINECFG"
587        else
588                rm -f ${ENGINECFG}-LAST
589        fi
[ec045b1]590        # Obtener URL para descargas adicionales.
591        DOWNLOADURL=$(oglivecli config download-url 2>/dev/null)
[a0081b7]592        DOWNLOADURL=${DOWNLOADURL:-"https://$OPENGNSYS_SERVER/trac/downloads"}
[a3855dc]593
[0304465]594        echoAndLog "${FUNCNAME}(): client files successfully updated"
[45f1fe8]595}
[4e51cb0]596
[5050850]597# Crear certificado para la firma de cargadores de arranque, si es necesario.
598function createCerts ()
599{
600        local SSLCFGDIR=$INSTALL_TARGET/client/etc/ssl
601        mkdir -p $SSLCFGDIR/{certs,private}
602        if [ ! -f $SSLCFGDIR/private/opengnsys.key ]; then
603                echoAndLog "${FUNCNAME}(): creating certificate files"
604                openssl req -new -x509 -newkey rsa:2048 -keyout $SSLCFGDIR/private/opengnsys.key -out $SSLCFGDIR/certs/opengnsys.crt -nodes -days 3650 -subj "/CN=OpenGnsys/"
605                openssl x509 -in $SSLCFGDIR/certs/opengnsys.crt -out $SSLCFGDIR/certs/opengnsys.cer -outform DER
606                echoAndLog "${FUNCNAME}(): certificate successfully created"
607        fi
608}
609
[3ce53a7]610# Configurar HTTPS y exportar usuario y grupo del servicio Apache.
611function apacheConfiguration ()
[4e51cb0]612{
[9215580]613        local config template module socketfile
[6f4d39b]614
[ec536c6]615        # Avtivar PHP-FPM.
616        echoAndLog "${FUNCNAME}(): configuring PHP-FPM"
617        service=$PHPFPMSERV
618        $ENABLESERVICE; $STARTSERVICE
619
[9215580]620        # Activar módulos de Apache.
[2e38f60]621        if [ -e $APACHECFGDIR/sites-available/opengnsys.conf ]; then
[0304465]622                echoAndLog "${FUNCNAME}(): Configuring Apache modules"
[3ce53a7]623                a2ensite default-ssl
[9215580]624                for module in $APACHEENABLEMODS; do a2enmod -q "$module"; done
625                for module in $APACHEDISABLEMODS; do a2dismod -q "${module//PHP7VERSION}"; done
[3ce53a7]626                a2ensite opengnsys
[5f21d34]627        elif [ -e $APACHECFGDIR/conf.modules.d ]; then
[0304465]628                echoAndLog "${FUNCNAME}(): Configuring Apache modules"
[5f21d34]629                sed -i '/rewrite/s/^#//' $APACHECFGDIR/*.conf
[3ce53a7]630        fi
[ec536c6]631        # Elegir plantilla según versión de Apache.
632        if [ -n "$(apachectl -v | grep "2\.[0-2]")" ]; then
633               template=$WORKDIR/opengnsys/server/etc/apache-prev2.4.conf.tmpl > $config
634        else
635               template=$WORKDIR/opengnsys/server/etc/apache.conf.tmpl
636        fi
[ea016a46]637        sockfile=$(find /run/php -name "php*.sock" -type s -print 2>/dev/null | tail -1)
[6f4d39b]638        # Actualizar configuración de Apache a partir de fichero de plantilla.
639        for config in $APACHECFGDIR/{,sites-available/}opengnsys.conf; do
[37481d8]640                if [ -e $config ]; then
641                        if [ -n "$sockfile" ]; then
642                                sed -e "s,CONSOLEDIR,$INSTALL_TARGET/www,g; s,proxy:fcgi:.*,proxy:unix:${sockfile%% *}|fcgi://localhost\",g" $template > $config
643                        else
644                                sed -e "s,CONSOLEDIR,$INSTALL_TARGET/www,g" $template > $config
645                        fi
646                fi
[900be258]647        done
648
649        # Reiniciar Apache.
[ec536c6]650        service=$APACHESERV; $STARTSERVICE
[900be258]651
[3ce53a7]652        # Variables de ejecución de Apache.
[4e51cb0]653        # - APACHE_RUN_USER
654        # - APACHE_RUN_GROUP
[2e38f60]655        if [ -f $APACHECFGDIR/envvars ]; then
656                source $APACHECFGDIR/envvars
[4e51cb0]657        fi
[2e38f60]658        APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"}
[de8bbb1]659        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
[4e51cb0]660}
661
[4b96166]662# Configurar servicio Rsync.
663function rsyncConfigure()
664{
665        local service
666
667        # Configurar acceso a Rsync.
668        if [ ! -f /etc/rsyncd.conf ]; then
[0304465]669                echoAndLog "${FUNCNAME}(): Configuring Rsync service"
[65baf16]670                NEWFILES="$NEWFILES /etc/rsyncd.conf"
[4b96166]671                sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENTUSER/g" \
672                    $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > /etc/rsyncd.conf
673                # Habilitar Rsync.
674                if [ -f /etc/default/rsync ]; then
675                        perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
676                fi
677                if [ -f $INETDCFGDIR/rsync ]; then
678                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
679                else
680                        cat << EOT > $INETDCFGDIR/rsync
681service rsync
682{
683        disable = no
684        socket_type = stream
685        wait = no
686        user = root
687        server = $(which rsync)
688        server_args = --daemon
689        log_on_failure += USERID
690        flags = IPv6
691}
692EOT
693                fi
694                # Activar e iniciar Rsync.
695                service="rsync"  $ENABLESERVICE
[ab7f563]696                service="xinetd"
697                $ENABLESERVICE; $STARTSERVICE
[4b96166]698        fi
699}
700
[5f21d34]701# Copiar ficheros del OpenGnsys Web Console.
[a0867b37]702function updateWebFiles()
703{
[2b793a8]704        local ERRCODE COMPATDIR f
705
[a0867b37]706        echoAndLog "${FUNCNAME}(): Updating web files..."
[2b793a8]707
708        # Copiar los ficheros nuevos conservando el archivo de configuración de acceso.
709        backupFile $INSTALL_TARGET/www/controlacceso.php
710        mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
[884b6ce]711        rsync -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
[2b793a8]712        ERRCODE=$?
713        mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
[1635f45]714        rm -fr $INSTALL_TARGET/www/xajax
[900be258]715        unzip -o $WORKDIR/opengnsys/admin/slim-2.6.1.zip -d $INSTALL_TARGET/www/rest
[8b8e948]716        unzip -o $WORKDIR/opengnsys/admin/swagger-ui-2.2.5.zip -d $INSTALL_TARGET/www/rest
[d655cc4]717        if [ $ERRCODE != 0 ]; then
[a0867b37]718                errorAndLog "${FUNCNAME}(): Error updating web files."
719                exit 1
720        fi
[2b793a8]721        restoreFile $INSTALL_TARGET/www/controlacceso.php
722
[1a2fa9d8]723        # Cambiar acceso a protocolo HTTPS.
724        if grep -q "http://" $INSTALL_TARGET/www/controlacceso.php 2>/dev/null; then
725                echoAndLog "${FUNCNAME}(): updating web access file"
726                perl -pi -e 's!http://!https://!g' $INSTALL_TARGET/www/controlacceso.php
727                NEWFILES="$NEWFILES $INSTALL_TARGET/www/controlacceso.php"
728        fi
729
[2b793a8]730        # Compatibilidad con dispositivos móviles.
731        COMPATDIR="$INSTALL_TARGET/www/principal"
732        for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
733                sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
734        done
[d70a45f]735        cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
[aafe8f9]736        # Acceso al manual de usuario
737        ln -fs ../doc/userManual $INSTALL_TARGET/www/userManual
[0645906]738        # Fichero de log de la API REST.
739        touch $INSTALL_TARGET/log/{ogagent,rest,remotepc}.log
[2b793a8]740
[0304465]741        echoAndLog "${FUNCNAME}(): Web files successfully updated"
[a0867b37]742}
743
[ec045b1]744# Copiar ficheros en la zona de descargas de OpenGnsys Web Console.
745function updateDownloadableFiles()
746{
[0304465]747        local FILENAME=ogagentpkgs-$NEWVERSION.tar.gz
[ec045b1]748        local TARGETFILE=$WORKDIR/$FILENAME
749
750        # Descargar archivo comprimido, si es necesario.
751        if [ -s $PROGRAMDIR/$FILENAME ]; then
752                echoAndLog "${FUNCNAME}(): Moving $PROGRAMDIR/$FILENAME file to $(dirname $TARGETFILE)"
753                mv $PROGRAMDIR/$FILENAME $TARGETFILE
754        else
755                echoAndLog "${FUNCNAME}(): Downloading $FILENAME"
[884b6ce]756                curl $DOWNLOADURL/$FILENAME -o $TARGETFILE
[ec045b1]757        fi
758        if [ ! -s $TARGETFILE ]; then
759                errorAndLog "${FUNCNAME}(): Cannot download $FILENAME"
760                return 1
761        fi
762
763        # Descomprimir fichero en zona de descargas.
764        tar xvzf $TARGETFILE -C $INSTALL_TARGET/www/descargas
765        if [ $? != 0 ]; then
[0304465]766                errorAndLog "${FUNCNAME}(): Error uncompressing archive $FILENAME"
[884b6ce]767                return 1
[ec045b1]768        fi
769}
770
[72134d5]771# Copiar carpeta de Interface
[64dd765]772function updateInterfaceAdm()
[72134d5]773{
[27dc5ff]774        local errcode=0
[2b793a8]775
[72134d5]776        # Crear carpeta y copiar Interface
777        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
778        mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
[884b6ce]779        rsync -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
[27dc5ff]780        errcoce=$?
[72134d5]781        mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm
[27dc5ff]782        if [ $errcode -ne 0 ]; then
[72134d5]783                echoAndLog "${FUNCNAME}(): error while updating admin interface"
784                exit 1
785        fi
[0304465]786        echoAndLog "${FUNCNAME}(): Admin interface successfully updated"
[72134d5]787}
[a0867b37]788
[5d6bf97]789# Crear documentación Doxygen para la consola web.
790function makeDoxygenFiles()
791{
792        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
793        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
794                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
795        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
[0304465]796                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files"
[5d6bf97]797                return 1
798        fi
[45f1fe8]799        rm -fr "$INSTALL_TARGET/www/api"
[15b2a4e]800        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
801        rm -fr $INSTALL_TARGET/www/{man,perlmod,rtf}
[0304465]802        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully"
[5d6bf97]803}
804
805
[a0867b37]806# Crea la estructura base de la instalación de opengnsys
807function createDirs()
808{
[eb9424f]809        # Crear estructura de directorios.
[a0867b37]810        echoAndLog "${FUNCNAME}(): creating directory paths in ${INSTALL_TARGET}"
[8cb279b]811        local dir MKNETDIR
[7bb72f7]812
[cfad47b]813        mkdir -p ${INSTALL_TARGET}/{bin,doc,etc,lib,sbin,www}
[d7ece95]814        mkdir -p ${INSTALL_TARGET}/{client,images/groups}
[a0867b37]815        mkdir -p ${INSTALL_TARGET}/log/clients
[eb9424f]816        ln -fs ${INSTALL_TARGET}/log /var/log/opengnsys
[7bb72f7]817        # Detectar directorio de instalación de TFTP.
818        if [ ! -L ${INSTALL_TARGET}/tftpboot ]; then
819                for dir in /var/lib/tftpboot /srv/tftp; do
820                        [ -d $dir ] && ln -fs $dir ${INSTALL_TARGET}/tftpboot
821                done
822        fi
[b4d8d51]823        mkdir -p $INSTALL_TARGET/tftpboot/{menu.lst,grub}/examples
[a0867b37]824        if [ $? -ne 0 ]; then
825                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
826                return 1
827        fi
[663cd905]828        ! [ -f $INSTALL_TARGET/tftpboot/menu.lst/templates/00unknown ] && mv $INSTALL_TARGET/tftpboot/menu.lst/templates/* $INSTALL_TARGET/tftpboot/menu.lst/examples
[b4d8d51]829        ! [ -f $INSTALL_TARGET/tftpboot/grub/templates/10 ] && mv $INSTALL_TARGET/tftpboot/grub/templates/* $INSTALL_TARGET/tftpboot/grub/examples
[a0867b37]830
[8cb279b]831        # Preparar arranque en red con Grub.
832        for f in grub-mknetdir grub2-mknetdir; do
833                if which $f &>/dev/null; then MKNETDIR=$f; fi
834        done
[5969a13]835        $MKNETDIR --net-directory=${INSTALL_TARGET}/tftpboot --subdir=grub
[8cb279b]836
[eb9424f]837        # Crear usuario ficticio.
838        if id -u $OPENGNSYS_CLIENTUSER &>/dev/null; then
839                echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENTUSER\" is already created"
840        else
[5f21d34]841                echoAndLog "${FUNCNAME}(): creating OpenGnsys user"
[eb9424f]842                useradd $OPENGNSYS_CLIENTUSER 2>/dev/null
843                if [ $? -ne 0 ]; then
[5f21d34]844                        errorAndLog "${FUNCNAME}(): error creating OpenGnsys user"
[eb9424f]845                        return 1
846                fi
847        fi
848
[57f7e9c]849        # Mover el fichero de registro al directorio de logs.
850        echoAndLog "${FUNCNAME}(): moving update log file"
851        mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
[7669bca]852        chmod 600 $LOG_FILE
[57f7e9c]853
[a0867b37]854        echoAndLog "${FUNCNAME}(): directory paths created"
855        return 0
856}
857
[566e84f]858# Actualización incremental de la BD (versión actaul a actaul+1, hasta final-1 a final).
859function updateDatabase()
860{
861        local DBDIR="$WORKDIR/opengnsys/admin/Database"
862        local file FILES=""
863
864        echoAndLog "${FUNCNAME}(): looking for database updates"
865        pushd $DBDIR >/dev/null
866        # Bucle de actualización incremental desde versión actual a la final.
867        for file in $OPENGNSYS_DATABASE-*-*.sql; do
868                case "$file" in
869                        $OPENGNSYS_DATABASE-$OLDVERSION-$NEWVERSION.sql)
870                                # Actualización única de versión inicial y final.
871                                FILES="$FILES $file"
872                                break
873                                ;;
874                        $OPENGNSYS_DATABASE-*-postinst.sql)
875                                # Ignorar fichero específico de post-instalación.
876                                ;;
877                        $OPENGNSYS_DATABASE-$OLDVERSION-*.sql)
878                                # Actualización de versión n a n+1.
879                                FILES="$FILES $file"
[b5db03a]880                                OLDVERSION="$(echo ${file%.*} | cut -f3 -d-)"
[566e84f]881                                ;;
882                        $OPENGNSYS_DATABASE-*-$NEWVERSION.sql)
883                                # Última actualización de versión final-1 a final.
884                                if [ -n "$FILES" ]; then
885                                        FILES="$FILES $file"
886                                        break
887                                fi
888                                ;;
889                esac
890        done
891        # Aplicar posible actualización propia para la versión final.
892        file=$OPENGNSYS_DATABASE-$NEWVERSION.sql
893        if [ -n "$FILES" -o "$OLDVERSION" = "$NEWVERSION" -a -r $file ]; then
894                FILES="$FILES $file"
895        fi
896
897        popd >/dev/null
898        if [ -n "$FILES" ]; then
899                for file in $FILES; do
[0cfe47a]900                        importSqlFile $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD $OPENGNSYS_DATABASE $DBDIR/$file
[566e84f]901                done
902                echoAndLog "${FUNCNAME}(): database is update"
903        else
904                echoAndLog "${FUNCNAME}(): database unchanged"
905        fi
906}
907
[a0867b37]908# Copia ficheros de configuración y ejecutables genéricos del servidor.
[64dd765]909function updateServerFiles()
[bb30a50]910{
[c1e00e4]911        # No copiar ficheros del antiguo cliente Initrd
[873cf1e]912        local SOURCES=( repoman/bin \
[c1e00e4]913                        server/bin \
[3e7d77b]914                        server/lib \
[42a0e41]915                        admin/Sources/Services/ogAdmServerAux \
916                        admin/Sources/Services/ogAdmRepoAux \
[873cf1e]917                        server/tftpboot \
[5969a13]918                        /usr/lib/shim/shimx64.efi.signed \
919                        /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed \
[bb30a50]920                        installer/opengnsys_uninstall.sh \
[6777e3e]921                        installer/opengnsys_export.sh \
922                        installer/opengnsys_import.sh \
[873cf1e]923                        doc )
924        local TARGETS=( bin \
925                        bin \
[3e7d77b]926                        lib \
[cdad332]927                        sbin/ogAdmServerAux \
928                        sbin/ogAdmRepoAux \
[873cf1e]929                        tftpboot \
[5969a13]930                        tftpboot/shimx64.efi.signed \
931                        tftpboot/grubx64.efi \
[9a2c0f9d]932                        lib/opengnsys_uninstall.sh \
[6777e3e]933                        lib/opengnsys_export.sh \
934                        lib/opengnsys_import.sh \
[873cf1e]935                        doc )
[a0867b37]936
937        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
938                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
939                exit 1
940        fi
941
942        echoAndLog "${FUNCNAME}(): updating files in server directories"
943        pushd $WORKDIR/opengnsys >/dev/null
944        local i
945        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
[27dc5ff]946                if [ -d "$INSTALL_TARGET/${TARGETS[i]}" ]; then
[884b6ce]947                        rsync -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}"))
[aa36857]948                else
[56f100f]949                        rsync -irplt "${SOURCES[i]}" $(readlink -m "$INSTALL_TARGET/${TARGETS[i]}")
[aa36857]950                fi
[a0867b37]951        done
952        popd >/dev/null
[df3cd7f]953        NEWFILES=""             # Ficheros de configuración que han cambiado de formato.
[f80f839]954        if grep -q 'pxelinux.0' /etc/dhcp*/dhcpd*.conf; then
[df3cd7f]955                echoAndLog "${FUNCNAME}(): updating DHCP files"
[f80f839]956                perl -pi -e 's/pxelinux.0/grldr/' /etc/dhcp*/dhcpd*.conf
[a37e5fc4]957                service=$DHCPSERV; $STARTSERVICE
[df3cd7f]958                NEWFILES="/etc/dhcp*/dhcpd*.conf"
959        fi
[5969a13]960        if ! grep -q 'shimx64.efi.signed' /etc/dhcp*/dhcpd*.conf; then
961                echoAndLog "${FUNCNAME}(): updating DHCP files for UEFI computers"
962                UEFICFG="    # 0007 == x64 EFI boot\n"\
963"    if option arch = 00:07 {\n"\
964"        filename \"shimx64.efi.signed\";\n"\
965"    } else {\n"\
966"        filename \"grldr\";\n"\
967"    }"
[8f24716]968                sed -i -e 1i"option arch code 93 = unsigned integer 16;" -e s@"^.*grldr\"\;"@"$UEFICFG"@g /etc/dhcp*/dhcpd*.conf
[5969a13]969                service=$DHCPSERV; $STARTSERVICE
970                NEWFILES="/etc/dhcp*/dhcpd*.conf"
971        fi
[d372e6e]972        if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then
[df3cd7f]973                echoAndLog "${FUNCNAME}(): updating new init file"
974                backupFile /etc/init.d/opengnsys
975                cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
976                NEWFILES="$NEWFILES /etc/init.d/opengnsys"
977        fi
[3b8ef0d]978        if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys >/dev/null; then
979                echoAndLog "${FUNCNAME}(): updating new default file"
980                backupFile /etc/default/opengnsys
981                # Buscar si hay nuevos parámetros.
982                local var valor
983                while IFS="=" read -e var valor; do
984                        [[ $var =~ ^# ]] || \
985                                grep -q "^$var=" /etc/default/opengnsys || \
986                                echo "$var=$valor" >> /etc/default/opengnsys
987                done < $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default
988                NEWFILES="$NEWFILES /etc/default/opengnsys"
989        fi
[1a2fa9d8]990        if egrep -q "(UrlMsg=.*msgbrowser.php)|(UrlMenu=http://)" $INSTALL_TARGET/client/etc/ogAdmClient.cfg 2>/dev/null; then
[df3cd7f]991                echoAndLog "${FUNCNAME}(): updating new client config file"
992                backupFile $INSTALL_TARGET/client/etc/ogAdmClient.cfg
[1a2fa9d8]993                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
[df3cd7f]994                NEWFILES="$NEWFILES $INSTALL_TARGET/client/etc/ogAdmClient.cfg"
[f80f839]995        fi
[a3855dc]996
[9ee62ad]997        echoAndLog "${FUNCNAME}(): updating cron files"
[db9e706]998        [ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
999        [ ! -f /etc/cron.d/torrenttracker ] && echo "5 * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
[dc762088]1000        [ ! -f /etc/cron.d/imagedelete ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
[0645906]1001        [ ! -f /etc/cron.d/ogagentqueue ] && echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/ogagentqueue.cron ] && $INSTALL_TARGET/bin/ogagentqueue.cron" > /etc/cron.d/ogagentqueue
[b4d8d51]1002
[d9b2413]1003        echoAndLog "${FUNCNAME}(): deleting deprecated cron file"
1004        [ -e /etc/cron.d/opengnsys ] && rm -f /etc/cron.d/opengnsys \
1005                                              $INSTALL_TARGET/bin/opengnsys.cron
1006
[b4d8d51]1007        # Se modifican los nombres de las plantilla PXE por compatibilidad con los equipos UEFI.
1008        if [ -f $INSTALL_TARGET/tftpboot/menu.lst/templates/01 ]; then
1009            BIOSPXEDIR="$INSTALL_TARGET/tftpboot/menu.lst/templates"
1010            mv $BIOSPXEDIR/01 $BIOSPXEDIR/10
[74e6712]1011            sed -i "s/\bMBR\b/1hd/" $BIOSPXEDIR/10
[b4d8d51]1012        fi
[8f24716]1013        echoAndLog "${FUNCNAME}(): server files successfully updated"
[a0867b37]1014}
1015
1016####################################################################
1017### Funciones de compilación de código fuente de servicios
1018####################################################################
1019
[dde65c7]1020# Mueve el fichero del nuevo servicio si es distinto al del directorio destino.
1021function moveNewService()
1022{
1023        local service
1024
1025        # Recibe 2 parámetros: fichero origen y directorio destino.
1026        [ $# == 2 ] || return 1
[ddcb0cf]1027        [ -f  $1 -a -d $2 ] || return 1
[dde65c7]1028
1029        # Comparar los ficheros.
[ddcb0cf]1030        if ! diff -q $1 $2/$(basename $1) &>/dev/null; then
[dde65c7]1031                # Parar los servicios si fuese necesario.
1032                [ -z "$NEWSERVICES" ] && service="opengnsys" $STOPSERVICE
1033                # Nuevo servicio.
1034                NEWSERVICES="$NEWSERVICES $(basename $1)"
1035                # Mover el nuevo fichero de servicio
1036                mv $1 $2
1037        fi
1038}
1039
1040
[bb30a50]1041# Recompilar y actualiza los serivicios y clientes.
[64dd765]1042function compileServices()
[a0867b37]1043{
[bb30a50]1044        local hayErrores=0
1045
[5f21d34]1046        # Compilar OpenGnsys Server
1047        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Admin Server"
[bb30a50]1048        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
[dde65c7]1049        make && moveNewService ogAdmServer $INSTALL_TARGET/sbin
[bb30a50]1050        if [ $? -ne 0 ]; then
[5f21d34]1051                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server"
[bb30a50]1052                hayErrores=1
1053        fi
1054        popd
[dde2db1]1055        # Parar antiguo servicio de repositorio.
[b351d8a]1056        pgrep ogAdmRepo > /dev/null && service="ogAdmRepo" $STOPSERVICE
[5f21d34]1057        # Compilar OpenGnsys Agent
[0304465]1058        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Server Agent"
[bb30a50]1059        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
[dde65c7]1060        make && moveNewService ogAdmAgent $INSTALL_TARGET/sbin
[bb30a50]1061        if [ $? -ne 0 ]; then
[0304465]1062                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Server Agent"
[bb30a50]1063                hayErrores=1
1064        fi
1065        popd
1066
[5f21d34]1067        # Compilar OpenGnsys Client
1068        echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Client"
[72134d5]1069        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
[e473667]1070        make && mv ogAdmClient $INSTALL_TARGET/client/bin
[a0867b37]1071        if [ $? -ne 0 ]; then
[5f21d34]1072                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Client"
[a0867b37]1073                hayErrores=1
1074        fi
1075        popd
[8f24716]1076        # Generar un API token de ogAdmServer si no existe en el fichero de configuración.
1077        grep -q "APITOKEN=" $INSTALL_TARGET/etc/ogAdmServer.cfg || \
[35f1277]1078                $INSTALL_TARGET/bin/settoken -f
[a0867b37]1079
1080        return $hayErrores
1081}
1082
1083
1084####################################################################
[5f21d34]1085### Funciones instalacion cliente OpenGnsys
[a0867b37]1086####################################################################
1087
[5f21d34]1088# Actualizar cliente OpenGnsys
[c1e00e4]1089function updateClient()
1090{
[66b04ff]1091        #local FILENAME=ogLive-precise-3.2.0-23-generic-r5159.iso       # 1.1.0-rc6 (32-bit)
[2e1b900]1092        local FILENAME=ogLive-bionic-5.0.0-27-generic-amd64-r20190830.7208cc9.iso       # 1.1.1-rc5
[0b85cc93]1093        local SOURCEFILE=$DOWNLOADURL/$FILENAME
[0496417]1094        local TARGETFILE=$(oglivecli config download-dir)/$FILENAME
[0b85cc93]1095        local SOURCELENGTH
1096        local TARGETLENGTH
[0496417]1097        local OGINITRD
[a63345ac]1098        local SAMBAPASS
[0b85cc93]1099
[0496417]1100        # Comprobar si debe convertirse el antiguo cliente al nuevo formato ogLive.
1101        if oglivecli check | grep -q "oglivecli convert"; then
1102                echoAndLog "${FUNCNAME}(): Converting OpenGnsys Client to default ogLive"
1103                oglivecli convert
1104        fi
[0b85cc93]1105        # Comprobar si debe actualizarse el cliente.
[5f0c2dd]1106        SOURCELENGTH=$(curl -sI $SOURCEFILE 2>&1 | awk '/Content-Length:/ {gsub("\r", ""); print $2}')
[0496417]1107        TARGETLENGTH=$(stat -c "%s" $TARGETFILE 2>/dev/null)
[d4e90c1]1108        [ -z $TARGETLENGTH ] && TARGETLENGTH=0
[0b85cc93]1109        if [ "$SOURCELENGTH" != "$TARGETLENGTH" ]; then
[ec045b1]1110                echoAndLog "${FUNCNAME}(): Downloading $FILENAME"
[0496417]1111                oglivecli download $FILENAME
[0b85cc93]1112                if [ ! -s $TARGETFILE ]; then
[ec045b1]1113                        errorAndLog "${FUNCNAME}(): Error downloading $FILENAME"
[0b85cc93]1114                        return 1
1115                fi
[1893b9d]1116                # Actaulizar la imagen ISO del ogclient.
[0304465]1117                echoAndLog "${FUNCNAME}(): Updatting ogLive client"
[0496417]1118                oglivecli install $FILENAME
[e1c01217]1119               
[2e1b900]1120                INSTALLEDOGLIVE=${FILENAME%.*}
[ee4beb4]1121
[0304465]1122                echoAndLog "${FUNCNAME}(): ogLive successfully updated"
[0b85cc93]1123        else
[65baf16]1124                # Si no existe, crear el fichero de claves de Rsync.
1125                if [ ! -f /etc/rsyncd.secrets ]; then
[ec045b1]1126                        echoAndLog "${FUNCNAME}(): Restoring ogLive access key"
[0496417]1127                        OGINITRD=$(oglivecli config install-dir)/$(jq -r ".oglive[.default].directory")/oginitrd.img
[65baf16]1128                        SAMBAPASS=$(gzip -dc $OGINITRD | \
1129                                    cpio -i --to-stdout scripts/ogfunctions 2>&1 | \
1130                                    grep "^[    ].*OPTIONS=" | \
1131                                    sed 's/\(.*\)pass=\(\w*\)\(.*\)/\2/')
[0496417]1132                        echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | setsmbpass
[65baf16]1133                else
[ec045b1]1134                        echoAndLog "${FUNCNAME}(): ogLive is already updated"
[65baf16]1135                fi
[04e5d96]1136                # Versión del ogLive instalado.
1137                echo "${FILENAME%.*}" > $INSTALL_TARGET/doc/veroglive.txt
[c1e00e4]1138        fi
1139}
[a0867b37]1140
[5b95ab6]1141# Comprobar permisos y ficheros.
1142function checkFiles()
1143{
[fbc7333]1144        local LOGROTATEDIR=/etc/logrotate.d
1145
[5b95ab6]1146        # Comprobar permisos adecuados.
1147        if [ -x $INSTALL_TARGET/bin/checkperms ]; then
[0304465]1148                echoAndLog "${FUNCNAME}(): Checking permissions"
[5b95ab6]1149                OPENGNSYS_DIR="$INSTALL_TARGET" OPENGNSYS_USER="$OPENGNSYS_CLIENTUSER" APACHE_USER="$APACHE_RUN_USER" APACHE_GROUP="$APACHE_RUN_GROUP" $INSTALL_TARGET/bin/checkperms
1150        fi
1151        # Eliminamos el fichero de estado del tracker porque es incompatible entre los distintos paquetes
1152        if [ -f /tmp/dstate ]; then
[0304465]1153                echoAndLog "${FUNCNAME}(): Deleting unused files"
[5b95ab6]1154                rm -f /tmp/dstate
1155        fi
[59d6670]1156        # Crear nuevos ficheros de logrotate y borrar el fichero antiguo.
[fbc7333]1157        if [ -d $LOGROTATEDIR ]; then
[59d6670]1158                rm -f $LOGROTATEDIR/opengnsys
[fbc7333]1159                if [ ! -f $LOGROTATEDIR/opengnsysServer ]; then
1160                        echoAndLog "${FUNCNAME}(): Creating logrotate configuration file for server"
1161                        sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
1162                                $WORKDIR/opengnsys/server/etc/logrotate.tmpl > $LOGROTATEDIR/opengnsysServer
1163                fi
1164                if [ ! -f $LOGROTATEDIR/opengnsysRepo ]; then
1165                        echoAndLog "${FUNCNAME}(): Creating logrotate configuration file for repository"
1166                        sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
1167                                $WORKDIR/opengnsys/server/etc/logrotate.tmpl > $LOGROTATEDIR/opengnsysRepo
1168                fi
1169        fi
[5b95ab6]1170}
1171
[eb9424f]1172# Resumen de actualización.
1173function updateSummary()
1174{
1175        # Actualizar fichero de versión y revisión.
[884b6ce]1176        local VERSIONFILE REVISION
[3bbaf79]1177        VERSIONFILE="$INSTALL_TARGET/doc/VERSION.json"
[5f0c2dd]1178        # Obtener revisión.
1179        if [ $REMOTE -eq 1 ]; then
1180                # Revisión: rAñoMesDía.Gitcommit (8 caracteres de fecha y 7 primeros de commit).
[663363a]1181                if [ "$BRANCH" = "master" ]; then
1182                        REVISION=$(curl -s "$API_URL" | jq '"r" + (.commit.commit.committer.date | split("-") | join("")[:8]) + "." + (.commit.sha[:7])')
1183                else
1184                        REVISION=$(curl -s "$API_URL" | jq '"r" + (.commit.committer.date | split("-") | join("")[:8]) + "." + (.sha[:7])')
1185                fi
[5f0c2dd]1186        else
1187                # Parámetro "release" del fichero JSON.
1188                REVISION=$(jq -r '.release' $PROGRAMDIR/../doc/VERSION.json 2>/dev/null)
1189        fi
[3bbaf79]1190        [ -f $VERSIONFILE ] || echo '{ "project": "OpenGnsys" }' > $VERSIONFILE
1191        jq ".release=$REVISION" $VERSIONFILE | sponge $VERSIONFILE
1192        VERSION="$(jq -r '[.project, .version, .codename, .release] | join(" ")' $VERSIONFILE 2>/dev/null)"
1193        # Borrar antiguo fichero de versión.
1194        rm -f "${VERSIONFILE/json/txt}"
[eb9424f]1195
1196        echo
[5f21d34]1197        echoAndLog "OpenGnsys Update Summary"
[df3cd7f]1198        echo       "========================"
[3bbaf79]1199        echoAndLog "Project version:                  $VERSION"
[57f7e9c]1200        echoAndLog "Update log file:                  $LOG_FILE"
[c3e4ff1]1201        [ "$NEWFILES" ] && echoAndLog "Check new config files:           $(echo $NEWFILES)"
1202        [ "$NEWSERVICES" ] && echoAndLog "New compiled services:            $(echo $NEWSERVICES)"
[8b2da718]1203        echoAndLog "Warnings:"
[0304465]1204        echoAndLog " - You must to clear web browser cache before loading OpenGnsys page"
[dde2db1]1205        echoAndLog " - Run \"settoken\" script to update authentication tokens"
[c3e4ff1]1206        [ "$INSTALLEDOGLIVE" ] && echoAndLog " - Installed new ogLive Client: $INSTALLEDOGLIVE"
[ce63f8d]1207        echoAndLog " - If you want to use BURG as boot manager, run following command as root:"
1208        echoAndLog "      curl $DOWNLOADURL/burg.tgz -o $INSTALL_TARGET/client/lib/burg.tgz"
1209
[eb9424f]1210        echo
1211}
1212
1213
[a0867b37]1214
1215#####################################################################
[5f21d34]1216####### Proceso de actualización de OpenGnsys
[a0867b37]1217#####################################################################
1218
1219
[27dc5ff]1220# Comprobar si hay conexión y detectar parámetros de red por defecto.
1221checkNetworkConnection
1222if [ $? -ne 0 ]; then
1223        errorAndLog "Error connecting to server. Causes:"
[0304465]1224        errorAndLog " - Network is unreachable, check device parameters"
1225        errorAndLog " - You are inside a private network, configure the proxy service"
1226        errorAndLog " - Server is temporally down, try again later"
[27dc5ff]1227        exit 1
1228fi
[739fb00]1229getNetworkSettings
[27dc5ff]1230
[fd45e9a]1231# Elegir versión y comprobar si se intanta actualizar a una versión anterior.
1232chooseVersion
[0304465]1233checkVersion
1234if [ $? -ne 0 ]; then
1235        errorAndLog "Cannot downgrade to an older version ($OLDVERSION to $NEWVERSION)"
1236        errorAndLog "You must to uninstall OpenGnsys and install desired release"
1237        exit 1
1238fi
1239
[663363a]1240echoAndLog "OpenGnsys update begins at $(date)"
1241pushd $WORKDIR
1242
[64dd765]1243# Comprobar auto-actualización del programa.
1244if [ "$PROGRAMDIR" != "$INSTALL_TARGET/bin" ]; then
1245        checkAutoUpdate
1246        if [ $? -ne 0 ]; then
[0304465]1247                echoAndLog "OpenGnsys updater has been overwritten"
[063caa5]1248                echoAndLog "Please, run this script again"
[64dd765]1249                exit
1250        fi
1251fi
1252
[db9e706]1253# Detectar datos de auto-configuración del instalador.
1254autoConfigure
1255
[bb30a50]1256# Instalar dependencias.
[d70a45f]1257installDependencies ${DEPENDENCIES[*]}
[a0867b37]1258if [ $? -ne 0 ]; then
[0304465]1259        errorAndLog "Error: you must to install all needed dependencies"
[a0867b37]1260        exit 1
1261fi
1262
[5f21d34]1263# Arbol de directorios de OpenGnsys.
[a0867b37]1264createDirs ${INSTALL_TARGET}
1265if [ $? -ne 0 ]; then
[0304465]1266        errorAndLog "Error while creating directory paths"
[a0867b37]1267        exit 1
1268fi
1269
1270# Si es necesario, descarga el repositorio de código en directorio temporal
[884b6ce]1271if [ $REMOTE -eq 1 ]; then
1272        downloadCode $CODE_URL
[a0867b37]1273        if [ $? -ne 0 ]; then
[884b6ce]1274                errorAndLog "Error while getting code from repository"
[a0867b37]1275                exit 1
1276        fi
1277else
1278        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
1279fi
1280
[21372e8]1281# Comprobar configuración de MySQL.
1282checkMysqlConfig $OPENGNSYS_DBUSER $OPENGNSYS_DBPASSWORD
1283
[566e84f]1284# Actualizar la BD.
1285updateDatabase
[295b4ab]1286
1287# Actualizar ficheros complementarios del servidor
[a0867b37]1288updateServerFiles
1289if [ $? -ne 0 ]; then
[5f21d34]1290        errorAndLog "Error updating OpenGnsys Server files"
[a0867b37]1291        exit 1
1292fi
1293
[be49575]1294# Configurar Rsync.
1295rsyncConfigure
1296
[5050850]1297# Actualizar ficheros del cliente.
[295b4ab]1298updateClientFiles
[5050850]1299createCerts
[295b4ab]1300updateInterfaceAdm
[45f1fe8]1301
[5050850]1302# Actualizar páqinas web.
[3ce53a7]1303apacheConfiguration
[a0867b37]1304updateWebFiles
1305if [ $? -ne 0 ]; then
[5f21d34]1306        errorAndLog "Error updating OpenGnsys Web Admin files"
[a0867b37]1307        exit 1
1308fi
[ec045b1]1309# Actaulizar ficheros descargables.
1310updateDownloadableFiles
[5d6bf97]1311# Generar páginas Doxygen para instalar en el web
1312makeDoxygenFiles
[a0867b37]1313
[bb30a50]1314# Recompilar y actualizar los servicios del sistema
[c3e4ff1]1315if compileServices; then
1316        # Restart services, if necessary.
1317        if [ "$NEWSERVICES" ]; then
1318                echoAndLog "Restarting OpenGnsys services"
1319                service="opengnsys" $STARTSERVICE
1320        fi
1321else
1322        errorAndLog "Error compiling OpenGnsys services"
1323        exit 1
1324fi
[bb30a50]1325
1326# Actaulizar ficheros auxiliares del cliente
[a0867b37]1327updateClient
1328if [ $? -ne 0 ]; then
[0304465]1329        errorAndLog "Error updating client files"
[a0867b37]1330        exit 1
1331fi
1332
[5b95ab6]1333# Comprobar permisos y ficheros.
1334checkFiles
[3320409]1335
[eb9424f]1336# Mostrar resumen de actualización.
1337updateSummary
1338
[3b8ef0d]1339rm -rf $WORKDIR
[5f21d34]1340echoAndLog "OpenGnsys update finished at $(date)"
[a0867b37]1341
1342popd
1343
Note: See TracBrowser for help on using the repository browser.