source: installer/opengnsys_installer.sh @ e24b042

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 e24b042 was dc762088, checked in by albertogp <albertogp@…>, 12 years ago

branches-version1.0
Corrigiendo error en los ficheros de instalación y actualización
en la línea de /etc/cron.d fichero deletepreimage 1369 y 629 respectivamente

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

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