[58828de] | 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 | echoAndLog "OpenGnSys CLIENT installation begins at $(date)" |
---|
| 43 | ########################################################################## |
---|
| 44 | ## FASE 1 - Instalación de software adicional. |
---|
| 45 | ##TO DO Integrar en el instaldor. Actualizar repositorios |
---|
| 46 | # Datos para la generación del cliente. |
---|
| 47 | DEPENDENCIES=( debootstrap subversion schroot squashfs-tools) |
---|
| 48 | apt-get update |
---|
| 49 | # Instalación de dependencias (paquetes de sistema operativo). |
---|
| 50 | declare -a notinstalled |
---|
| 51 | checkDependencies DEPENDENCIES notinstalled |
---|
| 52 | if [ $? -ne 0 ]; then |
---|
| 53 | installDependencies notinstalled |
---|
| 54 | if [ $? -ne 0 ]; then |
---|
| 55 | echoAndLog "Error while installing some dependeces, please verify your server installation before continue" |
---|
| 56 | exit 1 |
---|
| 57 | fi |
---|
| 58 | fi |
---|
| 59 | ############## FIN DEL TO DO |
---|
| 60 | ############################################## FIN FASE 1 |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | echoAndLog "OpenGnSys CLIENT installation begins at $(date)" |
---|
| 67 | |
---|
| 68 | ############## FASE 2 - Asignación de variables |
---|
| 69 | #obtenemos las variables necesarias. |
---|
| 70 | ogClientVar |
---|
| 71 | #obtenemos la información del host. |
---|
| 72 | ogClientOsInfo |
---|
| 73 | ######################## FIN fase 2 |
---|
| 74 | |
---|
| 75 | ############# FASE 3: Segundo Sistema archivos (img) Creación. |
---|
| 76 | #TODO comprobacion de que el fichero esta creado. |
---|
| 77 | file $OGCLIENTFILE | grep "partition 1: ID=0x83" |
---|
| 78 | if [ $? == 1 ] |
---|
| 79 | then |
---|
| 80 | ##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. |
---|
| 81 | ogClient2ndFile || exit 1 |
---|
| 82 | fi |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | #3.2 generamos el Sistema de archivos con debootstrap |
---|
| 86 | # Comprobamos que ya tenemos alguno. |
---|
| 87 | schroot -p -c IMGogclient -- touch /tmp/ogclientOK |
---|
| 88 | if [ -f /tmp/ogclientOK ] |
---|
| 89 | then |
---|
| 90 | rm /tmp/ogclientOK |
---|
| 91 | else |
---|
| 92 | ogClient2ndFs $TYPECLIENT || exit |
---|
| 93 | fi |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | ############### FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot |
---|
| 97 | cat /etc/schroot/schroot.conf | grep ogclient || ogClientSchrootConf |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | ############### FASE 5: Configuración del Segundo Sistema de archivos (img) con la estructura especial de OpenGnsys |
---|
| 101 | ogClient2ndSVN $TYPECLIENT || exit |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | ############# FASE6: Ejecutamos los scripts de personalización del 2º sistema de archivos (img) desde la jaula schroot |
---|
| 107 | ### 6.1 instalacion de software con apt-get |
---|
| 108 | schroot -p -c IMGogclient -- /root/InstallSoftware.sh |
---|
| 109 | echo "saltando" |
---|
| 110 | if [ $? -ne 0 ]; then |
---|
| 111 | errorAndLog "Instalando sofware adicional OG : ERROR" |
---|
| 112 | exit |
---|
| 113 | else |
---|
| 114 | echoAndLog "Instalando sofware adicional OG: OK" |
---|
| 115 | fi |
---|
| 116 | #### 6.2 compilación de software. |
---|
| 117 | cd / |
---|
| 118 | schroot -p -c IMGogclient -- /root/CompileSoftware.sh |
---|
| 119 | cd - |
---|
| 120 | |
---|
| 121 | ### 6.3 configuracion hostname passroot securety |
---|
| 122 | cd / |
---|
| 123 | schroot -c IMGogclient -- /root/ConfFS.sh |
---|
| 124 | cd - |
---|
| 125 | #schroot -c IMGogclient -- echo -ne "og1\nog1\n" | passwd root |
---|
| 126 | # schroot -c IMGogclient -- passwd root | echo "root" |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | ### 6.4 incorporamos la clave publica del servidor |
---|
| 130 | cd / |
---|
| 131 | ssh-keygen -q -f /root/.ssh/id_rsa -N "" |
---|
| 132 | cp /root/.ssh/id_rsa.pub /tmp |
---|
| 133 | schroot -p -c IMGogclient -- /root/importSshKeys.sh |
---|
| 134 | cd - |
---|
| 135 | ############ y la del propio cliente. |
---|
| 136 | schroot -c IMGogclient -- /root/generateSshKeysClient.sh |
---|
| 137 | |
---|
| 138 | ## configuramos los locales. |
---|
| 139 | schroot -c IMGogclient -- /root/ReconfigureLocales.sh |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | ################## FIN fase 6. Fin de comfiguración del segundo sistema de archivos (img) |
---|
| 143 | |
---|
| 144 | ################## FASE 7. Generamos el 1er sistema de archivos. INITRD |
---|
| 145 | #nota el parametro es el "tipo" de linux generado en debootstrap. usar solo "host", es decir version,kernel ... del propio host |
---|
| 146 | #nota: hace un schroot, al 2fs (img), ejecuta el fichero generateinitrd. |
---|
| 147 | #nota: deja en el directorio tmp del host el nuevo initrd, y lo copia al tftpboot |
---|
| 148 | ogClientInitrd $TYPECLIENT |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | ################## FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) |
---|
| 152 | # generamos el 2sistema de archivos en squashfs |
---|
| 153 | ogClient2ndSqfs |
---|
| 154 | ################## FIN FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | ##################### FASE 9. algunos detallas del pxe |
---|
| 158 | #dejamos ficheros de ejemplo para el pxe y el nfs |
---|
[88b75ac] | 159 | #ogClientConfpxe |
---|
[58828de] | 160 | ##################### FIN FASE 9. algunos detallas del pxe |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | # Mostrar sumario de la instalación e instrucciones de post-instalación. |
---|
| 164 | installationSummary |
---|
| 165 | |
---|
| 166 | echoAndLog "OpenGnSys installation finished at $(date)" |
---|