source: installer/opengnsys_installer.sh @ 5827bb9

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

#730: Evitar errores en algunas clásulas GROUP BY cuando MySQL tiene habilitado el modo ONLY_FULL_GROUP_BY (por deecto en MySQL 5.7 de Ubuntu 16.04).

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

  • Property mode set to 100755
File size: 57.3 KB
RevLine 
[a01156a]1#!/bin/bash
2
3#####################################################################
[5f21d34]4####### Script instalador OpenGnsys
5####### Autor: Luis Guillén <lguillen@unizar.es>
[a01156a]6#####################################################################
7
8
[9672640]9####  AVISO: Puede editar configuración de acceso por defecto.
10####  WARNING: Edit default access configuration if you wish.
11DEFAULT_MYSQL_ROOT_PASSWORD="passwordroot"      # Clave por defecto root de MySQL
[5f21d34]12DEFAULT_OPENGNSYS_DB_USER="usuog"               # Usuario por defecto de acceso a la base de datos
[9672640]13DEFAULT_OPENGNSYS_DB_PASSWD="passusuog"         # Clave por defecto de acceso a la base de datos
14DEFAULT_OPENGNSYS_CLIENT_PASSWD="og"            # Clave por defecto de acceso del cliente       
[4a3cd1f]15
[1e7eaab]16# Sólo ejecutable por usuario root
[6ef01d9]17if [ "$(whoami)" != 'root' ]; then
[1e7eaab]18        echo "ERROR: this program must run under root privileges!!"
19        exit 1
20fi
[9672640]21
[5f21d34]22echo -e "\\nOpenGnsys Installation"
[9672640]23echo "=============================="
24
25# Clave root de MySQL
26while : ; do
27        echo -n -e "\\nEnter root password for MySQL (${DEFAULT_MYSQL_ROOT_PASSWORD}): ";
28        read MYSQL_ROOT_PASSWORD
29        if [ -n "${MYSQL_ROOT_PASSWORD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
30                echo -e "\\aERROR: Must be alphanumeric, try again..."
31        else
32                if [ -z $MYSQL_ROOT_PASSWORD ]; then # Si esta vacio ponemos el valor por defecto
33                        MYSQL_ROOT_PASSWORD=$DEFAULT_MYSQL_ROOT_PASSWORD
34                fi
35                break
36        fi
37done
38
39# Usuario de acceso a la base de datos
40while : ; do
[5f21d34]41        echo -n -e "\\nEnter username for OpenGnsys console (${DEFAULT_OPENGNSYS_DB_USER}): "
[9672640]42        read OPENGNSYS_DB_USER
43        if [ -n "${OPENGNSYS_DB_USER//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
44                echo -e "\\aERROR: Must be alphanumeric, try again..."
45        else
46                if [ -z $OPENGNSYS_DB_USER ]; then # Si esta vacio ponemos el valor por defecto
47                        OPENGNSYS_DB_USER=$DEFAULT_OPENGNSYS_DB_USER
48                fi
49                break
50        fi
51done
52
53# Clave de acceso a la base de datos
54while : ; do
[5f21d34]55        echo -n -e "\\nEnter password for OpenGnsys console (${DEFAULT_OPENGNSYS_DB_PASSWD}): "
[9672640]56        read OPENGNSYS_DB_PASSWD
57        if [ -n "${OPENGNSYS_DB_PASSWD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
58                echo -e "\\aERROR: Must be alphanumeric, try again..."
59        else
60                if [ -z $OPENGNSYS_DB_PASSWD ]; then # Si esta vacio ponemos el valor por defecto
61                        OPENGNSYS_DB_PASSWD=$DEFAULT_OPENGNSYS_DB_PASSWD
62                fi
63                break
64        fi
65done
66
67# Clave de acceso del cliente
68while : ; do
[5f21d34]69        echo -n -e "\\nEnter root password for OpenGnsys client (${DEFAULT_OPENGNSYS_CLIENT_PASSWD}): "
[9672640]70        read OPENGNSYS_CLIENT_PASSWD
71        if [ -n "${OPENGNSYS_CLIENT_PASSWD//[a-zA-Z0-9]/}" ]; then # Comprobamos que sea un valor alfanumerico
72                echo -e "\\aERROR: Must be alphanumeric, try again..."
73        else
74                if [ -z $OPENGNSYS_CLIENT_PASSWD ]; then # Si esta vacio ponemos el valor por defecto
75                        OPENGNSYS_CLIENT_PASSWD=$DEFAULT_OPENGNSYS_CLIENT_PASSWD
76                fi
77                break
78        fi
79done
80
81echo -e "\\n=============================="
[1e7eaab]82
83# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
[49c6891]84PROGRAMDIR=$(readlink -e $(dirname "$0"))
[35b0ef1]85PROGRAMNAME=$(basename "$0")
[07c3a59]86OPENGNSYS_SERVER="www.opengnsys.es"
[ec045b1]87DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads"
[1e7eaab]88if [ -d "$PROGRAMDIR/../installer" ]; then
[6ef01d9]89        USESVN=0
[1e7eaab]90else
[6ef01d9]91        USESVN=1
[1e7eaab]92fi
[1a2fa9d8]93SVN_URL="http://$OPENGNSYS_SERVER/svn/branches/version1.1/"
[1e7eaab]94
[a01156a]95WORKDIR=/tmp/opengnsys_installer
[1e7eaab]96mkdir -p $WORKDIR
97
[5f21d34]98# Directorio destino de OpenGnsys.
[1e7eaab]99INSTALL_TARGET=/opt/opengnsys
[42a0e41]100
101# Registro de incidencias.
102OGLOGFILE=$INSTALL_TARGET/log/${PROGRAMNAME%.sh}.log
[acfb07d]103LOG_FILE=/tmp/$(basename $OGLOGFILE)
[a01156a]104
[fd021b0]105# Usuario del cliente para acceso remoto.
106OPENGNSYS_CLIENT_USER="opengnsys"
107
108# Nombre de la base datos y fichero SQL para su creación.
109OPENGNSYS_DATABASE="ogAdmBD"
110OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/${OPENGNSYS_DATABASE}.sql
[3aaf91d]111
[a01156a]112
113#####################################################################
[d168a46]114####### Funciones de configuración
115#####################################################################
116
117# Generar variables de configuración del instalador
118# Variables globales:
[5cc52295]119# - OSDISTRIB, OSVERSION - tipo y versión de la distribución GNU/Linux
[d168a46]120# - DEPENDENCIES - array de dependencias que deben estar instaladas
121# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKGS - comandos para gestión de paquetes
[109e8b2]122# - INSTALLEXTRADEPS - instalar dependencias no incluidas en la distribución
[53fba30]123# - STARTSERVICE, ENABLESERVICE - iniciar y habilitar un servicio
[109e8b2]124# - STOPSERVICE, DISABLESERVICE - parar y deshabilitar un servicio
[53fba30]125# - APACHESERV, APACHECFGDIR, APACHESITESDIR, APACHEUSER, APACHEGROUP - servicio y configuración de Apache
[7825e9e]126# - APACHESSLMOD, APACHEENABLESSL, APACHEMAKECERT - habilitar módulo Apache y certificado SSL
[5f21d34]127# - APACHEENABLEOG, APACHEOGSITE, - habilitar sitio web de OpenGnsys
[53fba30]128# - INETDSERV - servicio Inetd
[09ac3b8]129# - FIREWALLSERV - servicio de cortabuegos IPTables/FirewallD
[53fba30]130# - DHCPSERV, DHCPCFGDIR - servicio y configuración de DHCP
[0f8100d]131# - MYSQLSERV, TMPMYCNF - servicio MySQL y fichero temporal con credenciales de acceso
132# - MARIADBSERV - servicio MariaDB (sustituto de MySQL en algunas distribuciones)
[e70925a]133# - RSYNCSERV, RSYNCCFGDIR - servicio y configuración de Rsync
[53fba30]134# - SAMBASERV, SAMBACFGDIR - servicio y configuración de Samba
[297df16]135# - TFTPSERV, TFTPCFGDIR, SYSLINUXDIR - servicio y configuración de TFTP/PXE
[d168a46]136function autoConfigure()
137{
[44f6582]138# Detectar sistema operativo del servidor (compatible con fichero os-release y con LSB).
139if [ -f /etc/os-release ]; then
140        source /etc/os-release
[eb7b39d]141        OSDISTRIB="$ID"
[5cc52295]142        OSVERSION="$VERSION_ID"
[44f6582]143else
144        OSDISTRIB=$(lsb_release -is 2>/dev/null)
[5cc52295]145        OSVERSION=$(lsb_release -rs 2>/dev/null)
[44f6582]146fi
[5cc52295]147# Convertir distribución a minúsculas y obtener solo el 1er número de versión.
[eb7b39d]148OSDISTRIB="${OSDISTRIB,,}"
[5cc52295]149OSVERSION="${OSVERSION%%.*}"
[d168a46]150
[eb7b39d]151# Configuración según la distribución GNU/Linux (usar minúsculas).
[d168a46]152case "$OSDISTRIB" in
[eb7b39d]153        ubuntu|debian|linuxmint)
[3554392]154                DEPENDENCIES=( subversion apache2 php5 php5-ldap libapache2-mod-php5 mysql-server php5-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa syslinux xinetd build-essential g++-multilib libmysqlclient15-dev wget doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php5-curl gettext moreutils jq )
[d168a46]155                UPDATEPKGLIST="apt-get update"
156                INSTALLPKG="apt-get -y install --force-yes"
157                CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install"
[53fba30]158                if which service &>/dev/null; then
[7ba85a4]159                        STARTSERVICE="eval service \$service restart"
[109e8b2]160                        STOPSERVICE="eval service \$service stop"
[53fba30]161                else
[7ba85a4]162                        STARTSERVICE="eval /etc/init.d/\$service restart"
[109e8b2]163                        STOPSERVICE="eval /etc/init.d/\$service stop"
[53fba30]164                fi
[7ba85a4]165                ENABLESERVICE="eval update-rc.d \$service defaults"
[109e8b2]166                DISABLESERVICE="eval update-rc.d \$service disable"
[53fba30]167                APACHESERV=apache2
[d168a46]168                APACHECFGDIR=/etc/apache2
[643ca8c]169                APACHESITESDIR=sites-available
[53fba30]170                APACHEOGSITE=opengnsys
[d168a46]171                APACHEUSER="www-data"
172                APACHEGROUP="www-data"
[7ba85a4]173                APACHESSLMOD="a2enmod ssl"
[7829e4e]174                APACHEREWRITEMOD="a2enmod rewrite"
[7ba85a4]175                APACHEENABLESSL="a2ensite default-ssl"
[53fba30]176                APACHEENABLEOG="a2ensite $APACHEOGSITE"
[643ca8c]177                APACHEMAKECERT="make-ssl-cert generate-default-snakeoil --force-overwrite"
[53fba30]178                DHCPSERV=isc-dhcp-server
[83518d5]179                DHCPCFGDIR=/etc/dhcp
[f243a47]180                INETDSERV=xinetd
181                INETDCFGDIR=/etc/xinetd.d
[53fba30]182                MYSQLSERV=mysql
[0f8100d]183                MARIADBSERV=mariadb
[e70925a]184                RSYNCSERV=rsync
185                RSYNCCFGDIR=/etc
[53fba30]186                SAMBASERV=smbd
[d168a46]187                SAMBACFGDIR=/etc/samba
[297df16]188                SYSLINUXDIR=/usr/lib/syslinux
[d168a46]189                TFTPCFGDIR=/var/lib/tftpboot
190                ;;
[eb7b39d]191        fedora|centos)
[3554392]192                DEPENDENCIES=( subversion httpd mod_ssl php php-ldap mysql-server mysql-devel mysql-devel.i686 php-mysql dhcp tftp-server tftp syslinux xinetd binutils gcc gcc-c++ glibc-devel glibc-devel.i686 glibc-static glibc-static.i686 libstdc++ libstdc++.i686 libstdc++-devel.i686 make wget doxygen graphviz ctorrent samba samba-client rsync unzip debootstrap schroot squashfs-tools python-crypto arp-scan gettext moreutils jq )
[109e8b2]193                INSTALLEXTRADEPS=( 'rpm -Uv ftp://ftp.altlinux.org/pub/distributions/ALTLinux/5.1/branch/files/i586/RPMS/netpipes-4.2-alt1.i586.rpm'
[b8969db]194                                   'pushd /tmp; wget -t3 http://download.bittornado.com/download/BitTornado-0.3.18.tar.gz && tar xvzf BitTornado-0.3.18.tar.gz && cd BitTornado-CVS && python setup.py install && ln -fs btlaunchmany.py /usr/bin/btlaunchmany && ln -fs bttrack.py /usr/bin/bttrack; popd' )
[eb7b39d]195                if [ "$OSDISTRIB" == "centos" ]; then
[03cfd6e]196                        UPDATEPKGLIST='test rpm -q --quiet epel-release || echo -e "[epel]\nname=EPEL temporal\nmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-\$releasever&arch=\$basearch\nenabled=1\ngpgcheck=0" >/etc/yum.repos.d/epel.repo'
197                fi
[d168a46]198                INSTALLPKG="yum install -y"
[c79a2b3]199                CHECKPKG="rpm -q --quiet \$package"
[03cfd6e]200                SYSTEMD=$(which systemctl 2>/dev/null)
201                if [ -n "$SYSTEMD" ]; then
202                        STARTSERVICE="eval systemctl start \$service.service"
203                        STOPSERVICE="eval systemctl stop \$service.service"
204                        ENABLESERVICE="eval systemctl enable \$service.service"
205                        DISABLESERVICE="eval systemctl disable \$service.service"
206                else
207                        STARTSERVICE="eval service \$service start"
208                        STOPSERVICE="eval service \$service stop"
209                        ENABLESERVICE="eval chkconfig \$service on"
210                        DISABLESERVICE="eval chkconfig \$service off"
211                fi
[53fba30]212                APACHESERV=httpd
[d168a46]213                APACHECFGDIR=/etc/httpd/conf.d
[53fba30]214                APACHEOGSITE=opengnsys.conf
[d168a46]215                APACHEUSER="apache"
216                APACHEGROUP="apache"
[5f21d34]217                APACHEREWRITEMOD="sed -i '/rewrite/s/^#//' $APACHECFGDIR/../*.conf"
[53fba30]218                DHCPSERV=dhcpd
[d168a46]219                DHCPCFGDIR=/etc/dhcp
[09ac3b8]220                if firewall-cmd --state &>/dev/null; then
221                        FIREWALLSERV=firewalld
222                else
223                        FIREWALLSERV=iptables
224                fi
[53fba30]225                INETDSERV=xinetd
[f243a47]226                INETDCFGDIR=/etc/xinetd.d
[53fba30]227                MYSQLSERV=mysqld
[0f8100d]228                MARIADBSERV=mariadb
[e70925a]229                RSYNCSERV=rsync
230                RSYNCCFGDIR=/etc
[53fba30]231                SAMBASERV=smb
[d168a46]232                SAMBACFGDIR=/etc/samba
[297df16]233                SYSLINUXDIR=/usr/share/syslinux
[53fba30]234                TFTPSERV=tftp
[d168a46]235                TFTPCFGDIR=/var/lib/tftpboot
236                ;;
237        "")     echo "ERROR: Unknown Linux distribution, please install \"lsb_release\" command."
238                exit 1 ;;
[5f21d34]239        *)      echo "ERROR: Distribution not supported by OpenGnsys."
[d168a46]240                exit 1 ;;
241esac
[09bf701]242
243# Fichero de credenciales de acceso a MySQL.
244TMPMYCNF=/tmp/.my.cnf.$$
[d168a46]245}
246
[09ac3b8]247
[ff6c349]248# Modificar variables de configuración tras instalar paquetes del sistema.
249function autoConfigurePost()
250{
[09ac3b8]251local f
252
[44f6582]253# Configuraciones específicas para Samba y TFTP en Debian 6.
254[ -z "$SYSTEMD" -a ! -e /etc/init.d/$SAMBASERV ] && SAMBASERV=samba
255[ ! -e $TFTPCFGDIR ] && TFTPCFGDIR=/srv/tftp
256
[09ac3b8]257# Configuraciones específicas para SELinux permisivo en distintas versiones.
[44f6582]258[ -f /selinux/enforce ] && echo 0 > /selinux/enforce
[e5f9c147]259for f in /etc/sysconfig/selinux /etc/selinux/config; do
[4fdf2b1]260        [ -f $f ] && perl -pi -e 's/SELINUX=enforcing/SELINUX=permissive/g' $f
[09ac3b8]261done
262selinuxenabled 2>/dev/null && setenforce 0 2>/dev/null
[ff6c349]263}
264
265
[83518d5]266# Cargar lista de paquetes del sistema y actualizar algunas variables de configuración
267# dependiendo de la versión instalada.
268function updatePackageList()
269{
[ad69c61]270local DHCPVERSION PHP5VERSION
[83518d5]271
272# Si es necesario, actualizar la lista de paquetes disponibles.
273[ -n "$UPDATEPKGLIST" ] && eval $UPDATEPKGLIST
274
275# Configuración personallizada de algunos paquetes.
276case "$OSDISTRIB" in
[eb7b39d]277        ubuntu|linuxmint)       # Postconfiguación personalizada para Ubuntu.
[83518d5]278                # Configuración para DHCP v3.
[e4b1572]279                DHCPVERSION=$(apt-cache show $(apt-cache pkgnames|egrep "dhcp.?-server$") | \
[83518d5]280                              awk '/Version/ {print substr($2,1,1);}' | \
281                              sort -n | tail -1)
282                if [ $DHCPVERSION = 3 ]; then
[e4b1572]283                        DEPENDENCIES=( ${DEPENDENCIES[@]/isc-dhcp-server/dhcp3-server} )
[53fba30]284                        DHCPSERV=dhcp3-server
[83518d5]285                        DHCPCFGDIR=/etc/dhcp3
286                fi
[ad69c61]287                # Configuración para PHP 5 en Ubuntu 16.x+.
288                if [ -z "$(apt-cache pkgnames php5)" ]; then
[668f7dc]289                        eval $INSTALLPKG software-properties-common
[21f78d1]290                        add-apt-repository -y ppa:ondrej/php
[668f7dc]291                        eval $UPDATEPKGLIST
[ad69c61]292                fi
[21f78d1]293                PHP5VERSION=$(apt-cache pkgnames php5 | sort | head -1)
294                DEPENDENCIES=( ${DEPENDENCIES[@]//php5/$PHP5VERSION} )
[ad69c61]295                # Dependencias correctas para libmysqlclient.
[21f78d1]296                [ -z "$(apt-cache pkgnames libmysqlclient15)" ] && DEPENDENCIES=( ${DEPENDENCIES[@]//libmysqlclient15/libmysqlclient} )
[83518d5]297                ;;
[eb7b39d]298        centos) # Postconfiguación personalizada para CentOS.
[c525453]299                # Incluir repositorio de paquetes EPEL y paquetes específicos.
300                DEPENDENCIES=( ${DEPENDENCIES[@]} epel-release procps )
[2c8b9ed]301                # Cambios a aplicar a partir de CentOS 7.
302                if [ $OSVERSION -ge 7 ]; then
303                        # Sustituir MySQL por MariaDB.
304                        DEPENDENCIES=( ${DEPENDENCIES[*]/mysql-/mariadb-} )
305                        # Instalar arp-scan de CentOS 6 (no disponible en CentOS 7).
306                        DEPENDENCIES=( ${DEPENDENCIES[*]/arp-scan/http://dag.wieers.com/redhat/el6/en/$(arch)/dag/RPMS/arp-scan-1.9-1.el6.rf.$(arch).rpm} )
307                fi
[c525453]308                ;;
[eb7b39d]309        fedora) # Postconfiguación personalizada para Fedora.
[c525453]310                # Incluir paquetes específicos.
311                DEPENDENCIES=( ${DEPENDENCIES[@]} libstdc++-static.i686 btrfs-progs procps-ng )
[5cc52295]312                # Sustituir MySQL por MariaDB a partir de Fedora 20.
313                [ $OSVERSION -ge 20 ] && DEPENDENCIES=( ${DEPENDENCIES[*]/mysql-/mariadb-} )
[c79a2b3]314                ;;
[83518d5]315esac
316}
317
[d168a46]318
319#####################################################################
[a01156a]320####### Algunas funciones útiles de propósito general:
321#####################################################################
[d168a46]322
[13a01a7]323function getDateTime()
[a01156a]324{
[d168a46]325        date "+%Y%m%d-%H%M%S"
[a01156a]326}
327
328# Escribe a fichero y muestra por pantalla
[13a01a7]329function echoAndLog()
[a01156a]330{
[d168a46]331        local DATETIME=`getDateTime`
[87c7b02]332        echo "$1"
[d168a46]333        echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE
[a01156a]334}
335
[87c7b02]336# Escribe a fichero y muestra mensaje de error
[13a01a7]337function errorAndLog()
[a01156a]338{
[d168a46]339        local DATETIME=`getDateTime`
[87c7b02]340        echo "ERROR: $1"
[d168a46]341        echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
[a01156a]342}
343
[346eaee]344# Escribe a fichero y muestra mensaje de aviso
345function warningAndLog()
346{
347        local DATETIME=`getDateTime`
[cd86637]348        echo "Warning: $1"
[346eaee]349        echo "$DATETIME;$SSH_CLIENT;Warning: $1" >> $LOG_FILE
350}
351
[87c7b02]352# Comprueba si el elemento pasado en $2 está en el array $1
[13a01a7]353function isInArray()
[a01156a]354{
355        if [ $# -ne 2 ]; then
[13a01a7]356                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]357                exit 1
358        fi
359
360        local deps
[87c7b02]361        local is_in_array=1
362        local element="$2"
363
364        echoAndLog "${FUNCNAME}(): checking if $2 is in $1"
[5c33840]365        eval "deps=( \"\${$1[@]}\" )"
[a01156a]366
[87c7b02]367        # Copia local del array del parámetro 1.
368        for (( i = 0 ; i < ${#deps[@]} ; i++ )); do
369                if [ "${deps[$i]}" = "${element}" ]; then
370                        echoAndLog "isInArray(): $element found in array"
[a01156a]371                        is_in_array=0
372                fi
373        done
374
375        if [ $is_in_array -ne 0 ]; then
[87c7b02]376                echoAndLog "${FUNCNAME}(): $element NOT found in array"
[a01156a]377        fi
378
379        return $is_in_array
380}
381
[87c7b02]382
[a01156a]383#####################################################################
384####### Funciones de manejo de paquetes Debian
385#####################################################################
386
[13a01a7]387function checkPackage()
[a01156a]388{
389        package=$1
390        if [ -z $package ]; then
[73cfa0a]391                errorAndLog "${FUNCNAME}(): parameter required"
[a01156a]392                exit 1
393        fi
[73cfa0a]394        echoAndLog "${FUNCNAME}(): checking if package $package exists"
[d168a46]395        eval $CHECKPKG
[a01156a]396        if [ $? -eq 0 ]; then
[73cfa0a]397                echoAndLog "${FUNCNAME}(): package $package exists"
[a01156a]398                return 0
399        else
[73cfa0a]400                echoAndLog "${FUNCNAME}(): package $package doesn't exists"
[a01156a]401                return 1
402        fi
403}
404
[87c7b02]405# Recibe array con dependencias
[a01156a]406# por referencia deja un array con las dependencias no resueltas
407# devuelve 1 si hay alguna dependencia no resuelta
[13a01a7]408function checkDependencies()
[a01156a]409{
410        if [ $# -ne 2 ]; then
[73cfa0a]411                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]412                exit 1
413        fi
414
[73cfa0a]415        echoAndLog "${FUNCNAME}(): checking dependences"
[a01156a]416        uncompletedeps=0
417
418        # copia local del array del parametro 1
419        local deps
[5c33840]420        eval "deps=( \"\${$1[@]}\" )"
[a01156a]421
422        declare -a local_notinstalled
[5c33840]423
[a01156a]424        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
425        do
426                checkPackage ${deps[$i]}
427                if [ $? -ne 0 ]; then
428                        local_notinstalled[$uncompletedeps]=$package
429                        let uncompletedeps=uncompletedeps+1
430                fi
431        done
432
433        # relleno el array especificado en $2 por referencia
434        for (( i = 0 ; i < ${#local_notinstalled[@]} ; i++ ))
435        do
436                eval "${2}[$i]=${local_notinstalled[$i]}"
437        done
438
439        # retorna el numero de paquetes no resueltos
[73cfa0a]440        echoAndLog "${FUNCNAME}(): dependencies uncompleted: $uncompletedeps"
[a01156a]441        return $uncompletedeps
442}
443
444# Recibe un array con las dependencias y lo instala
[13a01a7]445function installDependencies()
[a01156a]446{
447        if [ $# -ne 1 ]; then
[813f617]448                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]449                exit 1
450        fi
[813f617]451        echoAndLog "${FUNCNAME}(): installing uncompleted dependencies"
[a01156a]452
453        # copia local del array del parametro 1
454        local deps
[5c33840]455        eval "deps=( \"\${$1[@]}\" )"
[a01156a]456
457        local string_deps=""
458        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
459        do
460                string_deps="$string_deps ${deps[$i]}"
461        done
462
463        if [ -z "${string_deps}" ]; then
[813f617]464                errorAndLog "${FUNCNAME}(): array of dependeces is empty"
[a01156a]465                exit 1
466        fi
467
[c79a2b3]468        OLD_DEBIAN_FRONTEND=$DEBIAN_FRONTEND            # Debian/Ubuntu
[a01156a]469        export DEBIAN_FRONTEND=noninteractive
470
[d168a46]471        echoAndLog "${FUNCNAME}(): now $string_deps will be installed"
472        eval $INSTALLPKG $string_deps
[a01156a]473        if [ $? -ne 0 ]; then
[813f617]474                errorAndLog "${FUNCNAME}(): error installing dependencies"
[a01156a]475                return 1
476        fi
477
[c79a2b3]478        DEBIAN_FRONTEND=$OLD_DEBIAN_FRONTEND            # Debian/Ubuntu
[8244351]479        test grep -q "EPEL temporal" /etc/yum.repos.d/epel.repo 2>/dev/null ] || mv -f /etc/yum.repos.d/epel.repo.rpmnew /etc/yum.repos.d/epel.repo 2>/dev/null # CentOS/RedHat EPEL
[c79a2b3]480
[813f617]481        echoAndLog "${FUNCNAME}(): dependencies installed"
[a01156a]482}
483
[13a01a7]484# Hace un backup del fichero pasado por parámetro
485# deja un -last y uno para el día
486function backupFile()
487{
488        if [ $# -ne 1 ]; then
489                errorAndLog "${FUNCNAME}(): invalid number of parameters"
490                exit 1
491        fi
492
[d168a46]493        local file="$1"
494        local dateymd=`date +%Y%m%d`
[13a01a7]495
[d168a46]496        if [ ! -f "$file" ]; then
[346eaee]497                warningAndLog "${FUNCNAME}(): file $file doesn't exists"
[13a01a7]498                return 1
499        fi
500
[d168a46]501        echoAndLog "${FUNCNAME}(): making $file backup"
[13a01a7]502
503        # realiza una copia de la última configuración como last
[d168a46]504        cp -a "$file" "${file}-LAST"
[13a01a7]505
506        # si para el día no hay backup lo hace, sino no
[d168a46]507        if [ ! -f "${file}-${dateymd}" ]; then
508                cp -a "$file" "${file}-${dateymd}"
[13a01a7]509        fi
510
[d168a46]511        echoAndLog "${FUNCNAME}(): $file backup success"
[13a01a7]512}
513
[a01156a]514#####################################################################
515####### Funciones para el manejo de bases de datos
516#####################################################################
517
518# This function set password to root
[13a01a7]519function mysqlSetRootPassword()
[a01156a]520{
521        if [ $# -ne 1 ]; then
[813f617]522                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]523                exit 1
524        fi
525
[e0edc14]526        local root_mysql="$1"
[813f617]527        echoAndLog "${FUNCNAME}(): setting root password in MySQL server"
[e0edc14]528        mysqladmin -u root password "$root_mysql"
[a01156a]529        if [ $? -ne 0 ]; then
[813f617]530                errorAndLog "${FUNCNAME}(): error while setting root password in MySQL server"
[a01156a]531                return 1
532        fi
[813f617]533        echoAndLog "${FUNCNAME}(): root password saved!"
[a01156a]534        return 0
535}
536
[892606b9]537# Si el servicio mysql esta ya instalado cambia la variable de la clave del root por la ya existente
[e0edc14]538function mysqlGetRootPassword()
539{
[892606b9]540        local pass_mysql
541        local pass_mysql2
[7c54b49]542        # Comprobar si MySQL está instalado con la clave de root por defecto.
543        if mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<<"quit" 2>/dev/null; then
544                echoAndLog "${FUNCNAME}(): Using default mysql root password."
545        else
546                stty -echo
[e0edc14]547                echo "There is a MySQL service already installed."
548                read -p "Enter MySQL root password: " pass_mysql
[7c54b49]549                echo ""
[e0edc14]550                read -p "Confrim password:" pass_mysql2
[7c54b49]551                echo ""
552                stty echo
553                if [ "$pass_mysql" == "$pass_mysql2" ] ;then
[e0edc14]554                        MYSQL_ROOT_PASSWORD="$pass_mysql"
[7c54b49]555                        return 0
556                else
[e0edc14]557                        echo "The keys don't match. Do not configure the server's key,"
558                        echo "transactions in the database will give error."
[7c54b49]559                        return 1
560                fi
[892606b9]561        fi
562}
563
[a01156a]564# comprueba si puede conectar con mysql con el usuario root
565function mysqlTestConnection()
566{
567        if [ $# -ne 1 ]; then
[e0edc14]568                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]569                exit 1
570        fi
571
[09bf701]572        local root_password="$1"
[e0edc14]573        echoAndLog "${FUNCNAME}(): checking connection to mysql..."
[09bf701]574        # Componer fichero con credenciales de conexión a MySQL.
575        touch $TMPMYCNF
576        chmod 600 $TMPMYCNF
577        cat << EOT > $TMPMYCNF
[c073224]578[client]
[09bf701]579user=root
580password=$root_password
581EOT
582        # Borrar el fichero temporal si termina el proceso de instalación.
583        trap "rm -f $TMPMYCNF" 0 1 2 3 6 9 15
584        # Comprobar conexión a MySQL.
585        echo "" | mysql --defaults-extra-file=$TMPMYCNF
[a01156a]586        if [ $? -ne 0 ]; then
[e0edc14]587                errorAndLog "${FUNCNAME}(): connection to mysql failed, check root password and if daemon is running!"
[a01156a]588                return 1
589        else
[e0edc14]590                echoAndLog "${FUNCNAME}(): connection success"
[a01156a]591                return 0
592        fi
593}
594
595# comprueba si la base de datos existe
596function mysqlDbExists()
597{
[09bf701]598        if [ $# -ne 1 ]; then
[e0edc14]599                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]600                exit 1
601        fi
602
[09bf701]603        local database="$1"
[e0edc14]604        echoAndLog "${FUNCNAME}(): checking if $database exists..."
[09bf701]605        echo "show databases" | mysql --defaults-extra-file=$TMPMYCNF | grep "^${database}$"
[a01156a]606        if [ $? -ne 0 ]; then
[e0edc14]607                echoAndLog "${FUNCNAME}():database $database doesn't exists"
[a01156a]608                return 1
609        else
[e0edc14]610                echoAndLog "${FUNCNAME}():database $database exists"
[a01156a]611                return 0
612        fi
613}
614
[0a735488]615# Comprueba si la base de datos está vacía.
[a01156a]616function mysqlCheckDbIsEmpty()
617{
[09bf701]618        if [ $# -ne 1 ]; then
[e0edc14]619                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]620                exit 1
621        fi
622
[09bf701]623        local database="$1"
[e0edc14]624        echoAndLog "${FUNCNAME}(): checking if $database is empty..."
[09bf701]625        num_tablas=`echo "show tables" | mysql --defaults-extra-file=$TMPMYCNF "${database}" | wc -l`
[a01156a]626        if [ $? -ne 0 ]; then
[e0edc14]627                errorAndLog "${FUNCNAME}(): error executing query, check database and root password"
[a01156a]628                exit 1
629        fi
630
631        if [ $num_tablas -eq 0 ]; then
[e0edc14]632                echoAndLog "${FUNCNAME}():database $database is empty"
[a01156a]633                return 0
634        else
[e0edc14]635                echoAndLog "${FUNCNAME}():database $database has tables"
[a01156a]636                return 1
637        fi
638
639}
640
[0a735488]641# Importa un fichero SQL en la base de datos.
642# Parámetros:
643# - 1: nombre de la BD.
644# - 2: fichero a importar.
645# Nota: el fichero SQL puede contener las siguientes palabras reservadas:
646# - SERVERIP: se sustituye por la dirección IP del servidor.
647# - DBUSER: se sustituye por usuario de conexión a la BD definido en este script.
648# - DBPASSWD: se sustituye por la clave de conexión a la BD definida en este script.
[a01156a]649function mysqlImportSqlFileToDb()
650{
[09bf701]651        if [ $# -ne 2 ]; then
[c5ce04c]652                errorAndLog "${FNCNAME}(): invalid number of parameters"
[a01156a]653                exit 1
654        fi
655
[09bf701]656        local database="$1"
657        local sqlfile="$2"
[c4321ae]658        local tmpfile=$(mktemp)
[d168a46]659        local i=0
660        local dev=""
[c4321ae]661        local status
[8e0f770]662        # Claves aleatorias para acceso a las APIs REST.
[7829e4e]663        local OPENGNSYS_APIKEY=$(php -r 'echo md5(uniqid(rand(), true));')
[f9b5714]664        OPENGNSYS_REPOKEY=$(php -r 'echo md5(uniqid(rand(), true));')
[a01156a]665
666        if [ ! -f $sqlfile ]; then
[c5ce04c]667                errorAndLog "${FUNCNAME}(): Unable to locate $sqlfile!!"
[a01156a]668                return 1
669        fi
670
[d168a46]671        echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..."
[c4321ae]672        chmod 600 $tmpfile
[d168a46]673        for dev in ${DEVICE[*]}; do
[73a1bd6]674                if [ "${DEVICE[i]}" == "$DEFAULTDEV" ]; then
[d168a46]675                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
676                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
677                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
[7829e4e]678                            -e "s/APIKEY/$OPENGNSYS_APIKEY/g" \
[8e0f770]679                            -e "s/REPOKEY/$OPENGNSYS_REPOKEY/g" \
[d168a46]680                                $sqlfile > $tmpfile
681                fi
682                let i++
683        done
[09bf701]684        mysql --defaults-extra-file=$TMPMYCNF --default-character-set=utf8 "${database}" < $tmpfile
[c4321ae]685        status=$?
686        rm -f $tmpfile
687        if [ $status -ne 0 ]; then
[c5ce04c]688                errorAndLog "${FUNCNAME}(): error while importing $sqlfile in database $database"
[a01156a]689                return 1
690        fi
[c5ce04c]691        echoAndLog "${FUNCNAME}(): file imported to database $database"
[a01156a]692        return 0
693}
694
695# Crea la base de datos
696function mysqlCreateDb()
697{
[09bf701]698        if [ $# -ne 1 ]; then
[a555f49]699                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]700                exit 1
701        fi
702
[09bf701]703        local database="$1"
[a01156a]704
[a555f49]705        echoAndLog "${FUNCNAME}(): creating database..."
[09bf701]706        mysqladmin --defaults-extra-file=$TMPMYCNF create $database
[a01156a]707        if [ $? -ne 0 ]; then
[a555f49]708                errorAndLog "${FUNCNAME}(): error while creating database $database"
[a01156a]709                return 1
710        fi
[e47e131]711        # Quitar modo ONLY_FULL_GROUP_BY de MySQL (ticket #730).
712        mysql --defaults-extra-file=$TMPMYCNF -e "SET GLOBAL sql_mode=(SELECT TRIM(BOTH ',' FROM REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')));"
713
[a555f49]714        echoAndLog "${FUNCNAME}(): database $database created"
[a01156a]715        return 0
716}
717
[0a735488]718# Comprueba si ya está definido el usuario de acceso a la BD.
[a01156a]719function mysqlCheckUserExists()
720{
[09bf701]721        if [ $# -ne 1 ]; then
[e0edc14]722                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]723                exit 1
724        fi
725
[09bf701]726        local userdb="$1"
[a01156a]727
[e0edc14]728        echoAndLog "${FUNCNAME}(): checking if $userdb exists..."
[09bf701]729        echo "select user from user where user='${userdb}'\\G" |mysql --defaults-extra-file=$TMPMYCNF mysql | grep user
[a01156a]730        if [ $? -ne 0 ]; then
[e0edc14]731                echoAndLog "${FUNCNAME}(): user doesn't exists"
[a01156a]732                return 1
733        else
[e0edc14]734                echoAndLog "${FUNCNAME}(): user already exists"
[a01156a]735                return 0
736        fi
737
738}
739
740# Crea un usuario administrativo para la base de datos
741function mysqlCreateAdminUserToDb()
742{
[09bf701]743        if [ $# -ne 3 ]; then
[e0edc14]744                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]745                exit 1
746        fi
747
[09bf701]748        local database="$1"
749        local userdb="$2"
750        local passdb="$3"
[a01156a]751
[e0edc14]752        echoAndLog "${FUNCNAME}(): creating admin user ${userdb} to database ${database}"
[a01156a]753
754        cat > $WORKDIR/create_${database}.sql <<EOF
755GRANT USAGE ON *.* TO '${userdb}'@'localhost' IDENTIFIED BY '${passdb}' ;
756GRANT ALL PRIVILEGES ON ${database}.* TO '${userdb}'@'localhost' WITH GRANT OPTION ;
757FLUSH PRIVILEGES ;
758EOF
[09bf701]759        mysql --defaults-extra-file=$TMPMYCNF < $WORKDIR/create_${database}.sql
[a01156a]760        if [ $? -ne 0 ]; then
[e0edc14]761                errorAndLog "${FUNCNAME}(): error while creating user in mysql"
[a01156a]762                rm -f $WORKDIR/create_${database}.sql
763                return 1
764        else
[e0edc14]765                echoAndLog "${FUNCNAME}(): user created ok"
[a01156a]766                rm -f $WORKDIR/create_${database}.sql
767                return 0
768        fi
769}
770
771
772#####################################################################
773####### Funciones para el manejo de Subversion
774#####################################################################
775
[0a735488]776# Obtiene el código fuente del proyecto desde el servidor SVN.
[13a01a7]777function svnExportCode()
778{
779        if [ $# -ne 1 ]; then
780                errorAndLog "${FUNCNAME}(): invalid number of parameters"
781                exit 1
782        fi
783
[6090a2d]784        local url="$1"
[13a01a7]785
786        echoAndLog "${FUNCNAME}(): downloading subversion code..."
787
[6090a2d]788        svn export --force "$url" opengnsys
[13a01a7]789        if [ $? -ne 0 ]; then
[5f21d34]790                errorAndLog "${FUNCNAME}(): error getting OpenGnsys code from $url"
[13a01a7]791                return 1
792        fi
793        echoAndLog "${FUNCNAME}(): subversion code downloaded"
794        return 0
795}
796
797
[892606b9]798############################################################
[7586ca3]799###  Detectar red
800############################################################
801
[07c3a59]802# Comprobar si existe conexión.
803function checkNetworkConnection()
804{
[09ac3b8]805        echoAndLog "${FUNCNAME}(): Disabling Firewall: $FIREWALLSERV."
806        if [ -n "$FIREWALLSERV" ]; then
807                service=$FIREWALLSERV
[b83843c]808                $STOPSERVICE; $DISABLESERVICE
809        fi
[109e8b2]810
[5f21d34]811        echoAndLog "${FUNCNAME}(): Checking OpenGnsys server conectivity."
[07c3a59]812        OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"}
[225e859]813        if which wget &>/dev/null; then
814                wget --spider -q $OPENGNSYS_SERVER
815        elif which curl &>/dev/null; then
816                curl --connect-timeout 10 -s $OPENGNSYS_SERVER -o /dev/null
817        else
818                echoAndLog "${FUNCNAME}(): Cannot execute \"wget\" nor \"curl\"."
819                return 1
820        fi
[07c3a59]821}
822
823# Obtener los parámetros de red de la interfaz por defecto.
[7586ca3]824function getNetworkSettings()
825{
[d168a46]826        # Arrays globales definidas:
827        # - DEVICE:     nombres de dispositivos de red activos.
828        # - SERVERIP:   IPs locales del servidor.
829        # - NETIP:      IPs de redes.
830        # - NETMASK:    máscaras de red.
831        # - NETBROAD:   IPs de difusión de redes.
832        # - ROUTERIP:   IPs de routers.
833        # Otras variables globales:
834        # - DEFAULTDEV: dispositivo de red por defecto.
835        # - DNSIP:      IP del servidor DNS principal.
836
837        local i=0
838        local dev=""
839
[109e8b2]840        echoAndLog "${FUNCNAME}(): Detecting network parameters."
[d168a46]841        DEVICE=( $(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}') )
842        if [ -z "$DEVICE" ]; then
843                errorAndLog "${FUNCNAME}(): Network devices not detected."
[62e3bcf]844                exit 1
845        fi
[d168a46]846        for dev in ${DEVICE[*]}; do
847                SERVERIP[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
848                if [ -n "${SERVERIP[i]}" ]; then
[03cfd6e]849                        NETMASK[i]=$(LANG=C ifconfig $dev | \
850                                                awk '/Mask/ {sub(/.*:/,"",$4); print $4}
851                                                     /netmask/ {print $4}')
[d168a46]852                        NETBROAD[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {print ($6)}')
[826d576]853                        NETIP[i]=$(ip route | awk -v d="$dev" '$3==d && /src/ {sub (/\/.*/,""); print $1}')
854                        ROUTERIP[i]=$(ip route | awk -v d="$dev" '$1=="default" && $5==d {print $3}')
[d168a46]855                        DEFAULTDEV=${DEFAULTDEV:-"$dev"}
856                fi
[ce85ae8]857                let i++
[d168a46]858        done
[a555f49]859        DNSIP=$(awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n1)
[03cfd6e]860        if [ -z "${NETIP[*]}" -o -z "${NETMASK[*]}" ]; then
[62e3bcf]861                errorAndLog "${FUNCNAME}(): Network not detected."
[7586ca3]862                exit 1
863        fi
[cc7eab7]864
865        # Variables de ejecución de Apache
866        # - APACHE_RUN_USER
867        # - APACHE_RUN_GROUP
[d168a46]868        if [ -f $APACHECFGDIR/envvars ]; then
869                source $APACHECFGDIR/envvars
[cc7eab7]870        fi
[d168a46]871        APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"}
872        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
[73a1bd6]873
874        echoAndLog "${FUNCNAME}(): Default network device: $DEFAULTDEV."
[7586ca3]875}
876
877
878############################################################
[892606b9]879### Esqueleto para el Servicio pxe y contenedor tftpboot ###
880############################################################
881
[e0edc14]882function tftpConfigure()
883{
[109e8b2]884        echoAndLog "${FUNCNAME}(): Configuring TFTP service."
885        # Habilitar TFTP y reiniciar Inetd.
[8244351]886        if [ -n "$TFTPSERV" ]; then
[584b103]887                if [ -f $INETDCFGDIR/$TFTPSERV ]; then
888                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/$TFTPSERV
889                else
890                        service=$TFTPSERV
[b8969db]891                        $ENABLESERVICE; $STARTSERVICE
[584b103]892                fi
[8244351]893        fi
[53fba30]894        service=$INETDSERV
895        $ENABLESERVICE; $STARTSERVICE
[892606b9]896
[beaebf8]897        # Copiar ficheros de Syslinux.
[297df16]898        cp -a $SYSLINUXDIR $TFTPCFGDIR/syslinux
[beaebf8]899
[297df16]900        # comprobamos el servicio tftp
901        sleep 1
902        testPxe
[892606b9]903}
904
[0a735488]905# Comprueba que haya conexión al servicio TFTP/PXE.
[e0edc14]906function testPxe ()
907{
[297df16]908        echoAndLog "${FUNCNAME}(): Checking TFTP service... please wait."
[beaebf8]909        echo "test" >$TFTPCFGDIR/testpxe
910        tftp -v 127.0.0.1 -c get testpxe /tmp/testpxe && echoAndLog "TFTP service is OK." || errorAndLog "TFTP service is down."
911        rm -f $TFTPCFGDIR/testpxe /tmp/testpxe
[e4b1572]912}
913
914
915########################################################################
[5f21d34]916## Configuración servicio Samba
[8fc9552]917########################################################################
[e4b1572]918
919# Configurar servicios Samba.
[8fc9552]920function smbConfigure()
921{
[e0edc14]922        echoAndLog "${FUNCNAME}(): Configuring Samba service."
[8fc9552]923
[d168a46]924        backupFile $SAMBACFGDIR/smb.conf
[8fc9552]925       
[5f21d34]926        # Copiar plantailla de recursos para OpenGnsys
[c1e00e4]927        sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
[d168a46]928                $WORKDIR/opengnsys/server/etc/smb-og.conf.tmpl > $SAMBACFGDIR/smb-og.conf
[813f617]929        # Configurar y recargar Samba"
[5f21d34]930        perl -pi -e "s/WORKGROUP/OPENGNSYS/; s/server string \=.*/server string \= OpenGnsys Samba Server/" $SAMBACFGDIR/smb.conf
[03cfd6e]931        if ! grep -q "smb-og" $SAMBACFGDIR/smb.conf; then
932                echo "include = $SAMBACFGDIR/smb-og.conf" >> $SAMBACFGDIR/smb.conf
933        fi
[53fba30]934        service=$SAMBASERV
935        $ENABLESERVICE; $STARTSERVICE
[8fc9552]936        if [ $? -ne 0 ]; then
[813f617]937                errorAndLog "${FUNCNAME}(): error while configure Samba"
[8fc9552]938                return 1
939        fi
[eb9424f]940        # Crear clave para usuario de acceso a los recursos.
[813f617]941        echo -ne "$OPENGNSYS_CLIENT_PASSWD\n$OPENGNSYS_CLIENT_PASSWD\n" | smbpasswd -a -s $OPENGNSYS_CLIENT_USER
[8fc9552]942
[813f617]943        echoAndLog "${FUNCNAME}(): Added Samba configuration."
[8fc9552]944        return 0
945}
946
947
[b6906f7]948########################################################################
[5f21d34]949## Configuración servicio Rsync
[e70925a]950########################################################################
951
952# Configurar servicio Rsync.
953function rsyncConfigure()
954{
955        echoAndLog "${FUNCNAME}(): Configuring Rsync service."
956
957        backupFile $RSYNCCFGDIR/rsyncd.conf
958
959        # Configurar acceso a Rsync.
960        sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \
961                $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > $RSYNCCFGDIR/rsyncd.conf
962        sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \
963            -e "s/CLIENTPASSWORD/$OPENGNSYS_CLIENT_PASSWD/g" \
964                $WORKDIR/opengnsys/repoman/etc/rsyncd.secrets.tmpl > $RSYNCCFGDIR/rsyncd.secrets
965        chown root.root $RSYNCCFGDIR/rsyncd.secrets
966        chmod 600 $RSYNCCFGDIR/rsyncd.secrets
967
968        # Habilitar Rsync y reiniciar Inetd.
969        if [ -n "$RSYNCSERV" ]; then
[4666588]970                if [ -f /etc/default/rsync ]; then
971                        perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
972                fi
[f243a47]973                if [ -f $INETDCFGDIR/rsync ]; then
974                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
975                else
976                        cat << EOT > $INETDCFGDIR/rsync
977service rsync
978{
979        disable = no
980        socket_type = stream
981        wait = no
982        user = root
983        server = $(which rsync)
984        server_args = --daemon
985        log_on_failure += USERID
986        flags = IPv6
987}
988EOT
989                fi
[e70925a]990                service=$RSYNCSERV $ENABLESERVICE
991                service=$INETDSERV $STARTSERVICE
992        fi
993
994        echoAndLog "${FUNCNAME}(): Added Rsync configuration."
995        return 0
996}
997
998       
999########################################################################
[5f21d34]1000## Configuración servicio DHCP
[b6906f7]1001########################################################################
1002
[e4b1572]1003# Configurar servicios DHCP.
[7586ca3]1004function dhcpConfigure()
1005{
[836a7597]1006        echoAndLog "${FUNCNAME}(): Sample DHCP configuration."
[a555f49]1007
[d168a46]1008        local errcode=0
1009        local i=0
1010        local dev=""
1011
1012        backupFile $DHCPCFGDIR/dhcpd.conf
1013        for dev in ${DEVICE[*]}; do
[01a9904]1014                if [ -n "${SERVERIP[i]}" ]; then
[d168a46]1015                        backupFile $DHCPCFGDIR/dhcpd-$dev.conf
[e4b1572]1016                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1017                            -e "s/NETIP/${NETIP[i]}/g" \
1018                            -e "s/NETMASK/${NETMASK[i]}/g" \
1019                            -e "s/NETBROAD/${NETBROAD[i]}/g" \
1020                            -e "s/ROUTERIP/${ROUTERIP[i]}/g" \
[d168a46]1021                            -e "s/DNSIP/$DNSIP/g" \
1022                            $WORKDIR/opengnsys/server/etc/dhcpd.conf.tmpl > $DHCPCFGDIR/dhcpd-$dev.conf || errcode=1
1023                fi
1024                let i++
1025        done
1026        if [ $errcode -ne 0 ]; then
[b25fc47]1027                errorAndLog "${FUNCNAME}(): error while configuring DHCP server"
[a555f49]1028                return 1
1029        fi
[d168a46]1030        ln -f $DHCPCFGDIR/dhcpd-$DEFAULTDEV.conf $DHCPCFGDIR/dhcpd.conf
[53fba30]1031        service=$DHCPSERV
1032        $ENABLESERVICE; $STARTSERVICE
[d168a46]1033        echoAndLog "${FUNCNAME}(): Sample DHCP configured in \"$DHCPCFGDIR\"."
[a555f49]1034        return 0
[892606b9]1035}
1036
1037
[a01156a]1038#####################################################################
1039####### Funciones específicas de la instalación de Opengnsys
1040#####################################################################
1041
[5f21d34]1042# Copiar ficheros del OpenGnsys Web Console.
[7586ca3]1043function installWebFiles()
1044{
[2b793a8]1045        local COMPATDIR f
[7829e4e]1046        local XAJAXFILE="xajax_0.5_standard.zip"
1047        local SLIMFILE="slim-2.6.1.zip"
[8b8e948]1048        local SWAGGERFILE="swagger-ui-2.2.5.zip"
[2b793a8]1049
[dce072b]1050        echoAndLog "${FUNCNAME}(): Installing web files..."
[2b793a8]1051        # Copiar ficheros.
1052        cp -a $WORKDIR/opengnsys/admin/WebConsole/* $INSTALL_TARGET/www   #*/ comentario para Doxygen.
[7586ca3]1053        if [ $? != 0 ]; then
[dce072b]1054                errorAndLog "${FUNCNAME}(): Error copying web files."
[7586ca3]1055                exit 1
1056        fi
1057        find $INSTALL_TARGET/www -name .svn -type d -exec rm -fr {} \; 2>/dev/null
[7829e4e]1058
[8b8e948]1059        # Descomprimir librerías: XAJAX, Slim y Swagger-UI.
[7829e4e]1060        unzip -o $WORKDIR/opengnsys/admin/$XAJAXFILE -d $INSTALL_TARGET/www/xajax
1061        unzip -o $WORKDIR/opengnsys/admin/$SLIMFILE -d $INSTALL_TARGET/www/rest
[8b8e948]1062        unzip -o $WORKDIR/opengnsys/admin/$SWAGGERFILE -d $INSTALL_TARGET/www/rest
[7829e4e]1063
[2b793a8]1064        # Compatibilidad con dispositivos móviles.
1065        COMPATDIR="$INSTALL_TARGET/www/principal"
1066        for f in acciones administracion aula aulas hardwares imagenes menus repositorios softwares; do
1067                sed 's/clickcontextualnodo/clicksupnodo/g' $COMPATDIR/$f.php > $COMPATDIR/$f.device.php
1068        done
1069        cp -a $COMPATDIR/imagenes.device.php $COMPATDIR/imagenes.device4.php
[7586ca3]1070        # Cambiar permisos para ficheros especiales.
[e6d22c6]1071        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
[b7bd0df]1072        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/tmp/
[aad50e2]1073        # Fichero de logs del agente OGAgent.
[b1735a7]1074        touch $INSTALL_TARGET/log/ogagent.log
1075        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/log/ogagent.log
[2b793a8]1076
[dce072b]1077        echoAndLog "${FUNCNAME}(): Web files installed successfully."
[7586ca3]1078}
1079
[ec045b1]1080# Copiar ficheros en la zona de descargas de OpenGnsys Web Console.
1081function installDownloadableFiles()
1082{
1083        local FILENAME=ogagentpkgs-$INSTVERSION.tar.gz
1084        local TARGETFILE=$WORKDIR/$FILENAME
1085 
1086        # Descargar archivo comprimido, si es necesario.
1087        if [ -s $PROGRAMDIR/$FILENAME ]; then
1088                echoAndLog "${FUNCNAME}(): Moving $PROGRAMDIR/$FILENAME file to $(dirname $TARGETFILE)"
1089                mv $PROGRAMDIR/$FILENAME $TARGETFILE
1090        else
1091                echoAndLog "${FUNCNAME}(): Downloading $FILENAME"
1092                wget $DOWNLOADURL/$FILENAME -O $TARGETFILE
1093        fi
1094        if [ ! -s $TARGETFILE ]; then
1095                errorAndLog "${FUNCNAME}(): Cannot download $FILENAME"
1096                return 1
1097        fi
1098       
1099        # Descomprimir fichero en zona de descargas.
1100        tar xvzf $TARGETFILE -C $INSTALL_TARGET/www/descargas
1101        if [ $? != 0 ]; then
1102                errorAndLog "${FUNCNAME}(): Error uncompressing archive."
1103                exit 1
1104        fi
1105}
1106
[7586ca3]1107# Configuración específica de Apache.
[73a1bd6]1108function installWebConsoleApacheConf()
[a01156a]1109{
1110        if [ $# -ne 2 ]; then
[dce072b]1111                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]1112                exit 1
1113        fi
1114
[f9e3393]1115        local path_opengnsys_base="$1"
1116        local path_apache2_confd="$2"
[30837bb]1117        local CONSOLEDIR=${path_opengnsys_base}/www
[a01156a]1118
[892606b9]1119        if [ ! -d $path_apache2_confd ]; then
[dce072b]1120                errorAndLog "${FUNCNAME}(): path to apache2 conf.d can not found, verify your server installation"
[892606b9]1121                return 1
1122        fi
1123
[7586ca3]1124        mkdir -p $path_apache2_confd/{sites-available,sites-enabled}
[892606b9]1125
[dce072b]1126        echoAndLog "${FUNCNAME}(): creating apache2 config file.."
[a01156a]1127
[3ce53a7]1128        # Activar HTTPS.
[7825e9e]1129        $APACHESSLMOD
[643ca8c]1130        $APACHEENABLESSL
1131        $APACHEMAKECERT
[7829e4e]1132        # Activar módulo Rewrite.
1133        $APACHEREWRITEMOD
[30837bb]1134        # Genera configuración de consola web a partir del fichero plantilla.
[f9e3393]1135        if [ -n "$(apachectl -v | grep "2\.[0-2]")" ]; then
1136                # Configuración para versiones anteriores de Apache.
[6f4d39b]1137                sed -e "s,CONSOLEDIR,$CONSOLEDIR,g" \
[f3dde7e]1138                        $WORKDIR/opengnsys/server/etc/apache-prev2.4.conf.tmpl > $path_apache2_confd/$APACHESITESDIR/${APACHEOGSITE}
[f9e3393]1139        else
1140                # Configuración específica a partir de Apache 2.4
[6f4d39b]1141                sed -e "s,CONSOLEDIR,$CONSOLEDIR,g" \
[f3dde7e]1142                        $WORKDIR/opengnsys/server/etc/apache.conf.tmpl > $path_apache2_confd/$APACHESITESDIR/${APACHEOGSITE}.conf
[f9e3393]1143        fi
[643ca8c]1144        $APACHEENABLEOG
[a01156a]1145        if [ $? -ne 0 ]; then
[dce072b]1146                errorAndLog "${FUNCNAME}(): config file can't be linked to apache conf, verify your server installation"
[a01156a]1147                return 1
1148        fi
[103bc82]1149        echoAndLog "${FUNCNAME}(): config file created and linked, restarting apache daemon"
1150        service=$APACHESERV
1151        $ENABLESERVICE; $STARTSERVICE
1152        return 0
[a01156a]1153}
1154
[8fc9552]1155
[5d6bf97]1156# Crear documentación Doxygen para la consola web.
1157function makeDoxygenFiles()
1158{
1159        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
1160        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
1161                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
1162        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
1163                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files."
[ead38fb]1164                return 1
[5d6bf97]1165        fi
1166        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
1167        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api
1168        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully."
1169}
1170
1171
[a01156a]1172# Crea la estructura base de la instalación de opengnsys
[eb9424f]1173function createDirs()
[a01156a]1174{
1175        if [ $# -ne 1 ]; then
[dce072b]1176                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[a01156a]1177                exit 1
1178        fi
1179
[eb9424f]1180        local path_opengnsys_base="$1"
[a01156a]1181
[eb9424f]1182        # Crear estructura de directorios.
[dce072b]1183        echoAndLog "${FUNCNAME}(): creating directory paths in $path_opengnsys_base"
[a01156a]1184        mkdir -p $path_opengnsys_base
1185        mkdir -p $path_opengnsys_base/bin
[5c33840]1186        mkdir -p $path_opengnsys_base/client
[49c6891]1187        mkdir -p $path_opengnsys_base/doc
[5c33840]1188        mkdir -p $path_opengnsys_base/etc
[a01156a]1189        mkdir -p $path_opengnsys_base/lib
[1cc5697]1190        mkdir -p $path_opengnsys_base/log/clients
[eb9424f]1191        ln -fs $path_opengnsys_base/log /var/log/opengnsys
[7586ca3]1192        mkdir -p $path_opengnsys_base/sbin
[a01156a]1193        mkdir -p $path_opengnsys_base/www
[6f4d39b]1194        mkdir -p $path_opengnsys_base/images/group
[87c7b02]1195        mkdir -p $TFTPCFGDIR
[63fd1ba]1196        ln -fs $TFTPCFGDIR $path_opengnsys_base/tftpboot
[cfad47b]1197        mkdir -p $path_opengnsys_base/tftpboot/menu.lst
[a01156a]1198        if [ $? -ne 0 ]; then
[dce072b]1199                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
[a01156a]1200                return 1
1201        fi
1202
[eb9424f]1203        # Crear usuario ficticio.
1204        if id -u $OPENGNSYS_CLIENT_USER &>/dev/null; then
1205                echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENT_USER\" is already created"
1206        else
[5f21d34]1207                echoAndLog "${FUNCNAME}(): creating OpenGnsys user"
[eb9424f]1208                useradd $OPENGNSYS_CLIENT_USER 2>/dev/null
1209                if [ $? -ne 0 ]; then
[5f21d34]1210                        errorAndLog "${FUNCNAME}(): error creating OpenGnsys user"
[eb9424f]1211                        return 1
1212                fi
1213        fi
1214
1215        # Establecer los permisos básicos.
1216        echoAndLog "${FUNCNAME}(): setting directory permissions"
[5eb61a6]1217        chmod -R 775 $path_opengnsys_base/{log/clients,images}
1218        chown -R :$OPENGNSYS_CLIENT_USER $path_opengnsys_base/{log/clients,images}
[eb9424f]1219        if [ $? -ne 0 ]; then
1220                errorAndLog "${FUNCNAME}(): error while setting permissions"
1221                return 1
1222        fi
1223
[7669bca]1224        # Mover el fichero de registro de instalación al directorio de logs.
[acfb07d]1225        echoAndLog "${FUNCNAME}(): moving installation log file"
1226        mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
[7669bca]1227        chmod 600 $LOG_FILE
[acfb07d]1228
[dce072b]1229        echoAndLog "${FUNCNAME}(): directory paths created"
[a01156a]1230        return 0
1231}
1232
[463a1d49]1233# Copia ficheros de configuración y ejecutables genéricos del servidor.
[73a1bd6]1234function copyServerFiles ()
[e0edc14]1235{
[463a1d49]1236        if [ $# -ne 1 ]; then
[879689f]1237                errorAndLog "${FUNCNAME}(): invalid number of parameters"
[463a1d49]1238                exit 1
1239        fi
1240
[7caf5a7c]1241        local path_opengnsys_base="$1"
[463a1d49]1242
[a43e90d]1243        # Lista de ficheros y directorios origen y de directorios destino.
[cfad47b]1244        local SOURCES=( server/tftpboot \
[7caf5a7c]1245                        server/bin \
1246                        repoman/bin \
[3e7d77b]1247                        server/lib \
[42a0e41]1248                        admin/Sources/Services/ogAdmServerAux
1249                        admin/Sources/Services/ogAdmRepoAux
[7caf5a7c]1250                        installer/opengnsys_uninstall.sh \
1251                        installer/opengnsys_update.sh \
[6777e3e]1252                        installer/opengnsys_export.sh \
1253                        installer/opengnsys_import.sh \
[7caf5a7c]1254                        doc )
[cfad47b]1255        local TARGETS=( tftpboot \
[7caf5a7c]1256                        bin \
1257                        bin \
[3e7d77b]1258                        lib \
[42a0e41]1259                        sbin \
1260                        sbin \
[7caf5a7c]1261                        lib \
1262                        lib \
[6777e3e]1263                        lib \
1264                        lib \
[7caf5a7c]1265                        doc )
[463a1d49]1266
1267        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
[879689f]1268                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
[463a1d49]1269                exit 1
1270        fi
1271
[a43e90d]1272        # Copiar ficheros.
[879689f]1273        echoAndLog "${FUNCNAME}(): copying files to server directories"
[f2bb433]1274
[8457092]1275        pushd $WORKDIR/opengnsys
[463a1d49]1276        local i
1277        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
1278                if [ -f "${SOURCES[$i]}" ]; then
[879689f]1279                        echoAndLog "Copying ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
[b5aae72]1280                        cp -a "${SOURCES[$i]}" "${path_opengnsys_base}/${TARGETS[$i]}"
[8457092]1281                elif [ -d "${SOURCES[$i]}" ]; then
[879689f]1282                        echoAndLog "Copying content of ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
[8457092]1283                        cp -a "${SOURCES[$i]}"/* "${path_opengnsys_base}/${TARGETS[$i]}"
1284        else
[346eaee]1285                        warningAndLog "Unable to copy ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
[463a1d49]1286                fi
1287        done
[a43e90d]1288
[7586ca3]1289        popd
[892606b9]1290}
1291
[7586ca3]1292####################################################################
[5eb61a6]1293### Funciones de compilación de código fuente de servicios
[7586ca3]1294####################################################################
1295
[5f21d34]1296# Compilar los servicios de OpenGnsys
[7586ca3]1297function servicesCompilation ()
1298{
[13a01a7]1299        local hayErrores=0
[0795938]1300
[5f21d34]1301        # Compilar OpenGnsys Server
1302        echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Admin Server"
[7b61735]1303        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
[d168a46]1304        make && mv ogAdmServer $INSTALL_TARGET/sbin
[13a01a7]1305        if [ $? -ne 0 ]; then
[5f21d34]1306                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server"
[13a01a7]1307                hayErrores=1
1308        fi
[7586ca3]1309        popd
[5f21d34]1310        # Compilar OpenGnsys Repository Manager
1311        echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Repository Manager"
[7b61735]1312        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo
[d168a46]1313        make && mv ogAdmRepo $INSTALL_TARGET/sbin
[13a01a7]1314        if [ $? -ne 0 ]; then
[5f21d34]1315                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Repository Manager"
[13a01a7]1316                hayErrores=1
1317        fi
[8125e7c]1318        popd
[5f21d34]1319        # Compilar OpenGnsys Agent
1320        echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Agent"
[7b61735]1321        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
[d168a46]1322        make && mv ogAdmAgent $INSTALL_TARGET/sbin
[4984660]1323        if [ $? -ne 0 ]; then
[5f21d34]1324                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Agent"
[4984660]1325                hayErrores=1
1326        fi
1327        popd   
[5f21d34]1328        # Compilar OpenGnsys Client
1329        echoAndLog "${FUNCNAME}(): Compiling OpenGnsys Admin Client"
[7b61735]1330        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
[2338c95f]1331        make && mv ogAdmClient ../../../../client/shared/bin
[13a01a7]1332        if [ $? -ne 0 ]; then
[5f21d34]1333                echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Client"
[13a01a7]1334                hayErrores=1
1335        fi
[318efac]1336        popd
[13a01a7]1337
1338        return $hayErrores
[b6906f7]1339}
1340
[7b61735]1341####################################################################
1342### Funciones de copia de la Interface de administración
1343####################################################################
1344
1345# Copiar carpeta de Interface
[c1e00e4]1346function copyInterfaceAdm ()
[7b61735]1347{
1348        local hayErrores=0
1349       
[fbd9bcc]1350        # Crear carpeta y copiar Interface
[7b61735]1351        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
[fbd9bcc]1352        cp -ar $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client/interfaceAdm
[7b61735]1353        if [ $? -ne 0 ]; then
1354                echoAndLog "${FUNCNAME}(): error while copying Administration Interface Folder"
1355                hayErrores=1
1356        fi
[b6f1726]1357        chown $OPENGNSYS_CLIENT_USER:$OPENGNSYS_CLIENT_USER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
[f6c1d2b]1358        chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
[7b61735]1359
1360        return $hayErrores
1361}
[b6906f7]1362
[892606b9]1363####################################################################
1364### Funciones instalacion cliente opengnsys
1365####################################################################
1366
[73a1bd6]1367function copyClientFiles()
[7586ca3]1368{
[d168a46]1369        local errstatus=0
[a555f49]1370
[5f21d34]1371        echoAndLog "${FUNCNAME}(): Copying OpenGnsys Client files."
[73a1bd6]1372        cp -a $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
[d47d38d]1373        if [ $? -ne 0 ]; then
[9ef8920]1374                errorAndLog "${FUNCNAME}(): error while copying client estructure"
[d168a46]1375                errstatus=1
[9ef8920]1376        fi
[d47d38d]1377        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
[9ef8920]1378       
[5f21d34]1379        echoAndLog "${FUNCNAME}(): Copying OpenGnsys Cloning Engine files."
[d47d38d]1380        mkdir -p $INSTALL_TARGET/client/lib/engine/bin
[73a1bd6]1381        cp -a $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
[a555f49]1382        if [ $? -ne 0 ]; then
1383                errorAndLog "${FUNCNAME}(): error while copying engine files"
[d168a46]1384                errstatus=1
[a555f49]1385        fi
[9ef8920]1386       
[d168a46]1387        if [ $errstatus -eq 0 ]; then
[9ef8920]1388                echoAndLog "${FUNCNAME}(): client copy files success."
1389        else
1390                errorAndLog "${FUNCNAME}(): client copy files with errors"
1391        fi
1392
[d168a46]1393        return $errstatus
[463a1d49]1394}
1395
1396
[5f21d34]1397# Crear cliente OpenGnsys.
[5ad5dcc]1398function clientCreate()
[813f617]1399{
[3fd7818]1400        #local FILENAME=ogLive-xenial-4.4.0-34-generic-r4999.iso        # 1.1.0-rc4
1401        local FILENAME=ogLive-xenial-4.8.0-39-generic-amd64-r5225.iso   # 1.1.0-rc5
[0b85cc93]1402        local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME
[d168a46]1403 
[79c26a8]1404        # Descargar cliente, si es necesario.
1405        if [ -s $PROGRAMDIR/$FILENAME ]; then
1406                echoAndLog "${FUNCNAME}(): Moving $PROGRAMDIR/$FILENAME file to $(dirname $TARGETFILE)"
1407                mv $PROGRAMDIR/$FILENAME $TARGETFILE
1408        else
[ec045b1]1409                echoAndLog "${FUNCNAME}(): Downloading $FILENAME"
[0496417]1410                $INSTALL_TARGET/bin/oglivecli download $FILENAME
[79c26a8]1411        fi
[0b85cc93]1412        if [ ! -s $TARGETFILE ]; then
[ec045b1]1413                errorAndLog "${FUNCNAME}(): Error loading $FILENAME"
[813f617]1414                return 1
1415        fi
[1893b9d]1416
[79c26a8]1417        # Montar imagen, copiar cliente ogclient y desmontar.
[0496417]1418        echoAndLog "${FUNCNAME}(): Installing ogLive Client"
[6ef01d9]1419        echo -ne "$OPENGNSYS_CLIENT_PASSWD\n$OPENGNSYS_CLIENT_PASSWD\n" | \
[3fd7818]1420                        $INSTALL_TARGET/bin/oglivecli install $FILENAME
[1893b9d]1421        # Adaptar permisos.
[beaebf8]1422        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/tftpboot/menu.lst
[6ef01d9]1423
[813f617]1424        echoAndLog "${FUNCNAME}(): Client generation success"
1425}
1426
1427
[5f21d34]1428# Configuración básica de servicios de OpenGnsys
[cc7eab7]1429function openGnsysConfigure()
1430{
[d168a46]1431        local i=0
1432        local dev=""
[7d4ce64]1433        local CONSOLEURL
[d168a46]1434
[9ee62ad]1435        echoAndLog "${FUNCNAME}(): Copying init files."
[42a0e41]1436        cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
1437        cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys
[b8969db]1438        # Deshabilitar servicios de BitTorrent si no están instalados.
1439        if [ ! -e /usr/bin/bttrack ]; then
[fdab5d0]1440                sed -i 's/RUN_BTTRACKER="yes"/RUN_BTTRACKER="no"/; s/RUN_BTSEEDER="yes"/RUN_BTSEEDER="no"/' \
[b8969db]1441                        /etc/default/opengnsys
1442        fi
[9ee62ad]1443        echoAndLog "${FUNCNAME}(): Creating cron files."
[57cf15b]1444        echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
[9ee62ad]1445        echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
[8fc9552]1446        echo "5 * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
[dc762088]1447        echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/deletepreimage ] && $INSTALL_TARGET/bin/deletepreimage" > /etc/cron.d/imagedelete
[d168a46]1448
[700299b]1449        echoAndLog "${FUNCNAME}(): Creating logrotate configuration file."
1450        sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
1451                $WORKDIR/opengnsys/server/etc/logrotate.tmpl > /etc/logrotate.d/opengnsys
1452
[5f21d34]1453        echoAndLog "${FUNCNAME}(): Creating OpenGnsys config files."
[d168a46]1454        for dev in ${DEVICE[*]}; do
1455                if [ -n "${SERVERIP[i]}" ]; then
1456                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1457                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
1458                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
1459                            -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \
1460                                $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer/ogAdmServer.cfg > $INSTALL_TARGET/etc/ogAdmServer-$dev.cfg
1461                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
[f9b5714]1462                            -e "s/REPOKEY/$OPENGNSYS_REPOKEY/g" \
[d168a46]1463                                $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo/ogAdmRepo.cfg > $INSTALL_TARGET/etc/ogAdmRepo-$dev.cfg
1464                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1465                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
1466                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
1467                            -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \
1468                                $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent/ogAdmAgent.cfg > $INSTALL_TARGET/etc/ogAdmAgent-$dev.cfg
[1a2fa9d8]1469                        CONSOLEURL="https://${SERVERIP[i]}/opengnsys"
[d168a46]1470                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1471                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
1472                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
1473                            -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \
[b22305e]1474                            -e "s/OPENGNSYSURL/${CONSOLEURL//\//\\/}/g" \
[d168a46]1475                                $INSTALL_TARGET/www/controlacceso.php > $INSTALL_TARGET/www/controlacceso-$dev.php
1476                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
[d7f8305]1477                            -e "s/OPENGNSYSURL/${CONSOLEURL//\//\\/}/g" \
[d168a46]1478                                $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient/ogAdmClient.cfg > $INSTALL_TARGET/client/etc/ogAdmClient-$dev.cfg
[7d4ce64]1479                        if [ "$dev" == "$DEFAULTDEV" ]; then
[1a2fa9d8]1480                                OPENGNSYS_CONSOLEURL="$CONSOLEURL"
[7d4ce64]1481                        fi
[d168a46]1482                fi
1483                let i++
1484        done
1485        ln -f $INSTALL_TARGET/etc/ogAdmServer-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmServer.cfg
1486        ln -f $INSTALL_TARGET/etc/ogAdmRepo-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmRepo.cfg
1487        ln -f $INSTALL_TARGET/etc/ogAdmAgent-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmAgent.cfg
1488        ln -f $INSTALL_TARGET/client/etc/ogAdmClient-$DEFAULTDEV.cfg $INSTALL_TARGET/client/etc/ogAdmClient.cfg
1489        ln -f $INSTALL_TARGET/www/controlacceso-$DEFAULTDEV.php $INSTALL_TARGET/www/controlacceso.php
1490        chown root:root $INSTALL_TARGET/etc/{ogAdmServer,ogAdmAgent}*.cfg
1491        chmod 600 $INSTALL_TARGET/etc/{ogAdmServer,ogAdmAgent}*.cfg
1492        chown $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/controlacceso*.php
1493        chmod 600 $INSTALL_TARGET/www/controlacceso*.php
[1f7b2d0]1494
[a3855dc]1495        # Configuración del motor de clonación.
1496        # - Zona horaria del servidor.
1497        TZ=$(timedatectl status|awk -F"[:()]" '/Time.*zone/ {print $2}')
1498        cat << EOT >> $INSTALL_TARGET/client/etc/engine.cfg
1499# OpenGnsys Server timezone.
1500TZ="${TZ// /}"
1501EOT
1502
[1f7b2d0]1503        # Revisar permisos generales.
1504        if [ -x $INSTALL_TARGET/bin/checkperms ]; then
1505                echoAndLog "${FUNCNAME}(): Checking permissions."
1506                OPENGNSYS_DIR="$INSTALL_TARGET" OPENGNSYS_USER="$OPENGNSYS_CLIENT_USER" APACHE_USER="$APACHE_RUN_USER" APACHE_GROUP="$APACHE_RUN_GROUP" $INSTALL_TARGET/bin/checkperms
1507        fi
1508
[4e19f13]1509        # Evitar inicio de duplicado en Ubuntu 14.04 (Upstart y SysV Init).
[c7ade22]1510        if [ -f /etc/init/${MYSQLSERV}.conf -a -n "$(which initctl 2>/dev/null)" ]; then
[4e19f13]1511                service=$MYSQLSERV
1512                $DISABLESERVICE
1513        fi
1514
[5f21d34]1515        echoAndLog "${FUNCNAME}(): Starting OpenGnsys services."
[53fba30]1516        service="opengnsys"
1517        $ENABLESERVICE; $STARTSERVICE
[cc7eab7]1518}
1519
[b6906f7]1520
[a01156a]1521#####################################################################
[180a07dd]1522#######  Función de resumen informativo de la instalación
1523#####################################################################
1524
[813f617]1525function installationSummary()
1526{
[eb9424f]1527        # Crear fichero de versión y revisión, si no existe.
1528        local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
[5f21d34]1529        [ -f $VERSIONFILE ] || echo "OpenGnsys Server" >$VERSIONFILE
[130bdbf]1530        # Incluir datos de revisión, si se está instaladno desde el repositorio
1531        # de código o si no está incluida en el fichero de versión.
1532        if [ $USESVN -eq 1 ] || [ -z "$(awk '$3~/r[0-9]*/ {print}' $VERSIONFILE)" ]; then
1533                local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
1534                perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
1535        fi
[eb9424f]1536
1537        # Mostrar información.
[180a07dd]1538        echo
[5f21d34]1539        echoAndLog "OpenGnsys Installation Summary"
[180a07dd]1540        echo       "=============================="
[eb9424f]1541        echoAndLog "Project version:                  $(cat $VERSIONFILE 2>/dev/null)"
[49c6891]1542        echoAndLog "Installation directory:           $INSTALL_TARGET"
[acfb07d]1543        echoAndLog "Installation log file:            $LOG_FILE"
[49c6891]1544        echoAndLog "Repository directory:             $INSTALL_TARGET/images"
[d168a46]1545        echoAndLog "DHCP configuration directory:     $DHCPCFGDIR"
[87c7b02]1546        echoAndLog "TFTP configuration directory:     $TFTPCFGDIR"
1547        echoAndLog "Samba configuration directory:    $SAMBACFGDIR"
[49c6891]1548        echoAndLog "Web Console URL:                  $OPENGNSYS_CONSOLEURL"
[35b0ef1]1549        echoAndLog "Web Console access data:          specified in installer script"
[b8969db]1550        if grep -q "^RUN_BTTRACK.*no" /etc/default/opengnsys; then
1551                echoAndLog "BitTorrent service is disabled."
1552        fi
[180a07dd]1553        echo
1554        echoAndLog "Post-Installation Instructions:"
1555        echo       "==============================="
[663c6625]1556        echoAndLog "Firewall service has been disabled and SELinux mode set to"
[5f21d34]1557        echoAndLog "   permissive during OpenGnsys installation. Please check"
[64f4ada]1558        echoAndLog "   ${FIREWALLSERV:-firewall} and SELinux configuration, if needed."
[4faafcd]1559        echoAndLog "It's strongly recommended to synchronize this server with an NTP server."
[180a07dd]1560        echoAndLog "Review or edit all configuration files."
[c5ce04c]1561        echoAndLog "Insert DHCP configuration data and restart service."
[af5efd6]1562        echoAndLog "Optional: Log-in as Web Console admin user."
1563        echoAndLog " - Review default Organization data and assign access to users."
[180a07dd]1564        echoAndLog "Log-in as Web Console organization user."
[5f21d34]1565        echoAndLog " - Insert OpenGnsys data (labs, computers, menus, etc)."
[180a07dd]1566echo
1567}
1568
1569
1570
1571#####################################################################
[5f21d34]1572####### Proceso de instalación de OpenGnsys
[a01156a]1573#####################################################################
1574
[5f21d34]1575echoAndLog "OpenGnsys installation begins at $(date)"
[6090a2d]1576pushd $WORKDIR
[cc7eab7]1577
[af5efd6]1578# Detectar datos iniciales de auto-configuración del instalador.
[d168a46]1579autoConfigure
1580
1581# Detectar parámetros de red y comprobar si hay conexión.
1582getNetworkSettings
1583if [ $? -ne 0 ]; then
1584        errorAndLog "Error reading default network settings."
1585        exit 1
1586fi
[07c3a59]1587checkNetworkConnection
1588if [ $? -ne 0 ]; then
1589        errorAndLog "Error connecting to server. Causes:"
1590        errorAndLog " - Network is unreachable, review devices parameters."
1591        errorAndLog " - You are inside a private network, configure the proxy service."
1592        errorAndLog " - Server is temporally down, try agian later."
1593        exit 1
1594fi
[7586ca3]1595
[5f21d34]1596# Detener servicios de OpenGnsys, si están activos previamente.
[e0edc14]1597[ -f /etc/init.d/opengnsys ] && /etc/init.d/opengnsys stop
1598
[318efac]1599# Actualizar repositorios
[83518d5]1600updatePackageList
[318efac]1601
[b6906f7]1602# Instalación de dependencias (paquetes de sistema operativo).
[a01156a]1603declare -a notinstalled
1604checkDependencies DEPENDENCIES notinstalled
1605if [ $? -ne 0 ]; then
1606        installDependencies notinstalled
1607        if [ $? -ne 0 ]; then
1608                echoAndLog "Error while installing some dependeces, please verify your server installation before continue"
1609                exit 1
1610        fi
1611fi
[109e8b2]1612if [ -n "$INSTALLEXTRADEPS" ]; then
1613        echoAndLog "Installing extra dependencies"
1614        for (( i=0; i<${#INSTALLEXTRADEPS[*]}; i++ )); do
1615                eval ${INSTALLEXTRADEPS[i]}
1616        done
1617fi     
[a01156a]1618
[ff6c349]1619# Detectar datos de auto-configuración después de instalar paquetes.
1620autoConfigurePost
1621
[5f21d34]1622# Arbol de directorios de OpenGnsys.
[eb9424f]1623createDirs ${INSTALL_TARGET}
[a01156a]1624if [ $? -ne 0 ]; then
1625        errorAndLog "Error while creating directory paths!"
1626        exit 1
1627fi
[b6906f7]1628
[1e7eaab]1629# Si es necesario, descarga el repositorio de código en directorio temporal
[49c6891]1630if [ $USESVN -eq 1 ]; then
[1e7eaab]1631        svnExportCode $SVN_URL
1632        if [ $? -ne 0 ]; then
1633                errorAndLog "Error while getting code from svn"
1634                exit 1
1635        fi
1636else
1637        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
[a01156a]1638fi
1639
[5f21d34]1640# Compilar código fuente de los servicios de OpenGnsys.
[b6906f7]1641servicesCompilation
[13a01a7]1642if [ $? -ne 0 ]; then
1643        errorAndLog "Error while compiling OpenGnsys services"
1644        exit 1
1645fi
[b6906f7]1646
[7b61735]1647# Copiar carpeta Interface entre administración y motor de clonación.
[c1e00e4]1648copyInterfaceAdm
[7b61735]1649if [ $? -ne 0 ]; then
[c1e00e4]1650        errorAndLog "Error while copying Administration Interface"
[7b61735]1651        exit 1
1652fi
1653
[e70925a]1654# Configuración de TFTP.
[318efac]1655tftpConfigure
[b6906f7]1656
[e70925a]1657# Configuración de Samba.
[8fc9552]1658smbConfigure
1659if [ $? -ne 0 ]; then
[c1e00e4]1660        errorAndLog "Error while configuring Samba server!"
[8fc9552]1661        exit 1
1662fi
1663
[e70925a]1664# Configuración de Rsync.
1665rsyncConfigure
1666
1667# Configuración ejemplo DHCP.
[b6906f7]1668dhcpConfigure
[a555f49]1669if [ $? -ne 0 ]; then
1670        errorAndLog "Error while copying your dhcp server files!"
1671        exit 1
1672fi
[b6906f7]1673
[5f21d34]1674# Copiar ficheros de servicios OpenGnsys Server.
[73a1bd6]1675copyServerFiles ${INSTALL_TARGET}
[463a1d49]1676if [ $? -ne 0 ]; then
1677        errorAndLog "Error while copying the server files!"
1678        exit 1
1679fi
[730bde5]1680INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
[463a1d49]1681
[5f21d34]1682# Instalar base de datos de OpenGnsys Admin.
[5cc52295]1683isInArray notinstalled "mysql-server" || isInArray notinstalled "mariadb-server"
[b6906f7]1684if [ $? -eq 0 ]; then
[094ac0d]1685        # Habilitar gestor de base de datos (MySQL, si falla, MariaDB).
1686        service=$MYSQLSERV
1687        $ENABLESERVICE
1688        if [ $? != 0 ]; then
1689                service=$MARIADBSERV
1690                $ENABLESERVICE
1691        fi
1692        # Activar gestor de base de datos.
[0f8100d]1693        $STARTSERVICE
[094ac0d]1694        # Asignar clave del usuario "root".
[09bf701]1695        mysqlSetRootPassword "${MYSQL_ROOT_PASSWORD}"
[b6906f7]1696else
[094ac0d]1697        # Si ya está instalado el gestor de bases de datos, obtener clave de "root",
[b6906f7]1698        mysqlGetRootPassword
1699fi
[463a1d49]1700
[09bf701]1701mysqlTestConnection "${MYSQL_ROOT_PASSWORD}"
[a01156a]1702if [ $? -ne 0 ]; then
1703        errorAndLog "Error while connection to mysql"
1704        exit 1
1705fi
[09bf701]1706mysqlDbExists ${OPENGNSYS_DATABASE}
[a01156a]1707if [ $? -ne 0 ]; then
[cc7eab7]1708        echoAndLog "Creating Web Console database"
[09bf701]1709        mysqlCreateDb ${OPENGNSYS_DATABASE}
[a01156a]1710        if [ $? -ne 0 ]; then
[cc7eab7]1711                errorAndLog "Error while creating Web Console database"
[a01156a]1712                exit 1
1713        fi
1714else
[cc7eab7]1715        echoAndLog "Web Console database exists, ommiting creation"
[a01156a]1716fi
1717
[09bf701]1718mysqlCheckUserExists ${OPENGNSYS_DB_USER}
[a01156a]1719if [ $? -ne 0 ]; then
1720        echoAndLog "Creating user in database"
[09bf701]1721        mysqlCreateAdminUserToDb ${OPENGNSYS_DATABASE} ${OPENGNSYS_DB_USER} "${OPENGNSYS_DB_PASSWD}"
[a01156a]1722        if [ $? -ne 0 ]; then
[cc7eab7]1723                errorAndLog "Error while creating database user"
[a01156a]1724                exit 1
1725        fi
1726
1727fi
1728
[09bf701]1729mysqlCheckDbIsEmpty ${OPENGNSYS_DATABASE}
[a01156a]1730if [ $? -eq 0 ]; then
1731        echoAndLog "Creating tables..."
[892606b9]1732        if [ -f $WORKDIR/$OPENGNSYS_DB_CREATION_FILE ]; then
[09bf701]1733                mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_CREATION_FILE
[a01156a]1734        else
[892606b9]1735                errorAndLog "Unable to locate $WORKDIR/$OPENGNSYS_DB_CREATION_FILE!!"
[a01156a]1736                exit 1
1737        fi
[bc7dfe7]1738else
1739        # Si existe fichero ogBDAdmin-VersLocal-VersRepo.sql; aplicar cambios.
1740        REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
[295b4ab]1741        OPENGNSYS_DB_UPDATE_FILE="opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
1742        if [ -f $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE ]; then
[bc7dfe7]1743                echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION"
[09bf701]1744                mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE
[bc7dfe7]1745        else
1746                echoAndLog "Database unchanged."
1747        fi
[a01156a]1748fi
[09bf701]1749# Eliminar fichero temporal con credenciales de acceso a MySQL.
1750rm -f $TMPMYCNF
[a01156a]1751
[5f21d34]1752# Copiando páqinas web.
[7586ca3]1753installWebFiles
[ec045b1]1754# Descargar/descomprimir archivos descargables.
1755installDownloadableFiles
[5d6bf97]1756# Generar páqinas web de documentación de la API
1757makeDoxygenFiles
[a01156a]1758
[5f21d34]1759# Creando configuración de Apache.
[5fcf180]1760installWebConsoleApacheConf $INSTALL_TARGET $APACHECFGDIR
[a01156a]1761if [ $? -ne 0 ]; then
[5f21d34]1762        errorAndLog "Error configuring Apache for OpenGnsys Admin"
[a01156a]1763        exit 1
1764fi
1765
1766popd
[892606b9]1767
[9ef8920]1768# Crear la estructura de los accesos al servidor desde el cliente (shared)
[73a1bd6]1769copyClientFiles
[9ef8920]1770if [ $? -ne 0 ]; then
1771        errorAndLog "Error creating client structure"
1772fi
1773
[5f21d34]1774# Crear la estructura del cliente de OpenGnsys.
[5ad5dcc]1775clientCreate
[a555f49]1776if [ $? -ne 0 ]; then
[813f617]1777        errorAndLog "Error creating client"
[a555f49]1778        exit 1
1779fi
[892606b9]1780
[5f21d34]1781# Configuración de servicios de OpenGnsys
[65245d1]1782openGnsysConfigure
1783
[180a07dd]1784# Mostrar sumario de la instalación e instrucciones de post-instalación.
1785installationSummary
1786
[077dd7c5]1787#rm -rf $WORKDIR
[5f21d34]1788echoAndLog "OpenGnsys installation finished at $(date)"
[05d2e03]1789exit 0
[2308fc7]1790
Note: See TracBrowser for help on using the repository browser.