source: installer/opengnsys_installer.sh @ ca0f67c6

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 ca0f67c6 was 11b812d, checked in by ramon <ramongomez@…>, 12 years ago

#565 Instalardor y actualizador incluyen paquete para crear sistema de fichero para imagen diferencial.

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

  • Property mode set to 100755
File size: 51.2 KB
Line 
1#!/bin/bash
2
3#####################################################################
4####### Script instalador OpenGnSys
5####### autor: Luis Guillén <lguillen@unizar.es>
6#####################################################################
7
8
9
10####  AVISO: Editar configuración de acceso por defecto.
11####  WARNING: Edit default access configuration.
12MYSQL_ROOT_PASSWORD="passwordroot"      # Clave root de MySQL
13OPENGNSYS_DB_USER="usuog"               # Usuario de acceso a la base de datos
14OPENGNSYS_DB_PASSWD="passusuog"         # Clave de acceso a la base de datos
15OPENGNSYS_CLIENT_PASSWD="og"            # Clave de acceso del cliente
16
17
18####  AVISO: NO EDITAR.
19####  WARNING: DO NOT EDIT.
20OPENGNSYS_DATABASE="ogAdmBD"            # Nombre de la base datos
21OPENGNSYS_CLIENT_USER="opengnsys"       # Usuario del cliente para acceso remoto
22
23
24
25# Sólo ejecutable por usuario root
26if [ "$(whoami)" != 'root' ]; then
27        echo "ERROR: this program must run under root privileges!!"
28        exit 1
29fi
30# Solo se deben aceptar números y letras en la clave de acceso del cliente.
31if [ -n "${OPENGNSYS_CLIENT_PASSWD//[a-zA-Z0-9]/}" ]; then
32        echo "ERROR: client password must be alphanumeric, edit installer variables."
33        exit 1
34fi
35
36# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
37PROGRAMDIR=$(readlink -e $(dirname "$0"))
38OPENGNSYS_SERVER="www.opengnsys.es"
39if [ -d "$PROGRAMDIR/../installer" ]; then
40        USESVN=0
41else
42        USESVN=1
43fi
44SVN_URL="http://$OPENGNSYS_SERVER/svn/branches/version1.0/"
45
46WORKDIR=/tmp/opengnsys_installer
47mkdir -p $WORKDIR
48
49INSTALL_TARGET=/opt/opengnsys
50OGLOGFILE=$INSTALL_TARGET/log/opengnsys_installation.log
51LOG_FILE=/tmp/$(basename $OGLOGFILE)
52
53# Base de datos
54OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/ogAdmBD.sql
55
56
57#####################################################################
58####### Funciones de configuración
59#####################################################################
60
61# Generar variables de configuración del instalador
62# Variables globales:
63# - OSDISTRIB, OSCODENAME - datos de la distribución Linux
64# - DEPENDENCIES - array de dependencias que deben estar instaladas
65# - UPDATEPKGLIST, INSTALLPKGS, CHECKPKGS - comandos para gestión de paquetes
66# - INSTALLEXTRADEPS - instalar dependencias no incluidas en la distribución
67# - STARTSERVICE, ENABLESERVICE - iniciar y habilitar un servicio
68# - STOPSERVICE, DISABLESERVICE - parar y deshabilitar un servicio
69# - APACHESERV, APACHECFGDIR, APACHESITESDIR, APACHEUSER, APACHEGROUP - servicio y configuración de Apache
70# - APACHESSLMOD, APACHEENABLESSL, APACHEMAKECERT - habilitar módulo Apache y certificado SSL
71# - APACHEENABLEOG, APACHEOGSITE, - habilitar sitio web de OpenGnSys
72# - INETDSERV - servicio Inetd
73# - IPTABLESSERV - servicio IPTables
74# - DHCPSERV, DHCPCFGDIR - servicio y configuración de DHCP
75# - MYSQLSERV, TMPMYCNF - servicio MySQL y fichero temporal con credenciales de acceso.
76# - RSYNCSERV, RSYNCCFGDIR - servicio y configuración de Rsync
77# - SAMBASERV, SAMBACFGDIR - servicio y configuración de Samba
78# - TFTPSERV, TFTPCFGDIR, SYSLINUXDIR - servicio y configuración de TFTP/PXE
79function autoConfigure()
80{
81# Detectar sistema operativo del servidor (debe soportar LSB).
82OSDISTRIB=$(lsb_release -is 2>/dev/null)
83OSCODENAME=$(lsb_release -cs 2>/dev/null)
84
85# Configuración según la distribución GNU/Linux.
86case "$OSDISTRIB" in
87        Ubuntu|Debian|LinuxMint)
88                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 )
89                UPDATEPKGLIST="apt-get update"
90                INSTALLPKG="apt-get -y install --force-yes"
91                CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install"
92                if which service &>/dev/null; then
93                        STARTSERVICE="eval service \$service restart"
94                        STOPSERVICE="eval service \$service stop"
95                else
96                        STARTSERVICE="eval /etc/init.d/\$service restart"
97                        STOPSERVICE="eval /etc/init.d/\$service stop"
98                fi
99                ENABLESERVICE="eval update-rc.d \$service defaults"
100                DISABLESERVICE="eval update-rc.d \$service disable"
101                APACHESERV=apache2
102                APACHECFGDIR=/etc/apache2
103                APACHESITESDIR=sites-available
104                APACHEOGSITE=opengnsys
105                APACHEUSER="www-data"
106                APACHEGROUP="www-data"
107                APACHESSLMOD="a2enmod ssl"
108                APACHEENABLESSL="a2ensite default-ssl"
109                APACHEENABLEOG="a2ensite $APACHEOGSITE"
110                APACHEMAKECERT="make-ssl-cert generate-default-snakeoil --force-overwrite"
111                DHCPSERV=isc-dhcp-server
112                DHCPCFGDIR=/etc/dhcp
113                INETDSERV=xinetd
114                INETDCFGDIR=/etc/xinetd.d
115                MYSQLSERV=mysql
116                RSYNCSERV=rsync
117                RSYNCCFGDIR=/etc
118                SAMBASERV=smbd
119                SAMBACFGDIR=/etc/samba
120                SYSLINUXDIR=/usr/lib/syslinux
121                TFTPCFGDIR=/var/lib/tftpboot
122                ;;
123        Fedora|CentOS)
124                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++-static.i686 libstdc++-devel.i686 make wget doxygen graphviz ctorrent samba rsync unzip debootstrap schroot squashfs-tools btrfs-progs )
125                INSTALLEXTRADEPS=( 'rpm -Uv ftp://ftp.altlinux.org/pub/distributions/ALTLinux/5.1/branch/files/i586/RPMS/netpipes-4.2-alt1.i586.rpm'
126                                   'pushd /tmp; wget 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' )
127                if [ "$OSDISTRIB" == "CentOS" ]; then
128                        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'
129                fi
130                INSTALLPKG="yum install -y"
131                CHECKPKG="rpm -q --quiet \$package"
132                SYSTEMD=$(which systemctl 2>/dev/null)
133                if [ -n "$SYSTEMD" ]; then
134                        STARTSERVICE="eval systemctl start \$service.service"
135                        STOPSERVICE="eval systemctl stop \$service.service"
136                        ENABLESERVICE="eval systemctl enable \$service.service"
137                        DISABLESERVICE="eval systemctl disable \$service.service"
138                else
139                        STARTSERVICE="eval service \$service start"
140                        STOPSERVICE="eval service \$service stop"
141                        ENABLESERVICE="eval chkconfig \$service on"
142                        DISABLESERVICE="eval chkconfig \$service off"
143                fi
144                APACHESERV=httpd
145                APACHECFGDIR=/etc/httpd/conf.d
146                APACHEOGSITE=opengnsys.conf
147                APACHEUSER="apache"
148                APACHEGROUP="apache"
149                DHCPSERV=dhcpd
150                DHCPCFGDIR=/etc/dhcp
151                INETDSERV=xinetd
152                INETDCFGDIR=/etc/xinetd.d
153                IPTABLESSERV=iptables
154                MYSQLSERV=mysqld
155                RSYNCSERV=rsync
156                RSYNCCFGDIR=/etc
157                SAMBASERV=smb
158                SAMBACFGDIR=/etc/samba
159                SYSLINUXDIR=/usr/share/syslinux
160                TFTPSERV=tftp
161                TFTPCFGDIR=/var/lib/tftpboot
162                ;;
163        "")     echo "ERROR: Unknown Linux distribution, please install \"lsb_release\" command."
164                exit 1 ;;
165        *)      echo "ERROR: Distribution not supported by OpenGnSys."
166                exit 1 ;;
167esac
168
169# Fichero de credenciales de acceso a MySQL.
170TMPMYCNF=/tmp/.my.cnf.$$
171}
172
173# Modificar variables de configuración tras instalar paquetes del sistema.
174function autoConfigurePost()
175{
176[ -z "$SYSTEMD" -a ! -e /etc/init.d/$SAMBASERV ] && SAMBASERV=samba     # Debian 6
177[ ! -e $TFTPCFGDIR ] && TFTPCFGDIR=/srv/tftp            # Debian 6
178[ -f /selinux/enforce ] && echo 0 > /selinux/enforce    # SELinux permisivo
179selinuxenabled && setenforce 0 2>/dev/null              # SELinux permisivo (Fedora 17)
180}
181
182
183# Cargar lista de paquetes del sistema y actualizar algunas variables de configuración
184# dependiendo de la versión instalada.
185function updatePackageList()
186{
187local DHCPVERSION
188
189# Si es necesario, actualizar la lista de paquetes disponibles.
190[ -n "$UPDATEPKGLIST" ] && eval $UPDATEPKGLIST
191
192# Configuración personallizada de algunos paquetes.
193case "$OSDISTRIB" in
194        Ubuntu|LinuxMint)       # Postconfiguación personalizada para Ubuntu.
195                # Configuración para DHCP v3.
196                DHCPVERSION=$(apt-cache show $(apt-cache pkgnames|egrep "dhcp.?-server$") | \
197                              awk '/Version/ {print substr($2,1,1);}' | \
198                              sort -n | tail -1)
199                if [ $DHCPVERSION = 3 ]; then
200                        DEPENDENCIES=( ${DEPENDENCIES[@]/isc-dhcp-server/dhcp3-server} )
201                        DHCPSERV=dhcp3-server
202                        DHCPCFGDIR=/etc/dhcp3
203                fi
204                ;;
205        CentOS) # Postconfiguación personalizada para CentOS.
206                # Incluir repositorio de paquetes EPEL.
207                DEPENDENCIES=( ${DEPENDENCIES[@]} epel-release )
208                ;;
209esac
210}
211
212
213#####################################################################
214####### Algunas funciones útiles de propósito general:
215#####################################################################
216
217function getDateTime()
218{
219        date "+%Y%m%d-%H%M%S"
220}
221
222# Escribe a fichero y muestra por pantalla
223function echoAndLog()
224{
225        local DATETIME=`getDateTime`
226        echo "$1"
227        echo "$DATETIME;$SSH_CLIENT;$1" >> $LOG_FILE
228}
229
230# Escribe a fichero y muestra mensaje de error
231function errorAndLog()
232{
233        local DATETIME=`getDateTime`
234        echo "ERROR: $1"
235        echo "$DATETIME;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
236}
237
238# Comprueba si el elemento pasado en $2 está en el array $1
239function isInArray()
240{
241        if [ $# -ne 2 ]; then
242                errorAndLog "${FUNCNAME}(): invalid number of parameters"
243                exit 1
244        fi
245
246        local deps
247        local is_in_array=1
248        local element="$2"
249
250        echoAndLog "${FUNCNAME}(): checking if $2 is in $1"
251        eval "deps=( \"\${$1[@]}\" )"
252
253        # Copia local del array del parámetro 1.
254        for (( i = 0 ; i < ${#deps[@]} ; i++ )); do
255                if [ "${deps[$i]}" = "${element}" ]; then
256                        echoAndLog "isInArray(): $element found in array"
257                        is_in_array=0
258                fi
259        done
260
261        if [ $is_in_array -ne 0 ]; then
262                echoAndLog "${FUNCNAME}(): $element NOT found in array"
263        fi
264
265        return $is_in_array
266}
267
268
269#####################################################################
270####### Funciones de manejo de paquetes Debian
271#####################################################################
272
273function checkPackage()
274{
275        package=$1
276        if [ -z $package ]; then
277                errorAndLog "${FUNCNAME}(): parameter required"
278                exit 1
279        fi
280        echoAndLog "${FUNCNAME}(): checking if package $package exists"
281        eval $CHECKPKG
282        if [ $? -eq 0 ]; then
283                echoAndLog "${FUNCNAME}(): package $package exists"
284                return 0
285        else
286                echoAndLog "${FUNCNAME}(): package $package doesn't exists"
287                return 1
288        fi
289}
290
291# Recibe array con dependencias
292# por referencia deja un array con las dependencias no resueltas
293# devuelve 1 si hay alguna dependencia no resuelta
294function checkDependencies()
295{
296        if [ $# -ne 2 ]; then
297                errorAndLog "${FUNCNAME}(): invalid number of parameters"
298                exit 1
299        fi
300
301        echoAndLog "${FUNCNAME}(): checking dependences"
302        uncompletedeps=0
303
304        # copia local del array del parametro 1
305        local deps
306        eval "deps=( \"\${$1[@]}\" )"
307
308        declare -a local_notinstalled
309
310        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
311        do
312                checkPackage ${deps[$i]}
313                if [ $? -ne 0 ]; then
314                        local_notinstalled[$uncompletedeps]=$package
315                        let uncompletedeps=uncompletedeps+1
316                fi
317        done
318
319        # relleno el array especificado en $2 por referencia
320        for (( i = 0 ; i < ${#local_notinstalled[@]} ; i++ ))
321        do
322                eval "${2}[$i]=${local_notinstalled[$i]}"
323        done
324
325        # retorna el numero de paquetes no resueltos
326        echoAndLog "${FUNCNAME}(): dependencies uncompleted: $uncompletedeps"
327        return $uncompletedeps
328}
329
330# Recibe un array con las dependencias y lo instala
331function installDependencies()
332{
333        if [ $# -ne 1 ]; then
334                errorAndLog "${FUNCNAME}(): invalid number of parameters"
335                exit 1
336        fi
337        echoAndLog "${FUNCNAME}(): installing uncompleted dependencies"
338
339        # copia local del array del parametro 1
340        local deps
341        eval "deps=( \"\${$1[@]}\" )"
342
343        local string_deps=""
344        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
345        do
346                string_deps="$string_deps ${deps[$i]}"
347        done
348
349        if [ -z "${string_deps}" ]; then
350                errorAndLog "${FUNCNAME}(): array of dependeces is empty"
351                exit 1
352        fi
353
354        OLD_DEBIAN_FRONTEND=$DEBIAN_FRONTEND            # Debian/Ubuntu
355        export DEBIAN_FRONTEND=noninteractive
356
357        echoAndLog "${FUNCNAME}(): now $string_deps will be installed"
358        eval $INSTALLPKG $string_deps
359        if [ $? -ne 0 ]; then
360                errorAndLog "${FUNCNAME}(): error installing dependencies"
361                return 1
362        fi
363
364        DEBIAN_FRONTEND=$OLD_DEBIAN_FRONTEND            # Debian/Ubuntu
365        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
366
367        echoAndLog "${FUNCNAME}(): dependencies installed"
368}
369
370# Hace un backup del fichero pasado por parámetro
371# deja un -last y uno para el día
372function backupFile()
373{
374        if [ $# -ne 1 ]; then
375                errorAndLog "${FUNCNAME}(): invalid number of parameters"
376                exit 1
377        fi
378
379        local file="$1"
380        local dateymd=`date +%Y%m%d`
381
382        if [ ! -f "$file" ]; then
383                errorAndLog "${FUNCNAME}(): file $file doesn't exists"
384                return 1
385        fi
386
387        echoAndLog "${FUNCNAME}(): making $file backup"
388
389        # realiza una copia de la última configuración como last
390        cp -a "$file" "${file}-LAST"
391
392        # si para el día no hay backup lo hace, sino no
393        if [ ! -f "${file}-${dateymd}" ]; then
394                cp -a "$file" "${file}-${dateymd}"
395        fi
396
397        echoAndLog "${FUNCNAME}(): $file backup success"
398}
399
400#####################################################################
401####### Funciones para el manejo de bases de datos
402#####################################################################
403
404# This function set password to root
405function mysqlSetRootPassword()
406{
407        if [ $# -ne 1 ]; then
408                errorAndLog "${FUNCNAME}(): invalid number of parameters"
409                exit 1
410        fi
411
412        local root_mysql="$1"
413        echoAndLog "${FUNCNAME}(): setting root password in MySQL server"
414        mysqladmin -u root password "$root_mysql"
415        if [ $? -ne 0 ]; then
416                errorAndLog "${FUNCNAME}(): error while setting root password in MySQL server"
417                return 1
418        fi
419        echoAndLog "${FUNCNAME}(): root password saved!"
420        return 0
421}
422
423# Si el servicio mysql esta ya instalado cambia la variable de la clave del root por la ya existente
424function mysqlGetRootPassword()
425{
426        local pass_mysql
427        local pass_mysql2
428        # Comprobar si MySQL está instalado con la clave de root por defecto.
429        if mysql -u root -p"$MYSQL_ROOT_PASSWORD" <<<"quit" 2>/dev/null; then
430                echoAndLog "${FUNCNAME}(): Using default mysql root password."
431        else
432                stty -echo
433                echo "There is a MySQL service already installed."
434                read -p "Enter MySQL root password: " pass_mysql
435                echo ""
436                read -p "Confrim password:" pass_mysql2
437                echo ""
438                stty echo
439                if [ "$pass_mysql" == "$pass_mysql2" ] ;then
440                        MYSQL_ROOT_PASSWORD="$pass_mysql"
441                        return 0
442                else
443                        echo "The keys don't match. Do not configure the server's key,"
444                        echo "transactions in the database will give error."
445                        return 1
446                fi
447        fi
448}
449
450# comprueba si puede conectar con mysql con el usuario root
451function mysqlTestConnection()
452{
453        if [ $# -ne 1 ]; then
454                errorAndLog "${FUNCNAME}(): invalid number of parameters"
455                exit 1
456        fi
457
458        local root_password="$1"
459        echoAndLog "${FUNCNAME}(): checking connection to mysql..."
460        # Componer fichero con credenciales de conexión a MySQL.
461        touch $TMPMYCNF
462        chmod 600 $TMPMYCNF
463        cat << EOT > $TMPMYCNF
464[client]
465user=root
466password=$root_password
467EOT
468        # Borrar el fichero temporal si termina el proceso de instalación.
469        trap "rm -f $TMPMYCNF" 0 1 2 3 6 9 15
470        # Comprobar conexión a MySQL.
471        echo "" | mysql --defaults-extra-file=$TMPMYCNF
472        if [ $? -ne 0 ]; then
473                errorAndLog "${FUNCNAME}(): connection to mysql failed, check root password and if daemon is running!"
474                return 1
475        else
476                echoAndLog "${FUNCNAME}(): connection success"
477                return 0
478        fi
479}
480
481# comprueba si la base de datos existe
482function mysqlDbExists()
483{
484        if [ $# -ne 1 ]; then
485                errorAndLog "${FUNCNAME}(): invalid number of parameters"
486                exit 1
487        fi
488
489        local database="$1"
490        echoAndLog "${FUNCNAME}(): checking if $database exists..."
491        echo "show databases" | mysql --defaults-extra-file=$TMPMYCNF | grep "^${database}$"
492        if [ $? -ne 0 ]; then
493                echoAndLog "${FUNCNAME}():database $database doesn't exists"
494                return 1
495        else
496                echoAndLog "${FUNCNAME}():database $database exists"
497                return 0
498        fi
499}
500
501function mysqlCheckDbIsEmpty()
502{
503        if [ $# -ne 1 ]; then
504                errorAndLog "${FUNCNAME}(): invalid number of parameters"
505                exit 1
506        fi
507
508        local database="$1"
509        echoAndLog "${FUNCNAME}(): checking if $database is empty..."
510        num_tablas=`echo "show tables" | mysql --defaults-extra-file=$TMPMYCNF "${database}" | wc -l`
511        if [ $? -ne 0 ]; then
512                errorAndLog "${FUNCNAME}(): error executing query, check database and root password"
513                exit 1
514        fi
515
516        if [ $num_tablas -eq 0 ]; then
517                echoAndLog "${FUNCNAME}():database $database is empty"
518                return 0
519        else
520                echoAndLog "${FUNCNAME}():database $database has tables"
521                return 1
522        fi
523
524}
525
526
527function mysqlImportSqlFileToDb()
528{
529        if [ $# -ne 2 ]; then
530                errorAndLog "${FNCNAME}(): invalid number of parameters"
531                exit 1
532        fi
533
534        local database="$1"
535        local sqlfile="$2"
536        local tmpfile=$(mktemp)
537        local i=0
538        local dev=""
539        local status
540
541        if [ ! -f $sqlfile ]; then
542                errorAndLog "${FUNCNAME}(): Unable to locate $sqlfile!!"
543                return 1
544        fi
545
546        echoAndLog "${FUNCNAME}(): importing SQL file to ${database}..."
547        chmod 600 $tmpfile
548        for dev in ${DEVICE[*]}; do
549                if [ "${DEVICE[i]}" == "$DEFAULTDEV" ]; then
550                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
551                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
552                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
553                                $sqlfile > $tmpfile
554                fi
555                let i++
556        done
557        mysql --defaults-extra-file=$TMPMYCNF --default-character-set=utf8 "${database}" < $tmpfile
558        status=$?
559        rm -f $tmpfile
560        if [ $status -ne 0 ]; then
561                errorAndLog "${FUNCNAME}(): error while importing $sqlfile in database $database"
562                return 1
563        fi
564        echoAndLog "${FUNCNAME}(): file imported to database $database"
565        return 0
566}
567
568# Crea la base de datos
569function mysqlCreateDb()
570{
571        if [ $# -ne 1 ]; then
572                errorAndLog "${FUNCNAME}(): invalid number of parameters"
573                exit 1
574        fi
575
576        local database="$1"
577
578        echoAndLog "${FUNCNAME}(): creating database..."
579        mysqladmin --defaults-extra-file=$TMPMYCNF create $database
580        if [ $? -ne 0 ]; then
581                errorAndLog "${FUNCNAME}(): error while creating database $database"
582                return 1
583        fi
584        echoAndLog "${FUNCNAME}(): database $database created"
585        return 0
586}
587
588
589function mysqlCheckUserExists()
590{
591        if [ $# -ne 1 ]; then
592                errorAndLog "${FUNCNAME}(): invalid number of parameters"
593                exit 1
594        fi
595
596        local userdb="$1"
597
598        echoAndLog "${FUNCNAME}(): checking if $userdb exists..."
599        echo "select user from user where user='${userdb}'\\G" |mysql --defaults-extra-file=$TMPMYCNF mysql | grep user
600        if [ $? -ne 0 ]; then
601                echoAndLog "${FUNCNAME}(): user doesn't exists"
602                return 1
603        else
604                echoAndLog "${FUNCNAME}(): user already exists"
605                return 0
606        fi
607
608}
609
610# Crea un usuario administrativo para la base de datos
611function mysqlCreateAdminUserToDb()
612{
613        if [ $# -ne 3 ]; then
614                errorAndLog "${FUNCNAME}(): invalid number of parameters"
615                exit 1
616        fi
617
618        local database="$1"
619        local userdb="$2"
620        local passdb="$3"
621
622        echoAndLog "${FUNCNAME}(): creating admin user ${userdb} to database ${database}"
623
624        cat > $WORKDIR/create_${database}.sql <<EOF
625GRANT USAGE ON *.* TO '${userdb}'@'localhost' IDENTIFIED BY '${passdb}' ;
626GRANT ALL PRIVILEGES ON ${database}.* TO '${userdb}'@'localhost' WITH GRANT OPTION ;
627FLUSH PRIVILEGES ;
628EOF
629        mysql --defaults-extra-file=$TMPMYCNF < $WORKDIR/create_${database}.sql
630        if [ $? -ne 0 ]; then
631                errorAndLog "${FUNCNAME}(): error while creating user in mysql"
632                rm -f $WORKDIR/create_${database}.sql
633                return 1
634        else
635                echoAndLog "${FUNCNAME}(): user created ok"
636                rm -f $WORKDIR/create_${database}.sql
637                return 0
638        fi
639}
640
641
642#####################################################################
643####### Funciones para el manejo de Subversion
644#####################################################################
645
646function svnExportCode()
647{
648        if [ $# -ne 1 ]; then
649                errorAndLog "${FUNCNAME}(): invalid number of parameters"
650                exit 1
651        fi
652
653        local url="$1"
654
655        echoAndLog "${FUNCNAME}(): downloading subversion code..."
656
657        svn export --force "$url" opengnsys
658        if [ $? -ne 0 ]; then
659                errorAndLog "${FUNCNAME}(): error getting OpenGnSys code from $url"
660                return 1
661        fi
662        echoAndLog "${FUNCNAME}(): subversion code downloaded"
663        return 0
664}
665
666
667############################################################
668###  Detectar red
669############################################################
670
671# Comprobar si existe conexión.
672function checkNetworkConnection()
673{
674        echoAndLog "${FUNCNAME}(): Disabling IPTables."
675        if [ -n "$IPTABLESSERV" ]; then
676                service=$IPTABLESSERV
677                $STOPSERVICE; $DISABLESERVICE
678        fi
679
680        echoAndLog "${FUNCNAME}(): Checking OpenGnSys server conectivity."
681        OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"www.opengnsys.es"}
682        wget --spider -q $OPENGNSYS_SERVER
683}
684
685# Obtener los parámetros de red de la interfaz por defecto.
686function getNetworkSettings()
687{
688        # Arrays globales definidas:
689        # - DEVICE:     nombres de dispositivos de red activos.
690        # - SERVERIP:   IPs locales del servidor.
691        # - NETIP:      IPs de redes.
692        # - NETMASK:    máscaras de red.
693        # - NETBROAD:   IPs de difusión de redes.
694        # - ROUTERIP:   IPs de routers.
695        # Otras variables globales:
696        # - DEFAULTDEV: dispositivo de red por defecto.
697        # - DNSIP:      IP del servidor DNS principal.
698
699        local i=0
700        local dev=""
701
702        echoAndLog "${FUNCNAME}(): Detecting network parameters."
703        DEVICE=( $(ip -o link show up | awk '!/loopback/ {sub(/:.*/,"",$2); print $2}') )
704        if [ -z "$DEVICE" ]; then
705                errorAndLog "${FUNCNAME}(): Network devices not detected."
706                exit 1
707        fi
708        for dev in ${DEVICE[*]}; do
709                SERVERIP[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {sub (/\/.*/, ""); print ($4)}')
710                if [ -n "${SERVERIP[i]}" ]; then
711                        NETMASK[i]=$(LANG=C ifconfig $dev | \
712                                                awk '/Mask/ {sub(/.*:/,"",$4); print $4}
713                                                     /netmask/ {print $4}')
714                        NETBROAD[i]=$(ip -o addr show dev $dev | awk '$3~/inet$/ {print ($6)}')
715                        NETIP[i]=$(netstat -nr | awk -v d="$dev" '$1!~/0\.0\.0\.0/&&$8==d {if (n=="") n=$1} END {print n}')
716                        ROUTERIP[i]=$(netstat -nr | awk -v d="$dev" '$1~/0\.0\.0\.0/&&$8==d {print $2}')
717                        DEFAULTDEV=${DEFAULTDEV:-"$dev"}
718                fi
719                let i++
720        done
721        DNSIP=$(awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n1)
722        if [ -z "${NETIP[*]}" -o -z "${NETMASK[*]}" ]; then
723                errorAndLog "${FUNCNAME}(): Network not detected."
724                exit 1
725        fi
726
727        # Variables de ejecución de Apache
728        # - APACHE_RUN_USER
729        # - APACHE_RUN_GROUP
730        if [ -f $APACHECFGDIR/envvars ]; then
731                source $APACHECFGDIR/envvars
732        fi
733        APACHE_RUN_USER=${APACHE_RUN_USER:-"$APACHEUSER"}
734        APACHE_RUN_GROUP=${APACHE_RUN_GROUP:-"$APACHEGROUP"}
735
736        echoAndLog "${FUNCNAME}(): Default network device: $DEFAULTDEV."
737}
738
739
740############################################################
741### Esqueleto para el Servicio pxe y contenedor tftpboot ###
742############################################################
743
744function tftpConfigure()
745{
746        echoAndLog "${FUNCNAME}(): Configuring TFTP service."
747        # Habilitar TFTP y reiniciar Inetd.
748        if [ -n "$TFTPSERV" ]; then
749                service=$TFTPSERV
750                $ENABLESERVICE
751        fi
752        service=$INETDSERV
753        $ENABLESERVICE; $STARTSERVICE
754
755        # preparacion contenedor tftpboot
756        cp -a $SYSLINUXDIR $TFTPCFGDIR/syslinux
757        cp -a $SYSLINUXDIR/pxelinux.0 $TFTPCFGDIR
758        # prepamos el directorio de la configuracion de pxe
759        mkdir -p $TFTPCFGDIR/pxelinux.cfg
760        cat > $TFTPCFGDIR/pxelinux.cfg/default <<EOF
761DEFAULT syslinux/vesamenu.c32
762MENU TITLE Aplicacion GNSYS
763 
764LABEL 1
765MENU LABEL 1
766KERNEL syslinux/chain.c32
767APPEND hd0
768 
769PROMPT 0
770TIMEOUT 10
771EOF
772        # comprobamos el servicio tftp
773        sleep 1
774        testPxe
775}
776
777function testPxe ()
778{
779        echoAndLog "${FUNCNAME}(): Checking TFTP service... please wait."
780        pushd /tmp
781        tftp -v localhost -c get pxelinux.0 /tmp/pxelinux.0 && echoAndLog "TFTP service is OK." || errorAndLog "TFTP service is down."
782        popd
783}
784
785
786########################################################################
787## Configuracion servicio NFS
788########################################################################
789
790# Configurar servicio NFS.
791# ADVERTENCIA: usa variables globales NETIP y NETMASK!
792function nfsConfigure()
793{
794        echoAndLog "${FUNCNAME}(): Config nfs server."
795        backupFile /etc/exports
796
797        nfsAddExport $INSTALL_TARGET/client ${NETIP}/${NETMASK}:ro,no_subtree_check,no_root_squash,sync
798        if [ $? -ne 0 ]; then
799                errorAndLog "${FUNCNAME}(): error while adding NFS client config"
800                return 1
801        fi
802
803        nfsAddExport $INSTALL_TARGET/images ${NETIP}/${NETMASK}:rw,no_subtree_check,no_root_squash,sync,crossmnt
804        if [ $? -ne 0 ]; then
805                errorAndLog "${FUNCNAME}(): error while adding NFS images config"
806                return 1
807        fi
808
809        nfsAddExport $INSTALL_TARGET/log/clients ${NETIP}/${NETMASK}:rw,no_subtree_check,no_root_squash,sync
810        if [ $? -ne 0 ]; then
811                errorAndLog "${FUNCNAME}(): error while adding logging client config"
812                return 1
813        fi
814
815        nfsAddExport $INSTALL_TARGET/tftpboot ${NETIP}/${NETMASK}:ro,no_subtree_check,no_root_squash,sync
816        if [ $? -ne 0 ]; then
817                errorAndLog "${FUNCNAME}(): error while adding second filesystem for the PXE ogclient"
818                return 1
819        fi
820
821        /etc/init.d/nfs-kernel-server restart
822        exportfs -va
823        if [ $? -ne 0 ]; then
824                errorAndLog "${FUNCNAME}(): error while configure exports"
825                return 1
826        fi
827
828        echoAndLog "${FUNCNAME}(): Added NFS configuration to file \"/etc/exports\"."
829        return 0
830}
831
832
833# Añadir entrada en fichero de configuración del servidor NFS.
834# Ejemplos:
835#nfsAddExport /opt/opengnsys 192.168.0.0/255.255.255.0:ro,no_subtree_check,no_root_squash,sync
836#nfsAddExport /opt/opengnsys 192.168.0.0/255.255.255.0
837#nfsAddExport /opt/opengnsys 80.20.2.1:ro 192.123.32.2:rw
838function nfsAddExport()
839{
840        if [ $# -lt 2 ]; then
841                errorAndLog "${FUNCNAME}(): invalid number of parameters"
842                exit 1
843        fi
844        if [ ! -f /etc/exports ]; then
845                errorAndLog "${FUNCNAME}(): /etc/exports don't exists"
846                return 1
847        fi
848
849        local export="$1"
850        local contador=0
851        local cadenaexport
852
853        grep "^$export" /etc/exports > /dev/null
854        if [ $? -eq 0 ]; then
855                echoAndLog "${FUNCNAME}(): $export exists in /etc/exports, omiting"
856                return 0
857        fi
858
859        cadenaexport="${export}"
860        for parametro in $*; do
861                if [ $contador -gt 0 ]; then
862                        host=`echo $parametro | awk -F: '{print $1}'`
863                        options=`echo $parametro | awk -F: '{print $2}'`
864                        if [ "${host}" == "" ]; then
865                                errorAndLog "${FUNCNAME}(): host can't be empty"
866                                return 1
867                        fi
868                        cadenaexport="${cadenaexport}\t${host}"
869
870                        if [ "${options}" != "" ]; then
871                                cadenaexport="${cadenaexport}(${options})"
872                        fi
873                fi
874                let contador=contador+1
875        done
876
877        echo -en "$cadenaexport\n" >> /etc/exports
878
879        echoAndLog "${FUNCNAME}(): add $export to /etc/exports"
880        return 0
881}
882
883
884########################################################################
885## Configuracion servicio Samba
886########################################################################
887
888# Configurar servicios Samba.
889function smbConfigure()
890{
891        echoAndLog "${FUNCNAME}(): Configuring Samba service."
892
893        backupFile $SAMBACFGDIR/smb.conf
894       
895        # Copiar plantailla de recursos para OpenGnSys
896        sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
897                $WORKDIR/opengnsys/server/etc/smb-og.conf.tmpl > $SAMBACFGDIR/smb-og.conf
898        # Configurar y recargar Samba"
899        perl -pi -e "s/WORKGROUP/OPENGNSYS/; s/server string \=.*/server string \= OpenGnSys Samba Server/" $SAMBACFGDIR/smb.conf
900        if ! grep -q "smb-og" $SAMBACFGDIR/smb.conf; then
901                echo "include = $SAMBACFGDIR/smb-og.conf" >> $SAMBACFGDIR/smb.conf
902        fi
903        service=$SAMBASERV
904        $ENABLESERVICE; $STARTSERVICE
905        if [ $? -ne 0 ]; then
906                errorAndLog "${FUNCNAME}(): error while configure Samba"
907                return 1
908        fi
909        # Crear clave para usuario de acceso a los recursos.
910        echo -ne "$OPENGNSYS_CLIENT_PASSWD\n$OPENGNSYS_CLIENT_PASSWD\n" | smbpasswd -a -s $OPENGNSYS_CLIENT_USER
911
912        echoAndLog "${FUNCNAME}(): Added Samba configuration."
913        return 0
914}
915
916
917########################################################################
918## Configuracion servicio Rsync
919########################################################################
920
921# Configurar servicio Rsync.
922function rsyncConfigure()
923{
924        echoAndLog "${FUNCNAME}(): Configuring Rsync service."
925
926        backupFile $RSYNCCFGDIR/rsyncd.conf
927
928        # Configurar acceso a Rsync.
929        sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \
930                $WORKDIR/opengnsys/repoman/etc/rsyncd.conf.tmpl > $RSYNCCFGDIR/rsyncd.conf
931        sed -e "s/CLIENTUSER/$OPENGNSYS_CLIENT_USER/g" \
932            -e "s/CLIENTPASSWORD/$OPENGNSYS_CLIENT_PASSWD/g" \
933                $WORKDIR/opengnsys/repoman/etc/rsyncd.secrets.tmpl > $RSYNCCFGDIR/rsyncd.secrets
934        chown root.root $RSYNCCFGDIR/rsyncd.secrets
935        chmod 600 $RSYNCCFGDIR/rsyncd.secrets
936
937        # Habilitar Rsync y reiniciar Inetd.
938        if [ -n "$RSYNCSERV" ]; then
939                if [ -f /etc/default/rsync ]; then
940                        perl -pi -e 's/RSYNC_ENABLE=.*/RSYNC_ENABLE=inetd/' /etc/default/rsync
941                fi
942                if [ -f $INETDCFGDIR/rsync ]; then
943                        perl -pi -e 's/disable.*/disable = no/' $INETDCFGDIR/rsync
944                else
945                        cat << EOT > $INETDCFGDIR/rsync
946service rsync
947{
948        disable = no
949        socket_type = stream
950        wait = no
951        user = root
952        server = $(which rsync)
953        server_args = --daemon
954        log_on_failure += USERID
955        flags = IPv6
956}
957EOT
958                fi
959                service=$RSYNCSERV $ENABLESERVICE
960                service=$INETDSERV $STARTSERVICE
961        fi
962
963        echoAndLog "${FUNCNAME}(): Added Rsync configuration."
964        return 0
965}
966
967       
968########################################################################
969## Configuracion servicio DHCP
970########################################################################
971
972# Configurar servicios DHCP.
973function dhcpConfigure()
974{
975        echoAndLog "${FUNCNAME}(): Sample DHCP configuration."
976
977        local errcode=0
978        local i=0
979        local dev=""
980
981        backupFile $DHCPCFGDIR/dhcpd.conf
982        for dev in ${DEVICE[*]}; do
983                if [ -n "${SERVERIP[i]}" ]; then
984                        backupFile $DHCPCFGDIR/dhcpd-$dev.conf
985                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
986                            -e "s/NETIP/${NETIP[i]}/g" \
987                            -e "s/NETMASK/${NETMASK[i]}/g" \
988                            -e "s/NETBROAD/${NETBROAD[i]}/g" \
989                            -e "s/ROUTERIP/${ROUTERIP[i]}/g" \
990                            -e "s/DNSIP/$DNSIP/g" \
991                            $WORKDIR/opengnsys/server/etc/dhcpd.conf.tmpl > $DHCPCFGDIR/dhcpd-$dev.conf || errcode=1
992                fi
993                let i++
994        done
995        if [ $errcode -ne 0 ]; then
996                errorAndLog "${FUNCNAME}(): error while configuring DHCP server"
997                return 1
998        fi
999        ln -f $DHCPCFGDIR/dhcpd-$DEFAULTDEV.conf $DHCPCFGDIR/dhcpd.conf
1000        service=$DHCPSERV
1001        $ENABLESERVICE; $STARTSERVICE
1002        echoAndLog "${FUNCNAME}(): Sample DHCP configured in \"$DHCPCFGDIR\"."
1003        return 0
1004}
1005
1006
1007#####################################################################
1008####### Funciones específicas de la instalación de Opengnsys
1009#####################################################################
1010
1011# Copiar ficheros del OpenGnSys Web Console.
1012function installWebFiles()
1013{
1014        echoAndLog "${FUNCNAME}(): Installing web files..."
1015        cp -a $WORKDIR/opengnsys/admin/WebConsole/* $INSTALL_TARGET/www   #*/ comentario para doxigen
1016        if [ $? != 0 ]; then
1017                errorAndLog "${FUNCNAME}(): Error copying web files."
1018                exit 1
1019        fi
1020        find $INSTALL_TARGET/www -name .svn -type d -exec rm -fr {} \; 2>/dev/null
1021        # Descomprimir XAJAX.
1022        unzip -o $WORKDIR/opengnsys/admin/xajax_0.5_standard.zip -d $INSTALL_TARGET/www/xajax
1023        # Cambiar permisos para ficheros especiales.
1024        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/images/{fotos,iconos}
1025        echoAndLog "${FUNCNAME}(): Web files installed successfully."
1026}
1027
1028# Configuración específica de Apache.
1029function installWebConsoleApacheConf()
1030{
1031        if [ $# -ne 2 ]; then
1032                errorAndLog "${FUNCNAME}(): invalid number of parameters"
1033                exit 1
1034        fi
1035
1036        local path_opengnsys_base=$1
1037        local path_apache2_confd=$2
1038        local CONSOLEDIR=${path_opengnsys_base}/www
1039
1040        if [ ! -d $path_apache2_confd ]; then
1041                errorAndLog "${FUNCNAME}(): path to apache2 conf.d can not found, verify your server installation"
1042                return 1
1043        fi
1044
1045        mkdir -p $path_apache2_confd/{sites-available,sites-enabled}
1046
1047        echoAndLog "${FUNCNAME}(): creating apache2 config file.."
1048
1049        # Activar HTTPS.
1050        $APACHESSLMOD
1051        $APACHEENABLESSL
1052        $APACHEMAKECERT
1053
1054        # Genera configuración de consola web a partir del fichero plantilla.
1055        sed -e "s/CONSOLEDIR/${CONSOLEDIR//\//\\/}/g" \
1056                $WORKDIR/opengnsys/server/etc/apache.conf.tmpl > $path_opengnsys_base/etc/apache.conf
1057
1058        ln -fs $path_opengnsys_base/etc/apache.conf $path_apache2_confd/$APACHESITESDIR/$APACHEOGSITE
1059        $APACHEENABLEOG
1060        if [ $? -ne 0 ]; then
1061                errorAndLog "${FUNCNAME}(): config file can't be linked to apache conf, verify your server installation"
1062                return 1
1063        else
1064                echoAndLog "${FUNCNAME}(): config file created and linked, restarting apache daemon"
1065                service=$APACHESERV
1066                $ENABLESERVICE; $STARTSERVICE
1067                return 0
1068        fi
1069}
1070
1071
1072# Crear documentación Doxygen para la consola web.
1073function makeDoxygenFiles()
1074{
1075        echoAndLog "${FUNCNAME}(): Making Doxygen web files..."
1076        $WORKDIR/opengnsys/installer/ogGenerateDoc.sh \
1077                        $WORKDIR/opengnsys/client/engine $INSTALL_TARGET/www
1078        if [ ! -d "$INSTALL_TARGET/www/html" ]; then
1079                errorAndLog "${FUNCNAME}(): unable to create Doxygen web files."
1080                return 1
1081        fi
1082        mv "$INSTALL_TARGET/www/html" "$INSTALL_TARGET/www/api"
1083        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/api
1084        echoAndLog "${FUNCNAME}(): Doxygen web files created successfully."
1085}
1086
1087
1088# Crea la estructura base de la instalación de opengnsys
1089function createDirs()
1090{
1091        if [ $# -ne 1 ]; then
1092                errorAndLog "${FUNCNAME}(): invalid number of parameters"
1093                exit 1
1094        fi
1095
1096        local path_opengnsys_base="$1"
1097
1098        # Crear estructura de directorios.
1099        echoAndLog "${FUNCNAME}(): creating directory paths in $path_opengnsys_base"
1100        mkdir -p $path_opengnsys_base
1101        mkdir -p $path_opengnsys_base/bin
1102        mkdir -p $path_opengnsys_base/client
1103        mkdir -p $path_opengnsys_base/doc
1104        mkdir -p $path_opengnsys_base/etc
1105        mkdir -p $path_opengnsys_base/lib
1106        mkdir -p $path_opengnsys_base/log/clients
1107        ln -fs $path_opengnsys_base/log /var/log/opengnsys
1108        mkdir -p $path_opengnsys_base/sbin
1109        mkdir -p $path_opengnsys_base/www
1110        mkdir -p $path_opengnsys_base/images
1111        mkdir -p $TFTPCFGDIR
1112        ln -fs $TFTPCFGDIR $path_opengnsys_base/tftpboot
1113        mkdir -p $path_opengnsys_base/tftpboot/pxelinux.cfg
1114        mkdir -p $path_opengnsys_base/tftpboot/menu.lst
1115        if [ $? -ne 0 ]; then
1116                errorAndLog "${FUNCNAME}(): error while creating dirs. Do you have write permissions?"
1117                return 1
1118        fi
1119
1120        # Crear usuario ficticio.
1121        if id -u $OPENGNSYS_CLIENT_USER &>/dev/null; then
1122                echoAndLog "${FUNCNAME}(): user \"$OPENGNSYS_CLIENT_USER\" is already created"
1123        else
1124                echoAndLog "${FUNCNAME}(): creating OpenGnSys user"
1125                useradd $OPENGNSYS_CLIENT_USER 2>/dev/null
1126                if [ $? -ne 0 ]; then
1127                        errorAndLog "${FUNCNAME}(): error creating OpenGnSys user"
1128                        return 1
1129                fi
1130        fi
1131
1132        # Establecer los permisos básicos.
1133        echoAndLog "${FUNCNAME}(): setting directory permissions"
1134        chmod -R 775 $path_opengnsys_base/{log/clients,images}
1135        chown -R :$OPENGNSYS_CLIENT_USER $path_opengnsys_base/{log/clients,images}
1136        if [ $? -ne 0 ]; then
1137                errorAndLog "${FUNCNAME}(): error while setting permissions"
1138                return 1
1139        fi
1140
1141        # Mover el fichero de registro de instalación al directorio de logs.
1142        echoAndLog "${FUNCNAME}(): moving installation log file"
1143        mv $LOG_FILE $OGLOGFILE && LOG_FILE=$OGLOGFILE
1144        chmod 600 $LOG_FILE
1145
1146        echoAndLog "${FUNCNAME}(): directory paths created"
1147        return 0
1148}
1149
1150# Copia ficheros de configuración y ejecutables genéricos del servidor.
1151function copyServerFiles ()
1152{
1153        if [ $# -ne 1 ]; then
1154                errorAndLog "${FUNCNAME}(): invalid number of parameters"
1155                exit 1
1156        fi
1157
1158        local path_opengnsys_base="$1"
1159
1160        local SOURCES=( server/tftpboot \
1161                        server/bin \
1162                        repoman/bin \
1163                        installer/opengnsys_uninstall.sh \
1164                        installer/opengnsys_update.sh \
1165                        installer/install_ticket_wolunicast.sh \
1166                        doc )
1167        local TARGETS=( tftpboot \
1168                        bin \
1169                        bin \
1170                        lib \
1171                        lib \
1172                        lib \
1173                        doc )
1174
1175        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
1176                errorAndLog "${FUNCNAME}(): inconsistent number of array items"
1177                exit 1
1178        fi
1179
1180        echoAndLog "${FUNCNAME}(): copying files to server directories"
1181
1182        pushd $WORKDIR/opengnsys
1183        local i
1184        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
1185                if [ -f "${SOURCES[$i]}" ]; then
1186                        echoAndLog "Copying ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
1187                        cp -a "${SOURCES[$i]}" "${path_opengnsys_base}/${TARGETS[$i]}"
1188                elif [ -d "${SOURCES[$i]}" ]; then
1189                        echoAndLog "Copying content of ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
1190                        cp -a "${SOURCES[$i]}"/* "${path_opengnsys_base}/${TARGETS[$i]}"
1191        else
1192                        echoAndLog "Warning: Unable to copy ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
1193                fi
1194        done
1195        popd
1196}
1197
1198####################################################################
1199### Funciones de compilación de código fuente de servicios
1200####################################################################
1201
1202# Compilar los servicios de OpenGnSys
1203function servicesCompilation ()
1204{
1205        local hayErrores=0
1206
1207        # Compilar OpenGnSys Server
1208        echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Admin Server"
1209        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer
1210        make && mv ogAdmServer $INSTALL_TARGET/sbin
1211        if [ $? -ne 0 ]; then
1212                echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Server"
1213                hayErrores=1
1214        fi
1215        popd
1216        # Compilar OpenGnSys Repository Manager
1217        echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Repository Manager"
1218        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo
1219        make && mv ogAdmRepo $INSTALL_TARGET/sbin
1220        if [ $? -ne 0 ]; then
1221                echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Repository Manager"
1222                hayErrores=1
1223        fi
1224        popd
1225        # Compilar OpenGnSys Agent
1226        echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Agent"
1227        pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent
1228        make && mv ogAdmAgent $INSTALL_TARGET/sbin
1229        if [ $? -ne 0 ]; then
1230                echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Agent"
1231                hayErrores=1
1232        fi
1233        popd   
1234        # Compilar OpenGnSys Client
1235        echoAndLog "${FUNCNAME}(): Compiling OpenGnSys Admin Client"
1236        pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient
1237        make && mv ogAdmClient ../../../../client/shared/bin
1238        if [ $? -ne 0 ]; then
1239                echoAndLog "${FUNCNAME}(): error while compiling OpenGnSys Admin Client"
1240                hayErrores=1
1241        fi
1242        popd
1243
1244        return $hayErrores
1245}
1246
1247####################################################################
1248### Funciones de copia de la Interface de administración
1249####################################################################
1250
1251# Copiar carpeta de Interface
1252function copyInterfaceAdm ()
1253{
1254        local hayErrores=0
1255       
1256        # Crear carpeta y copiar Interface
1257        echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
1258        cp -ar $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client/interfaceAdm
1259        if [ $? -ne 0 ]; then
1260                echoAndLog "${FUNCNAME}(): error while copying Administration Interface Folder"
1261                hayErrores=1
1262        fi
1263        chown $OPENGNSYS_CLIENT_USER:$OPENGNSYS_CLIENT_USER $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
1264        chmod 700 $INSTALL_TARGET/client/interfaceAdm/CambiarAcceso
1265
1266        return $hayErrores
1267}
1268
1269####################################################################
1270### Funciones instalacion cliente opengnsys
1271####################################################################
1272
1273function copyClientFiles()
1274{
1275        local errstatus=0
1276
1277        echoAndLog "${FUNCNAME}(): Copying OpenGnSys Client files."
1278        cp -a $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
1279        if [ $? -ne 0 ]; then
1280                errorAndLog "${FUNCNAME}(): error while copying client estructure"
1281                errstatus=1
1282        fi
1283        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
1284       
1285        echoAndLog "${FUNCNAME}(): Copying OpenGnSys Cloning Engine files."
1286        mkdir -p $INSTALL_TARGET/client/lib/engine/bin
1287        cp -a $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
1288        if [ $? -ne 0 ]; then
1289                errorAndLog "${FUNCNAME}(): error while copying engine files"
1290                errstatus=1
1291        fi
1292       
1293        if [ $errstatus -eq 0 ]; then
1294                echoAndLog "${FUNCNAME}(): client copy files success."
1295        else
1296                errorAndLog "${FUNCNAME}(): client copy files with errors"
1297        fi
1298
1299        return $errstatus
1300}
1301
1302
1303# Crear cliente OpenGnSys 1.0.2 y posteriores.
1304function clientCreate()
1305{
1306        local DOWNLOADURL="http://$OPENGNSYS_SERVER/downloads"
1307        local FILENAME=ogLive-quantal-3.7.6-030706-generic-r3619.iso    # 1.0.5-rc2
1308        local TARGETFILE=$INSTALL_TARGET/lib/$FILENAME
1309        local TMPDIR=/tmp/${FILENAME%.iso}
1310 
1311        # Descargar cliente, si es necesario.
1312        if [ -s $PROGRAMDIR/$FILENAME ]; then
1313                echoAndLog "${FUNCNAME}(): Moving $PROGRAMDIR/$FILENAME file to $(dirname $TARGETFILE)"
1314                mv $PROGRAMDIR/$FILENAME $TARGETFILE
1315        else
1316                echoAndLog "${FUNCNAME}(): Loading Client"
1317                wget $DOWNLOADURL/$FILENAME -O $TARGETFILE
1318        fi
1319        if [ ! -s $TARGETFILE ]; then
1320                errorAndLog "${FUNCNAME}(): Error loading OpenGnSys Client"
1321                return 1
1322        fi
1323        # Montar imagen, copiar cliente ogclient y desmontar.
1324        echoAndLog "${FUNCNAME}(): Copying Client files"
1325        mkdir -p $TMPDIR
1326        mount -o loop,ro $TARGETFILE $TMPDIR
1327        cp -av $TMPDIR/ogclient $INSTALL_TARGET/tftpboot
1328        umount $TMPDIR
1329        rmdir $TMPDIR
1330        # Asignar la clave cliente para acceso a Samba.
1331        echoAndLog "${FUNCNAME}(): Set client access key"
1332        echo -ne "$OPENGNSYS_CLIENT_PASSWD\n$OPENGNSYS_CLIENT_PASSWD\n" | \
1333                        $INSTALL_TARGET/bin/setsmbpass
1334
1335        # Establecer los permisos.
1336        find -L $INSTALL_TARGET/tftpboot -type d -exec chmod 755 {} \;
1337        find -L $INSTALL_TARGET/tftpboot -type f -exec chmod 644 {} \;
1338        chown -R :$OPENGNSYS_CLIENT_USER $INSTALL_TARGET/tftpboot/ogclient
1339        chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/tftpboot/{menu.lst,pxelinux.cfg}
1340
1341        # Ofrecer md5 del kernel y vmlinuz para ogupdateinitrd en cache
1342        cp -av $INSTALL_TARGET/tftpboot/ogclient/ogvmlinuz* $INSTALL_TARGET/tftpboot
1343        cp -av $INSTALL_TARGET/tftpboot/ogclient/oginitrd.img* $INSTALL_TARGET/tftpboot
1344
1345        echoAndLog "${FUNCNAME}(): Client generation success"
1346}
1347
1348
1349# Configuración básica de servicios de OpenGnSys
1350function openGnsysConfigure()
1351{
1352        local i=0
1353        local dev=""
1354        local CONSOLEURL
1355
1356        echoAndLog "${FUNCNAME}(): Copying init files."
1357        cp -p $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys
1358        cp -p $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys
1359        cp -p $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepoAux $INSTALL_TARGET/sbin
1360        echoAndLog "${FUNCNAME}(): Creating cron files."
1361        echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/opengnsys.cron ] && $INSTALL_TARGET/bin/opengnsys.cron" > /etc/cron.d/opengnsys
1362        echo "* * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator
1363        echo "5 * * * *   root   [ -x $INSTALL_TARGET/bin/torrent-tracker ] && $INSTALL_TARGET/bin/torrent-tracker" > /etc/cron.d/torrenttracker
1364
1365        echoAndLog "${FUNCNAME}(): Creating logrotate configuration file."
1366        sed -e "s/OPENGNSYSDIR/${INSTALL_TARGET//\//\\/}/g" \
1367                $WORKDIR/opengnsys/server/etc/logrotate.tmpl > /etc/logrotate.d/opengnsys
1368
1369        echoAndLog "${FUNCNAME}(): Creating OpenGnSys config files."
1370        for dev in ${DEVICE[*]}; do
1371                if [ -n "${SERVERIP[i]}" ]; then
1372                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1373                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
1374                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
1375                            -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \
1376                                $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer/ogAdmServer.cfg > $INSTALL_TARGET/etc/ogAdmServer-$dev.cfg
1377                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1378                                $WORKDIR/opengnsys/admin/Sources/Services/ogAdmRepo/ogAdmRepo.cfg > $INSTALL_TARGET/etc/ogAdmRepo-$dev.cfg
1379                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1380                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
1381                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
1382                            -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \
1383                                $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent/ogAdmAgent.cfg > $INSTALL_TARGET/etc/ogAdmAgent-$dev.cfg
1384                        CONSOLEURL="http://${SERVERIP[i]}/opengnsys"
1385                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1386                            -e "s/DBUSER/$OPENGNSYS_DB_USER/g" \
1387                            -e "s/DBPASSWORD/$OPENGNSYS_DB_PASSWD/g" \
1388                            -e "s/DATABASE/$OPENGNSYS_DATABASE/g" \
1389                            -e "s/OPENGNSYSURL/${CONSOLEURL//\//\\/}/g" \
1390                                $INSTALL_TARGET/www/controlacceso.php > $INSTALL_TARGET/www/controlacceso-$dev.php
1391                        sed -e "s/SERVERIP/${SERVERIP[i]}/g" \
1392                            -e "s/OPENGNSYSURL/${CONSOLEURL//\//\\/}/g" \
1393                                $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient/ogAdmClient.cfg > $INSTALL_TARGET/client/etc/ogAdmClient-$dev.cfg
1394                        if [ "$dev" == "$DEFAULTDEV" ]; then
1395                                OPENGNSYS_CONSOLEURL="${CONSOLEURL/http:/https:}"
1396                        fi
1397                fi
1398                let i++
1399        done
1400        ln -f $INSTALL_TARGET/etc/ogAdmServer-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmServer.cfg
1401        ln -f $INSTALL_TARGET/etc/ogAdmRepo-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmRepo.cfg
1402        ln -f $INSTALL_TARGET/etc/ogAdmAgent-$DEFAULTDEV.cfg $INSTALL_TARGET/etc/ogAdmAgent.cfg
1403        ln -f $INSTALL_TARGET/client/etc/ogAdmClient-$DEFAULTDEV.cfg $INSTALL_TARGET/client/etc/ogAdmClient.cfg
1404        ln -f $INSTALL_TARGET/www/controlacceso-$DEFAULTDEV.php $INSTALL_TARGET/www/controlacceso.php
1405        chown root:root $INSTALL_TARGET/etc/{ogAdmServer,ogAdmAgent}*.cfg
1406        chmod 600 $INSTALL_TARGET/etc/{ogAdmServer,ogAdmAgent}*.cfg
1407        chown $APACHE_RUN_USER:$APACHE_RUN_GROUP $INSTALL_TARGET/www/controlacceso*.php
1408        chmod 600 $INSTALL_TARGET/www/controlacceso*.php
1409        echoAndLog "${FUNCNAME}(): Starting OpenGnSys services."
1410        service="opengnsys"
1411        $ENABLESERVICE; $STARTSERVICE
1412}
1413
1414
1415#####################################################################
1416#######  Función de resumen informativo de la instalación
1417#####################################################################
1418
1419function installationSummary()
1420{
1421        # Crear fichero de versión y revisión, si no existe.
1422        local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
1423        local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
1424        [ -f $VERSIONFILE ] || echo "OpenGnSys" >$VERSIONFILE
1425        perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
1426
1427        # Mostrar información.
1428        echo
1429        echoAndLog "OpenGnSys Installation Summary"
1430        echo       "=============================="
1431        echoAndLog "Project version:                  $(cat $VERSIONFILE 2>/dev/null)"
1432        echoAndLog "Installation directory:           $INSTALL_TARGET"
1433        echoAndLog "Installation log file:            $LOG_FILE"
1434        echoAndLog "Repository directory:             $INSTALL_TARGET/images"
1435        echoAndLog "DHCP configuration directory:     $DHCPCFGDIR"
1436        echoAndLog "TFTP configuration directory:     $TFTPCFGDIR"
1437        echoAndLog "Samba configuration directory:    $SAMBACFGDIR"
1438        echoAndLog "Web Console URL:                  $OPENGNSYS_CONSOLEURL"
1439        echoAndLog "Web Console admin user:           $OPENGNSYS_DB_USER"
1440        echoAndLog "Web Console admin password:       $OPENGNSYS_DB_PASSWD"
1441        echo
1442        echoAndLog "Post-Installation Instructions:"
1443        echo       "==============================="
1444        echoAndLog "Change IPTables and SELinux system configuration, if needed."
1445        echoAndLog "Review or edit all configuration files."
1446        echoAndLog "Insert DHCP configuration data and restart service."
1447        echoAndLog "Optional: Log-in as Web Console admin user."
1448        echoAndLog " - Review default Organization data and assign access to users."
1449        echoAndLog "Log-in as Web Console organization user."
1450        echoAndLog " - Insert OpenGnSys data (labs, computers, menus, etc)."
1451echo
1452}
1453
1454
1455
1456#####################################################################
1457####### Proceso de instalación de OpenGnSys
1458#####################################################################
1459
1460echoAndLog "OpenGnSys installation begins at $(date)"
1461pushd $WORKDIR
1462
1463# Detectar datos iniciales de auto-configuración del instalador.
1464autoConfigure
1465
1466# Detectar parámetros de red y comprobar si hay conexión.
1467getNetworkSettings
1468if [ $? -ne 0 ]; then
1469        errorAndLog "Error reading default network settings."
1470        exit 1
1471fi
1472checkNetworkConnection
1473if [ $? -ne 0 ]; then
1474        errorAndLog "Error connecting to server. Causes:"
1475        errorAndLog " - Network is unreachable, review devices parameters."
1476        errorAndLog " - You are inside a private network, configure the proxy service."
1477        errorAndLog " - Server is temporally down, try agian later."
1478        exit 1
1479fi
1480
1481# Detener servicios de OpenGnSys, si están activos previamente.
1482[ -f /etc/init.d/opengnsys ] && /etc/init.d/opengnsys stop
1483
1484# Actualizar repositorios
1485updatePackageList
1486
1487# Instalación de dependencias (paquetes de sistema operativo).
1488declare -a notinstalled
1489checkDependencies DEPENDENCIES notinstalled
1490if [ $? -ne 0 ]; then
1491        installDependencies notinstalled
1492        if [ $? -ne 0 ]; then
1493                echoAndLog "Error while installing some dependeces, please verify your server installation before continue"
1494                exit 1
1495        fi
1496fi
1497if [ -n "$INSTALLEXTRADEPS" ]; then
1498        echoAndLog "Installing extra dependencies"
1499        for (( i=0; i<${#INSTALLEXTRADEPS[*]}; i++ )); do
1500                eval ${INSTALLEXTRADEPS[i]}
1501        done
1502fi     
1503
1504# Detectar datos de auto-configuración después de instalar paquetes.
1505autoConfigurePost
1506
1507# Arbol de directorios de OpenGnSys.
1508createDirs ${INSTALL_TARGET}
1509if [ $? -ne 0 ]; then
1510        errorAndLog "Error while creating directory paths!"
1511        exit 1
1512fi
1513
1514# Si es necesario, descarga el repositorio de código en directorio temporal
1515if [ $USESVN -eq 1 ]; then
1516        svnExportCode $SVN_URL
1517        if [ $? -ne 0 ]; then
1518                errorAndLog "Error while getting code from svn"
1519                exit 1
1520        fi
1521else
1522        ln -fs "$(dirname $PROGRAMDIR)" opengnsys
1523fi
1524
1525# Compilar código fuente de los servicios de OpenGnSys.
1526servicesCompilation
1527if [ $? -ne 0 ]; then
1528        errorAndLog "Error while compiling OpenGnsys services"
1529        exit 1
1530fi
1531
1532# Copiar carpeta Interface entre administración y motor de clonación.
1533copyInterfaceAdm
1534if [ $? -ne 0 ]; then
1535        errorAndLog "Error while copying Administration Interface"
1536        exit 1
1537fi
1538
1539# Configuración de TFTP.
1540tftpConfigure
1541
1542# Configuración de Samba.
1543smbConfigure
1544if [ $? -ne 0 ]; then
1545        errorAndLog "Error while configuring Samba server!"
1546        exit 1
1547fi
1548
1549# Configuración de Rsync.
1550rsyncConfigure
1551
1552# Configuración ejemplo DHCP.
1553dhcpConfigure
1554if [ $? -ne 0 ]; then
1555        errorAndLog "Error while copying your dhcp server files!"
1556        exit 1
1557fi
1558
1559# Copiar ficheros de servicios OpenGnSys Server.
1560copyServerFiles ${INSTALL_TARGET}
1561if [ $? -ne 0 ]; then
1562        errorAndLog "Error while copying the server files!"
1563        exit 1
1564fi
1565
1566# Instalar Base de datos de OpenGnSys Admin.
1567isInArray notinstalled "mysql-server"
1568if [ $? -eq 0 ]; then
1569        service=$MYSQLSERV
1570        $ENABLESERVICE; $STARTSERVICE
1571        mysqlSetRootPassword "${MYSQL_ROOT_PASSWORD}"
1572else
1573        mysqlGetRootPassword
1574fi
1575
1576mysqlTestConnection "${MYSQL_ROOT_PASSWORD}"
1577if [ $? -ne 0 ]; then
1578        errorAndLog "Error while connection to mysql"
1579        exit 1
1580fi
1581mysqlDbExists ${OPENGNSYS_DATABASE}
1582if [ $? -ne 0 ]; then
1583        echoAndLog "Creating Web Console database"
1584        mysqlCreateDb ${OPENGNSYS_DATABASE}
1585        if [ $? -ne 0 ]; then
1586                errorAndLog "Error while creating Web Console database"
1587                exit 1
1588        fi
1589else
1590        echoAndLog "Web Console database exists, ommiting creation"
1591fi
1592
1593mysqlCheckUserExists ${OPENGNSYS_DB_USER}
1594if [ $? -ne 0 ]; then
1595        echoAndLog "Creating user in database"
1596        mysqlCreateAdminUserToDb ${OPENGNSYS_DATABASE} ${OPENGNSYS_DB_USER} "${OPENGNSYS_DB_PASSWD}"
1597        if [ $? -ne 0 ]; then
1598                errorAndLog "Error while creating database user"
1599                exit 1
1600        fi
1601
1602fi
1603
1604mysqlCheckDbIsEmpty ${OPENGNSYS_DATABASE}
1605if [ $? -eq 0 ]; then
1606        echoAndLog "Creating tables..."
1607        if [ -f $WORKDIR/$OPENGNSYS_DB_CREATION_FILE ]; then
1608                mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_CREATION_FILE
1609        else
1610                errorAndLog "Unable to locate $WORKDIR/$OPENGNSYS_DB_CREATION_FILE!!"
1611                exit 1
1612        fi
1613else
1614        # Si existe fichero ogBDAdmin-VersLocal-VersRepo.sql; aplicar cambios.
1615        INSTVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt)
1616        REPOVERSION=$(awk '{print $2}' $WORKDIR/opengnsys/doc/VERSION.txt)
1617        OPENGNSYS_DB_UPDATE_FILE="opengnsys/admin/Database/$OPENGNSYS_DATABASE-$INSTVERSION-$REPOVERSION.sql"
1618        if [ -f $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE ]; then
1619                echoAndLog "Updating tables from version $INSTVERSION to $REPOVERSION"
1620                mysqlImportSqlFileToDb ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_UPDATE_FILE
1621        else
1622                echoAndLog "Database unchanged."
1623        fi
1624fi
1625# Eliminar fichero temporal con credenciales de acceso a MySQL.
1626rm -f $TMPMYCNF
1627
1628# copiando paqinas web
1629installWebFiles
1630# Generar páqinas web de documentación de la API
1631makeDoxygenFiles
1632
1633# creando configuracion de apache2
1634installWebConsoleApacheConf $INSTALL_TARGET $APACHECFGDIR
1635if [ $? -ne 0 ]; then
1636        errorAndLog "Error configuring Apache for OpenGnSys Admin"
1637        exit 1
1638fi
1639
1640popd
1641
1642# Crear la estructura de los accesos al servidor desde el cliente (shared)
1643copyClientFiles
1644if [ $? -ne 0 ]; then
1645        errorAndLog "Error creating client structure"
1646fi
1647
1648# Crear la estructura del cliente de OpenGnSys
1649clientCreate
1650if [ $? -ne 0 ]; then
1651        errorAndLog "Error creating client"
1652        exit 1
1653fi
1654
1655# Configuración de servicios de OpenGnSys
1656openGnsysConfigure
1657
1658# Mostrar sumario de la instalación e instrucciones de post-instalación.
1659installationSummary
1660
1661#rm -rf $WORKDIR
1662echoAndLog "OpenGnSys installation finished at $(date)"
1663exit 0
1664
Note: See TracBrowser for help on using the repository browser.