source: installer/opengnsys_installer.sh @ b6906f7

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 b6906f7 was b6906f7, checked in by ramon <ramongomez@…>, 16 years ago

Cambios en OpenGNSys Installer.

git-svn-id: https://opengnsys.es/svn/trunk@491 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 22.1 KB
Line 
1#!/bin/bash
2
3#####################################################################
4####### Script instalador OpenGnsys
5####### autor: Luis Guillén <lguillen@unizar.es>
6#####################################################################
7
8
9WORKDIR=/tmp/opengnsys_installer
10LOG_FILE=$WORKDIR/installation.log
11
12# Array con las dependencias
13DEPENDENCIES=( subversion php5 mysql-server nfs-kernel-server dhcp3-server udpcast bittorrent apache2 php5 mysql-server php5-mysql tftpd-hpa syslinux openbsd-inetd update-inetd build-essential cmake qt4-qmake libqt4-dev )
14
15INSTALL_TARGET=/opt/opengnsys
16
17MYSQL_ROOT_PASSWORD="passwordroot"
18
19# conexión al svn
20SVN_URL=svn://www.informatica.us.es:3690/opengnsys/trunk
21
22# Datos de base de datos
23OPENGNSYS_DATABASE=ogBDAdmin
24OPENGNSYS_DB_USER=usuog
25OPENGNSYS_DB_PASSWD=passusuog
26OPENGNSYS_DB_CREATION_FILE=opengnsys/admin/Database/ogBDAdmin.sql
27
28USUARIO=`whoami`
29
30if [ $USUARIO != 'root' ]
31then
32        echo "ERROR: this program must run under root privileges!!"
33        exit 1
34fi
35
36
37mkdir -p $WORKDIR
38pushd $WORKDIR
39
40#####################################################################
41####### Algunas funciones útiles de propósito general:
42#####################################################################
43getDateTime()
44{
45        echo `date +%Y%m%d-%H%M%S`
46}
47
48# Escribe a fichero y muestra por pantalla
49echoAndLog()
50{
51        echo $1
52        FECHAHORA=`getDateTime`
53        echo "$FECHAHORA;$SSH_CLIENT;$1" >> $LOG_FILE
54}
55
56errorAndLog()
57{
58        echo "ERROR: $1"
59        FECHAHORA=`getDateTime`
60        echo "$FECHAHORA;$SSH_CLIENT;ERROR: $1" >> $LOG_FILE
61}
62
63# comprueba si el elemento pasado en $2 esta en el array $1
64isInArray()
65{
66        if [ $# -ne 2 ]; then
67                errorAndLog "isInArray(): invalid number of parameters"
68                exit 1
69        fi
70
71        echoAndLog "isInArray(): checking if $2 is in $1"
72        local deps
73        eval "deps=( \"\${$1[@]}\" )"
74        elemento=$2
75
76        local is_in_array=1
77        # copia local del array del parametro 1
78        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
79        do
80                if [ "${deps[$i]}" = "${elemento}" ]; then
81                        echoAndLog "isInArray(): $elemento found in array"
82                        is_in_array=0
83                fi
84        done
85
86        if [ $is_in_array -ne 0 ]; then
87                echoAndLog "isInArray(): $elemento NOT found in array"
88        fi
89
90        return $is_in_array
91
92}
93
94#####################################################################
95####### Funciones de manejo de paquetes Debian
96#####################################################################
97
98checkPackage()
99{
100        package=$1
101        if [ -z $package ]; then
102                errorAndLog "checkPackage(): parameter required"
103                exit 1
104        fi
105        echoAndLog "checkPackage(): checking if package $package exists"
106        dpkg -L $package &>/dev/null
107        if [ $? -eq 0 ]; then
108                echoAndLog "checkPackage(): package $package exists"
109                return 0
110        else
111                echoAndLog "checkPackage(): package $package doesn't exists"
112                return 1
113        fi
114}
115
116# recibe array con dependencias
117# por referencia deja un array con las dependencias no resueltas
118# devuelve 1 si hay alguna dependencia no resuelta
119checkDependencies()
120{
121        if [ $# -ne 2 ]; then
122                errorAndLog "checkDependencies(): invalid number of parameters"
123                exit 1
124        fi
125
126        echoAndLog "checkDependencies(): checking dependences"
127        uncompletedeps=0
128
129        # copia local del array del parametro 1
130        local deps
131        eval "deps=( \"\${$1[@]}\" )"
132
133        declare -a local_notinstalled
134
135        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
136        do
137                checkPackage ${deps[$i]}
138                if [ $? -ne 0 ]; then
139                        local_notinstalled[$uncompletedeps]=$package
140                        let uncompletedeps=uncompletedeps+1
141                fi
142        done
143
144        # relleno el array especificado en $2 por referencia
145        for (( i = 0 ; i < ${#local_notinstalled[@]} ; i++ ))
146        do
147                eval "${2}[$i]=${local_notinstalled[$i]}"
148        done
149
150        # retorna el numero de paquetes no resueltos
151        echoAndLog "checkDependencies(): dependencies uncompleted: $uncompletedeps"
152        return $uncompletedeps
153}
154
155# Recibe un array con las dependencias y lo instala
156installDependencies()
157{
158        if [ $# -ne 1 ]; then
159                errorAndLog "installDependencies(): invalid number of parameters"
160                exit 1
161        fi
162        echoAndLog "installDependencies(): installing uncompleted dependencies"
163
164        # copia local del array del parametro 1
165        local deps
166        eval "deps=( \"\${$1[@]}\" )"
167
168        local string_deps=""
169        for (( i = 0 ; i < ${#deps[@]} ; i++ ))
170        do
171                string_deps="$string_deps ${deps[$i]}"
172        done
173
174        if [ -z "${string_deps}" ]; then
175                errorAndLog "installDependencies(): array of dependeces is empty"
176                exit 1
177        fi
178
179        OLD_DEBIAN_FRONTEND=$DEBIAN_FRONTEND
180        export DEBIAN_FRONTEND=noninteractive
181
182        echoAndLog "installDependencies(): now ${string_deps} will be installed"
183        apt-get -y install --force-yes ${string_deps}
184        if [ $? -ne 0 ]; then
185                errorAndLog "installDependencies(): error installing dependencies"
186                return 1
187        fi
188
189        DEBIAN_FRONTEND=$OLD_DEBIAN_FRONTEND
190        echoAndLog "installDependencies(): dependencies installed"
191}
192
193#####################################################################
194####### Funciones para el manejo de bases de datos
195#####################################################################
196
197# This function set password to root
198mysqlSetRootPassword()
199{
200        if [ $# -ne 1 ]; then
201                errorAndLog "mysqlSetRootPassword(): invalid number of parameters"
202                exit 1
203        fi
204
205        local root_mysql=$1
206        echoAndLog "mysqlSetRootPassword(): setting root password in MySQL server"
207        /usr/bin/mysqladmin -u root password ${root_mysql}
208        if [ $? -ne 0 ]; then
209                errorAndLog "mysqlSetRootPassword(): error while setting root password in MySQL server"
210                return 1
211        fi
212        echoAndLog "mysqlSetRootPassword(): root password saved!"
213        return 0
214}
215
216# Si el servicio mysql esta ya instalado cambia la variable de la clave del root por la ya existente
217mysqlGetRootPassword(){
218        local pass_mysql
219        local pass_mysql2
220        stty -echo
221        echo "Existe un servicio mysql ya instalado"
222        read -p  "Insertar clave de root de Mysql: " pass_mysql
223        echo ""
224        read -p "Confirmar clave:" pass_mysql2
225        echo ""
226        stty echo
227        if [ "$pass_mysql" == "$pass_mysql2" ] ;then
228                MYSQL_ROOT_PASSWORD=$pass_mysql
229                echo "La clave es: ${MYSQL_ROOT_PASSWORD}"
230                return 0
231        else
232                echo "Las claves no coinciden no se configura la clave del servidor de base de datos."
233                echo "las operaciones con la base de datos daran error"
234                return 1
235        fi
236
237
238}
239
240# comprueba si puede conectar con mysql con el usuario root
241function mysqlTestConnection()
242{
243        if [ $# -ne 1 ]; then
244                errorAndLog "mysqlTestConnection(): invalid number of parameters"
245                exit 1
246        fi
247
248        local root_password="${1}"
249        echoAndLog "mysqlTestConnection(): checking connection to mysql..."
250        echo "" | mysql -uroot -p"${root_password}"
251        if [ $? -ne 0 ]; then
252                errorAndLog "mysqlTestConnection(): connection to mysql failed, check root password and if daemon is running!"
253                return 1
254        else
255                echoAndLog "mysqlTestConnection(): connection success"
256                return 0
257        fi
258}
259
260# comprueba si la base de datos existe
261function mysqlDbExists()
262{
263        if [ $# -ne 2 ]; then
264                errorAndLog "mysqlDbExists(): invalid number of parameters"
265                exit 1
266        fi
267
268        local root_password="${1}"
269        local database=$2
270        echoAndLog "mysqlDbExists(): checking if $database exists..."
271        echo "show databases" | mysql -uroot -p"${root_password}" | grep "^${database}$"
272        if [ $? -ne 0 ]; then
273                echoAndLog "mysqlDbExists():database $database doesn't exists"
274                return 1
275        else
276                echoAndLog "mysqlDbExists():database $database exists"
277                return 0
278        fi
279}
280
281function mysqlCheckDbIsEmpty()
282{
283        if [ $# -ne 2 ]; then
284                errorAndLog "mysqlCheckDbIsEmpty(): invalid number of parameters"
285                exit 1
286        fi
287
288        local root_password="${1}"
289        local database=$2
290        echoAndLog "mysqlCheckDbIsEmpty(): checking if $database is empty..."
291        num_tablas=`echo "show tables" | mysql -uroot -p"${root_password}" "${database}" | wc -l`
292        if [ $? -ne 0 ]; then
293                errorAndLog "mysqlCheckDbIsEmpty(): error executing query, check database and root password"
294                exit 1
295        fi
296
297        if [ $num_tablas -eq 0 ]; then
298                echoAndLog "mysqlCheckDbIsEmpty():database $database is empty"
299                return 0
300        else
301                echoAndLog "mysqlCheckDbIsEmpty():database $database has tables"
302                return 1
303        fi
304
305}
306
307
308function mysqlImportSqlFileToDb()
309{
310        if [ $# -ne 3 ]; then
311                errorAndLog "mysqlImportSqlFileToDb(): invalid number of parameters"
312                exit 1
313        fi
314
315        local root_password="${1}"
316        local database=$2
317        local sqlfile=$3
318
319        if [ ! -f $sqlfile ]; then
320                errorAndLog "mysqlImportSqlFileToDb(): Unable to locate $sqlfile!!"
321                return 1
322        fi
323
324        echoAndLog "mysqlImportSqlFileToDb(): importing sql file to ${database}..."
325        mysql -uroot -p"${root_password}" "${database}" < $sqlfile
326        if [ $? -ne 0 ]; then
327                errorAndLog "mysqlImportSqlFileToDb(): error while importing $sqlfile in database $database"
328                return 1
329        fi
330        echoAndLog "mysqlImportSqlFileToDb(): file imported to database $database"
331        return 0
332}
333
334# Crea la base de datos
335function mysqlCreateDb()
336{
337        if [ $# -ne 2 ]; then
338                errorAndLog "mysqlCreateDb(): invalid number of parameters"
339                exit 1
340        fi
341
342        local root_password="${1}"
343        local database=$2
344
345        echoAndLog "mysqlCreateDb(): creating database..."
346        mysqladmin -u root --password="${root_password}" create $database
347        if [ $? -ne 0 ]; then
348                errorAndLog "mysqlCreateDb(): error while creating database $database"
349                return 1
350        fi
351        errorAndLog "mysqlCreateDb(): database $database created"
352        return 0
353}
354
355
356function mysqlCheckUserExists()
357{
358        if [ $# -ne 2 ]; then
359                errorAndLog "mysqlCheckUserExists(): invalid number of parameters"
360                exit 1
361        fi
362
363        local root_password="${1}"
364        local userdb=$2
365
366        echoAndLog "mysqlCheckUserExists(): checking if $userdb exists..."
367        echo "select user from user where user='${userdb}'\\G" |mysql -uroot -p"${root_password}" mysql | grep user
368        if [ $? -ne 0 ]; then
369                echoAndLog "mysqlCheckUserExists(): user doesn't exists"
370                return 1
371        else
372                echoAndLog "mysqlCheckUserExists(): user already exists"
373                return 0
374        fi
375
376}
377
378# Crea un usuario administrativo para la base de datos
379function mysqlCreateAdminUserToDb()
380{
381        if [ $# -ne 4 ]; then
382                errorAndLog "mysqlCreateAdminUserToDb(): invalid number of parameters"
383                exit 1
384        fi
385
386        local root_password=$1
387        local database=$2
388        local userdb=$3
389        local passdb=$4
390
391        echoAndLog "mysqlCreateAdminUserToDb(): creating admin user ${userdb} to database ${database}"
392
393        cat > $WORKDIR/create_${database}.sql <<EOF
394GRANT USAGE ON *.* TO '${userdb}'@'localhost' IDENTIFIED BY '${passdb}' ;
395GRANT ALL PRIVILEGES ON ${database}.* TO '${userdb}'@'localhost' WITH GRANT OPTION ;
396FLUSH PRIVILEGES ;
397EOF
398        mysql -u root --password=${root_password} < $WORKDIR/create_${database}.sql
399        if [ $? -ne 0 ]; then
400                errorAndLog "mysqlCreateAdminUserToDb(): error while creating user in mysql"
401                rm -f $WORKDIR/create_${database}.sql
402                return 1
403        else
404                echoAndLog "mysqlCreateAdminUserToDb(): user created ok"
405                rm -f $WORKDIR/create_${database}.sql
406                return 0
407        fi
408}
409
410
411#####################################################################
412####### Funciones para el manejo de Subversion
413#####################################################################
414
415svnCheckoutCode()
416{
417        if [ $# -ne 1 ]; then
418                errorAndLog "svnCheckoutCode(): invalid number of parameters"
419                exit 1
420        fi
421
422        local url=$1
423
424        echoAndLog "svnCheckoutCode(): downloading subversion code..."
425
426        /usr/bin/svn co "${url}" opengnsys
427        if [ $? -ne 0 ]; then
428                errorAndLog "svnCheckoutCode(): error getting code from ${url}, verify your user and password"
429                return 1
430        fi
431        echoAndLog "svnCheckoutCode(): subversion code downloaded"
432        return 0
433}
434
435############################################################
436### Esqueleto para el Servicio pxe y contenedor tftpboot ###
437############################################################
438
439function tftpConfigure() {
440        echo "Configurando el servicio tftp"
441        basetftp=/var/lib/tftpboot
442
443        # reiniciamos demonio internet ????? porque ????
444        /etc/init.d/openbsd-inetd start
445
446        # preparacion contenedor tftpboot
447        cp -pr /usr/lib/syslinux/ ${basetftp}/syslinux
448        cp /usr/lib/syslinux/pxelinux.0 ${basetftp}
449        # prepamos el directorio de la configuracion de pxe
450        mkdir -p ${basetftp}/pxelinux.cfg
451        cat > ${basetftp}/pxelinux.cfg/default <<EOF
452DEFAULT pxe
453
454LABEL pxe
455KERNEL linux
456APPEND initrd=initrd.gz ip=dhcp ro vga=788 irqpoll acpi=on
457EOF
458        # comprobamos el servicio tftp
459        sleep 1
460        testPxe
461        ## damos perfimos de lectura a usuario web.
462        chown -R www-data:www-data ${basetftp}
463}
464
465function testPxe () {
466        cd /tmp
467        echo "comprobando servicio pxe ..... Espere"
468        tftp -v localhost -c get pxelinux.0 /tmp/pxelinux.0 && echo "servidor tftp OK" || echo "servidor tftp KO"
469        cd /
470}
471
472########################################################################
473## Configuracion servicio NFS
474########################################################################
475
476function nfsConfigure (){
477        echoAndLog "nfsConfigure(): Sample NFS Configuration."
478        local net_ip net_mask VARS
479        VARS=$(route -n | awk '$2~/0\.0\.0\.0/ {print $1,$3}')
480        read -e net_ip net_mask <<<"$VARS"
481        if [ -z "$net_ip" -o -z "$net_mask" ]; then
482                echoAndLog "nfsConfigure(): Network not detected."
483                exit 1
484        fi
485        sed -e "s/NETIP/$net_ip/g" -e "s/NETMASK/$net_mask/g" $WORKDIR/opengnsys/server/NFS/exports  >> /etc/exports
486        exportfs -va
487        echoAndLog "nfsConfigure(): Sample NFS Configured in file \"/etc/exports\"."
488}
489
490
491########################################################################
492## Configuracion servicio DHCP
493########################################################################
494
495function dhcpConfigure (){
496        echoAndLog "dhcpConfigure(): Sample DHCP Configuration."
497        #### PRUEBAS
498        cp $WORKDIR/opengnsys/server/DHCP/dhcpd.conf  > /etc/dhcp3/dhcpd.conf
499
500}
501
502
503#####################################################################
504####### Funciones específicas de la instalación de Opengnsys
505#####################################################################
506
507function openGnsysInstallWebConsoleApacheConf()
508{
509        if [ $# -ne 2 ]; then
510                errorAndLog "openGnsysInstallWebConsoleApacheConf(): invalid number of parameters"
511                exit 1
512        fi
513
514        local path_opengnsys_base=$1
515        local path_apache2_confd=$2
516        local path_web_console=${path_opengnsys_base}/www
517
518        if [ ! -d $path_apache2_confd ]; then
519                errorAndLog "openGnsysInstallWebConsoleApacheConf(): path to apache2 conf.d can not found, verify your server installation"
520                return 1
521        fi
522
523    [ -d $path_apache2_confd/sites-available ] || mkdir $path_apache2_confd/sites-available
524    [ -d $path_apache2_confd/sites-enabled ] || mkdir $path_apache2_confd/sites-enabled
525
526        echoAndLog "openGnsysInstallWebConsoleApacheConf(): creating apache2 config file.."
527
528        # genera configuración
529        cat > $path_opengnsys_base/etc/apache.conf <<EOF
530# Hidra web interface configuration for Apache
531
532Alias /opengnsys ${path_web_console}
533
534<Directory ${path_web_console}>
535        Options -Indexes FollowSymLinks
536        DirectoryIndex acceso.php
537</Directory>
538EOF
539
540
541        ln -s $path_opengnsys_base/etc/apache.conf $path_apache2_confd/sites-available/opengnsys.conf
542        ln -s $path_apache2_confd/sites-available/opengnsys.conf $path_apache2_confd/sites-enabled/opengnsys.conf
543        if [ $? -ne 0 ]; then
544                errorAndLog "openGnsysInstallWebConsoleApacheConf(): config file can't be linked to apache conf, verify your server installation"
545                return 1
546        else
547                echoAndLog "openGnsysInstallWebConsoleApacheConf(): config file created and linked, restart your apache daemon"
548                return 0
549        fi
550}
551
552# Crea la estructura base de la instalación de opengnsys
553openGnsysInstallCreateDirs()
554{
555        if [ $# -ne 1 ]; then
556                errorAndLog "openGnsysInstallCreateDirs(): invalid number of parameters"
557                exit 1
558        fi
559
560        local path_opengnsys_base=$1
561
562        echoAndLog "openGnsysInstallCreateDirs(): creating directory paths in $path_opengnsys_base"
563
564        mkdir -p $path_opengnsys_base
565        mkdir -p $path_opengnsys_base/admin/{autoexec,comandos,usuarios}
566        mkdir -p $path_opengnsys_base/bin
567        mkdir -p $path_opengnsys_base/client
568        mkdir -p $path_opengnsys_base/etc
569        mkdir -p $path_opengnsys_base/lib
570        mkdir -p $path_opengnsys_base/log/clients
571        mkdir -p $path_opengnsys_base/www
572        mkdir -p $path_opengnsys_base/images
573        ln -fs /var/lib/tftpboot $path_opengnsys_base
574        ln -fs $path_opengnsys_base/log /var/log/opengnsys
575
576        if [ $? -ne 0 ]; then
577                errorAndLog "openGnsysInstallCreateDirs(): error while creating dirs. Do you have write permissions?"
578                return 1
579        fi
580
581        echoAndLog "openGnsysInstallCreateDirs(): directory paths created"
582        return 0
583}
584
585# Copia ficheros de configuración y ejecutables genéricos del servidor.
586openGnsysCopyServerFiles () {
587        if [ $# -ne 1 ]; then
588                errorAndLog "openGnsysCopyServerFiles(): invalid number of parameters"
589                exit 1
590        fi
591
592        local path_opengnsys_base=$1
593
594        local SOURCES=( client/boot/initrd-generator \
595                        client/boot/upgrade-clients-udeb.sh \
596                        client/boot/udeblist.conf )
597        local TARGETS=( bin/initrd-generator \
598                        bin/upgrade-clients-udeb.sh \
599                        etc/udeblist.conf )
600
601        if [ ${#SOURCES[@]} != ${#TARGETS[@]} ]; then
602                errorAndLog "openGnsysCopyServerFiles(): inconsistent number of array items"
603                exit 1
604        fi
605
606    echoAndLog "openGnsysCopyServerFiles(): copying files to server directories"
607
608    pushd opengnsys >/dev/null
609        local i
610        for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
611                if [ -f "${SOURCES[$i]}" ]; then
612                        echoAndLog "copying ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
613                        cp -p "${SOURCES[$i]}" "${path_opengnsys_base}/${TARGETS[$i]}"
614                fi
615                if [ -d "${SOURCES[$i]}" ]; then
616                        echoAndLog "openGnsysCopyServerFiles(): copying content of ${SOURCES[$i]} to $path_opengnsys_base/${TARGETS[$i]}"
617                        cp -pr "${SOURCES[$i]}/*" "${path_opengnsys_base}/${TARGETS[$i]}"
618                fi
619        done
620    popd >/dev/null
621}
622
623# Compilar los servicios de OpenGNsys
624servicesCompilation () {
625        # Compilar OpenGNSys Server
626        echoAndLog "servicesCompilation(): Compiling OpenGNSys Admin Server"
627        pushd $WORKDIR/opengnsys/admin/Services/ogAdmServer >/dev/null
628        make && make install
629        # Compilar OpenGNSys Repository Manager
630        echoAndLog "servicesCompilation(): Compiling OpenGNSys Repository Manager"
631        popd >/dev/null
632        pushd $WORKDIR/opengnsys/admin/Services/ogAdmRepo >/dev/null
633        make && make install
634        # Compilar OpenGNSys Client
635        echoAndLog "servicesCompilation(): Compiling OpenGNSys Admin Client"
636        popd >/dev/null
637        pushd $WORKDIR/opengnsys/admin/Services/ogAdmClient >/dev/null
638        make && mv ogAdmClient ../../client/nfsexport/bin
639        popd >/dev/null
640        # Compilar OpenGNSys Client Browser
641        echoAndLog "servicesCompilation(): Compiling OpenGNSys Client Browser"
642        pushd $WORKDIR/opengnsys/client/browser >/dev/null
643        cmake CMakeLists.txt && make && mv browser ../nfsexport/bin
644        popd >/dev/null
645}
646
647
648####################################################################
649### Funciones instalacion cliente opengnsys
650####################################################################
651
652function openGnsysClientCreate () {
653
654        echoAndLog "openGnsysClientCreate(): Copying OpenGNSys Client files."
655        cp -ar $WORKDIR/opengnsys/client/nfsexport/* $INSTALL_TARGET/client
656        find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
657        echoAndLog "openGnsysClientCreate(): Copying OpenGNSys Cloning Engine files."
658        mkdir -p $INSTALL_TARGET/client/lib/engine/bin
659        cp -ar $WORKDIR/opengnsys/client/engine/*.lib $INSTALL_TARGET/client/lib/engine/bin
660        cp -ar $WORKDIR/opengnsys/client/engine/*.sh $INSTALL_TARGET/client/lib/engine/bin
661
662        echoAndLog "openGnsysClientCreate(): Loading Kernel and Initrd files."
663        $INSTALL_TARGET/bin/initrd-generator -t $INSTALL_TARGET/tftpboot/
664
665        echoAndLog "openGnsysClientCreate(): Loading udeb files."
666        $INSTALL_TARGET/bin/upgrade-clients-udeb.sh
667
668}
669
670
671
672#####################################################################
673####### Proceso de instalación de OpenGNSys
674#####################################################################
675
676       
677# Instalación de dependencias (paquetes de sistema operativo).
678declare -a notinstalled
679checkDependencies DEPENDENCIES notinstalled
680if [ $? -ne 0 ]; then
681        installDependencies notinstalled
682        if [ $? -ne 0 ]; then
683                echoAndLog "Error while installing some dependeces, please verify your server installation before continue"
684                exit 1
685        fi
686fi
687
688# Arbol de directorios de OpenGNSys.
689openGnsysInstallCreateDirs ${INSTALL_TARGET}
690if [ $? -ne 0 ]; then
691        errorAndLog "Error while creating directory paths!"
692        exit 1
693fi
694
695# Descarga del repositorio de código en directorio temporal
696svnCheckoutCode $SVN_URL
697if [ $? -ne 0 ]; then
698        errorAndLog "Error while getting code from svn"
699        exit 1
700fi
701
702# Compilar código fuente de los servicios de OpenGNSys.
703servicesCompilation
704
705# Configurando tftp
706tftpConfigurate
707pxeTest
708
709# Configuración NFS
710nfsConfigure
711
712# Configuración ejemplo DHCP
713dhcpConfigure
714
715# Copiar ficheros de servicios OpenGNSys Server.
716openGnsysCopyServerFiles ${INSTALL_TARGET}
717if [ $? -ne 0 ]; then
718        errorAndLog "Error while copying the server files!"
719        exit 1
720fi
721
722# Instalar Base de datos de OpenGNSys Admin.
723isInArray notinstalled "mysql-server"
724if [ $? -eq 0 ]; then
725        mysqlSetRootPassword ${MYSQL_ROOT_PASSWORD}
726else
727        mysqlGetRootPassword
728
729fi
730
731mysqlTestConnection ${MYSQL_ROOT_PASSWORD}
732if [ $? -ne 0 ]; then
733        errorAndLog "Error while connection to mysql"
734        exit 1
735fi
736mysqlDbExists ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE}
737if [ $? -ne 0 ]; then
738        echoAndLog "Creating web console database"
739        mysqlCreateDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE}
740        if [ $? -ne 0 ]; then
741                errorAndLog "Error while creating hidra database"
742                exit 1
743        fi
744else
745        echoAndLog "Hidra database exists, ommiting creation"
746fi
747
748mysqlCheckUserExists ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DB_USER}
749if [ $? -ne 0 ]; then
750        echoAndLog "Creating user in database"
751        mysqlCreateAdminUserToDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE} ${OPENGNSYS_DB_USER} "${OPENGNSYS_DB_PASSWD}"
752        if [ $? -ne 0 ]; then
753                errorAndLog "Error while creating hidra user"
754                exit 1
755        fi
756
757fi
758
759mysqlCheckDbIsEmpty ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE}
760if [ $? -eq 0 ]; then
761        echoAndLog "Creating tables..."
762        if [ -f $WORKDIR/$OPENGNSYS_DB_CREATION_FILE ]; then
763                mysqlImportSqlFileToDb ${MYSQL_ROOT_PASSWORD} ${OPENGNSYS_DATABASE} $WORKDIR/$OPENGNSYS_DB_CREATION_FILE
764        else
765                errorAndLog "Unable to locate $WORKDIR/$OPENGNSYS_DB_CREATION_FILE!!"
766                exit 1
767        fi
768fi
769
770# Configuración del web de OpenGNSys Admin
771echoAndLog "Installing web files..."
772# copiando paqinas web
773cp -pr opengnsys/admin/WebConsole/* $INSTALL_TARGET/www   #*/ comentario para doxigen
774
775# creando configuracion de apache2
776openGnsysInstallWebConsoleApacheConf $INSTALL_TARGET /etc/apache2
777if [ $? -ne 0 ]; then
778        errorAndLog "Error while creating hidra apache config"
779        exit 1
780fi
781
782popd
783
784# Creando la estructura del cliente
785openGnsysClientCreate
786
787#rm -rf $WORKDIR
788echoAndLog "Process finalized!"
789
790
791
792
Note: See TracBrowser for help on using the repository browser.