1 | #!/bin/bash |
---|
2 | #@file ogClientGenerator.sh |
---|
3 | #@brief Script generación del cliente OpenGnSys |
---|
4 | #@warning |
---|
5 | #@version 0.9 - |
---|
6 | #@author Antonio J. Doblas Viso. |
---|
7 | #@date 2010/05/24 |
---|
8 | #*/ |
---|
9 | |
---|
10 | |
---|
11 | #$1 OSCONENAME lucid karmic |
---|
12 | #if [ $# -ne 1 ]; then |
---|
13 | # echo ": invalid number of parameters" |
---|
14 | # echo " host | lucid | karmic | jaunty | lenny | squeeze " |
---|
15 | # exit 1 |
---|
16 | #fi |
---|
17 | TYPECLIENT=host |
---|
18 | |
---|
19 | # Solo ejecutable por usuario root |
---|
20 | if [ "$(whoami)" != 'root' ] |
---|
21 | then |
---|
22 | echo "ERROR: this program must run under root privileges!!" |
---|
23 | exit 1 |
---|
24 | fi |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | #FIXME: variables del instalador oficial. |
---|
29 | WORKDIR=/tmp/opengnsys_installer |
---|
30 | INSTALL_TARGET=/opt/opengnsys |
---|
31 | LOG_FILE=/tmp/opengnsys_installation.log |
---|
32 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
33 | |
---|
34 | |
---|
35 | #funciones especificas del cliente. |
---|
36 | source $PROGRAMDIR/ogClientManager.lib |
---|
37 | #funciones incluidas dentro del scritps general de instalacion. |
---|
38 | source $PROGRAMDIR/ogInstaller.lib |
---|
39 | |
---|
40 | echoAndLog "OpenGnSys CLIENT installation begins at $(date)" |
---|
41 | |
---|
42 | ########################################################################## |
---|
43 | ## FASE 1 - Instalación de software adicional. |
---|
44 | ##TO DO Integrar en el instaldor. Actualizar repositorios |
---|
45 | # Datos para la generación del cliente. |
---|
46 | DEPENDENCIES=( debootstrap subversion schroot squashfs-tools) |
---|
47 | apt-get update |
---|
48 | # Instalación de dependencias (paquetes de sistema operativo). |
---|
49 | declare -a notinstalled |
---|
50 | checkDependencies DEPENDENCIES notinstalled |
---|
51 | if [ $? -ne 0 ]; then |
---|
52 | installDependencies notinstalled |
---|
53 | if [ $? -ne 0 ]; then |
---|
54 | echoAndLog "Error while installing some dependeces, please verify your server installation before continue" |
---|
55 | exit 1 |
---|
56 | fi |
---|
57 | fi |
---|
58 | ############## FIN DEL TO DO |
---|
59 | ############################################## FIN FASE 1 |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | ############## FASE 2 - Asignación de variables |
---|
64 | #obtenemos las variables necesarias. |
---|
65 | ogClientVar |
---|
66 | #obtenemos la información del host. |
---|
67 | ogClientOsInfo |
---|
68 | ######################## FIN fase 2 |
---|
69 | |
---|
70 | ############# FASE 3: Segundo Sistema archivos (img) Creación. |
---|
71 | #TODO comprobacion de que el fichero esta creado. |
---|
72 | file $OGCLIENTFILE | grep "partition 1: ID=0x83" |
---|
73 | if [ $? == 1 ] |
---|
74 | then |
---|
75 | ##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. |
---|
76 | ogClient2ndFile || exit 1 |
---|
77 | fi |
---|
78 | |
---|
79 | |
---|
80 | #3.2 generamos el Sistema de archivos con debootstrap |
---|
81 | # Comprobamos que ya tenemos alguno. |
---|
82 | schroot -p -c IMGogclient -- touch /tmp/ogclientOK |
---|
83 | if [ -f /tmp/ogclientOK ] |
---|
84 | then |
---|
85 | rm /tmp/ogclientOK |
---|
86 | else |
---|
87 | ogClient2ndFs $TYPECLIENT || exit |
---|
88 | fi |
---|
89 | |
---|
90 | |
---|
91 | ############### FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot |
---|
92 | cat /etc/schroot/schroot.conf | grep ogclient || ogClientSchrootConf |
---|
93 | |
---|
94 | |
---|
95 | ############### FASE 5: Configuración del Segundo Sistema de archivos (img) con la estructura especial de OpenGnsys |
---|
96 | ogClient2ndSVN $TYPECLIENT || exit |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | ############# FASE6: Ejecutamos los scripts de personalización del 2º sistema de archivos (img) desde la jaula schroot |
---|
102 | ### 6.1 instalacion de software con apt-get |
---|
103 | schroot -p -c IMGogclient -- /root/InstallSoftware.sh |
---|
104 | echo "saltando" |
---|
105 | if [ $? -ne 0 ]; then |
---|
106 | errorAndLog "Instalando sofware adicional OG : ERROR" |
---|
107 | exit |
---|
108 | else |
---|
109 | echoAndLog "Instalando sofware adicional OG: OK" |
---|
110 | fi |
---|
111 | #### 6.2 compilación de software. |
---|
112 | cd / |
---|
113 | schroot -p -c IMGogclient -- /root/CompileSoftware.sh |
---|
114 | cd - |
---|
115 | |
---|
116 | ### 6.3 configuracion hostname passroot securety |
---|
117 | cd / |
---|
118 | schroot -c IMGogclient -- /root/ConfFS.sh |
---|
119 | cd - |
---|
120 | #schroot -c IMGogclient -- echo -ne "og1\nog1\n" | passwd root |
---|
121 | # schroot -c IMGogclient -- passwd root | echo "root" |
---|
122 | |
---|
123 | |
---|
124 | ### 6.4 incorporamos la clave publica del servidor |
---|
125 | cd / |
---|
126 | ssh-keygen -q -f /root/.ssh/id_rsa -N "" |
---|
127 | cp /root/.ssh/id_rsa.pub /tmp |
---|
128 | schroot -p -c IMGogclient -- /root/importSshKeys.sh |
---|
129 | cd - |
---|
130 | ############ y la del propio cliente. |
---|
131 | schroot -c IMGogclient -- /root/generateSshKeysClient.sh |
---|
132 | |
---|
133 | ## configuramos los locales. |
---|
134 | schroot -c IMGogclient -- /root/ReconfigureLocales.sh |
---|
135 | |
---|
136 | |
---|
137 | ################## FIN fase 6. Fin de comfiguración del segundo sistema de archivos (img) |
---|
138 | |
---|
139 | ################## FASE 7. Generamos el 1er sistema de archivos. INITRD |
---|
140 | #nota el parametro es el "tipo" de linux generado en debootstrap. usar solo "host", es decir version,kernel ... del propio host |
---|
141 | #nota: hace un schroot, al 2fs (img), ejecuta el fichero generateinitrd. |
---|
142 | #nota: deja en el directorio tmp del host el nuevo initrd, y lo copia al tftpboot |
---|
143 | ogClientInitrd $TYPECLIENT |
---|
144 | |
---|
145 | |
---|
146 | ################## FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) |
---|
147 | # generamos el 2sistema de archivos en squashfs |
---|
148 | ogClient2ndSqfs |
---|
149 | ################## FIN FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) |
---|
150 | |
---|
151 | |
---|
152 | ##################### FASE 9. algunos detallas del pxe |
---|
153 | #dejamos ficheros de ejemplo para el pxe y el nfs |
---|
154 | #ogClientConfpxe |
---|
155 | ##################### FIN FASE 9. algunos detallas del pxe |
---|
156 | |
---|
157 | |
---|
158 | # Mostrar sumario de la instalación e instrucciones de post-instalación. |
---|
159 | installationSummary |
---|
160 | |
---|
161 | echoAndLog "OpenGnSys installation finished at $(date)" |
---|