source: installer/opengnsys_installer.sh @ ca68867

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 ca68867 was 35b0ef1, checked in by ramon <ramongomez@…>, 12 years ago

Instalador no muestra datos de acceso a la consola web.

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