[2cffa56] | 1 | #!/bin/bash |
---|
| 2 | #@file boottoolsgenerator.sh |
---|
| 3 | #@brief Script generación del sistema opertativo cliente OpenGnSys |
---|
| 4 | #@warning |
---|
| 5 | #@version 0.9 - Prototipo de sistema operativo multiarranque de opengnsys. |
---|
| 6 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 7 | #@date 2010/05/24 |
---|
| 8 | #@version 1.0 - Compatibilidad OpengGnsys X. |
---|
| 9 | #@author Antonio J. Doblas Viso. Universidad de Malaga. |
---|
| 10 | #@date 2011/08/03 |
---|
| 11 | #*/ |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | #Variables |
---|
| 15 | TYPECLIENT=host |
---|
| 16 | WORKDIR=/tmp/opengnsys_installer |
---|
| 17 | INSTALL_TARGET=/opt/opengnsys |
---|
| 18 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
| 19 | |
---|
| 20 | # Solo ejecutable por usuario root |
---|
| 21 | if [ "$(whoami)" != 'root' ] |
---|
| 22 | then |
---|
| 23 | echo "ERROR: this program must run under root privileges!!" |
---|
| 24 | exit 1 |
---|
| 25 | fi |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | #funciones especificas del cliente. |
---|
| 29 | source $PROGRAMDIR/boottoolsfunctions.lib |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | echoAndLog "OpenGnSys CLIENT installation begins at $(date)" |
---|
| 33 | |
---|
| 34 | ########################################################################## |
---|
| 35 | ## FASE 1 - Instalación de software adicional. |
---|
| 36 | DEPENDENCIES=( debootstrap subversion schroot squashfs-tools) |
---|
| 37 | apt-get update |
---|
| 38 | # Instalación de dependencias (paquetes de sistema operativo). |
---|
| 39 | declare -a notinstalled |
---|
| 40 | checkDependencies DEPENDENCIES notinstalled |
---|
| 41 | if [ $? -ne 0 ]; then |
---|
| 42 | installDependencies notinstalled |
---|
| 43 | if [ $? -ne 0 ]; then |
---|
| 44 | echoAndLog "Error while installing some dependeces, please verify your server installation before continue" |
---|
| 45 | exit 1 |
---|
| 46 | fi |
---|
| 47 | fi |
---|
| 48 | ########### FIN FASE 1 |
---|
| 49 | |
---|
| 50 | ##### FASE 2 - Asignación de variables |
---|
| 51 | #obtenemos las variables necesarias. |
---|
| 52 | btogGetVar |
---|
| 53 | #obtenemos la información del host. |
---|
| 54 | btogGetOsInfo |
---|
| 55 | ##### FIN fase 2 |
---|
| 56 | |
---|
| 57 | ############# FASE 3: Creación del Sistema Root (Segundo Sistema archivos (img)) |
---|
| 58 | ##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. |
---|
| 59 | file $BTROOTFSIMG | grep "partition 1: ID=0x83" |
---|
| 60 | if [ $? == 1 ] |
---|
| 61 | then |
---|
| 62 | btogSetFsVirtual || exit 2 |
---|
| 63 | fi |
---|
| 64 | #3.2 generamos el Sistema de archivos con debootstrap |
---|
| 65 | schroot -p -c IMGogclient -- touch /tmp/ogclientOK |
---|
| 66 | if [ -f /tmp/ogclientOK ] |
---|
| 67 | then |
---|
| 68 | rm /tmp/ogclientOK |
---|
| 69 | else |
---|
| 70 | btogSetFsBase || exit 3 |
---|
| 71 | fi |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | ############### FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot |
---|
| 75 | cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | ############### FASE 5: Configuración del Segundo Sistema de archivos (img) con la estructura especial de OpenGnsys |
---|
| 81 | cp ${BTSVNBOOTTOOLS}/includes/root/* /tmp/ |
---|
| 82 | chmod 777 /tmp/*.sh |
---|
| 83 | schroot -p -c IMGogclient -- /tmp/importSVNboot-tools.sh |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | ############# FASE6: Ejecutamos los scripts de personalización del 2º sistema de archivos (img) desde la jaula schroot |
---|
| 91 | ### 6.1 instalacion de software con apt-get |
---|
| 92 | schroot -p -c IMGogclient -- /root/InstallSoftware.sh |
---|
| 93 | echo "saltando" |
---|
| 94 | if [ $? -ne 0 ]; then |
---|
| 95 | errorAndLog "Instalando sofware adicional OG : ERROR" |
---|
| 96 | exit |
---|
| 97 | else |
---|
| 98 | echoAndLog "Instalando sofware adicional OG: OK" |
---|
| 99 | fi |
---|
| 100 | #### 6.2 compilación de software. |
---|
| 101 | cd / |
---|
| 102 | schroot -p -c IMGogclient -- /root/CompileSoftware.sh |
---|
| 103 | cd - |
---|
| 104 | |
---|
| 105 | ### 6.3 configuracion hostname passroot securety |
---|
| 106 | cd / |
---|
| 107 | schroot -c IMGogclient -- /root/ConfFS.sh |
---|
| 108 | cd - |
---|
| 109 | #schroot -c IMGogclient -- echo -ne "og1\nog1\n" | passwd root |
---|
| 110 | # schroot -c IMGogclient -- passwd root | echo "root" |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | ### 6.4 incorporamos la clave publica del servidor |
---|
| 114 | cd / |
---|
| 115 | ssh-keygen -q -f /root/.ssh/id_rsa -N "" |
---|
| 116 | cp /root/.ssh/id_rsa.pub /tmp |
---|
| 117 | schroot -p -c IMGogclient -- /root/importSshKeys.sh |
---|
| 118 | cd - |
---|
| 119 | ############ y la del propio cliente. |
---|
| 120 | schroot -c IMGogclient -- /root/generateSshKeysClient.sh |
---|
| 121 | |
---|
| 122 | ## configuramos los locales. |
---|
| 123 | schroot -c IMGogclient -- /root/ReconfigureLocales.sh |
---|
| 124 | |
---|
| 125 | exit 99 |
---|
| 126 | ################## FIN fase 6. Fin de comfiguración del segundo sistema de archivos (img) |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | |
---|
| 139 | ################## FASE 7. Generamos el 1er sistema de archivos. INITRD |
---|
| 140 | btogFsInitrd |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | ################## FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) |
---|
| 144 | # generamos el 2sistema de archivos en squashfs |
---|
| 145 | ogClient2ndSqfs |
---|
| 146 | ################## FIN FASE 8. convertimos el 2ºFS(img) en 2ºFS(sqfs) |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | ##################### FASE 9. algunos detallas del pxe |
---|
| 150 | #dejamos ficheros de ejemplo para el pxe y el nfs |
---|
| 151 | #ogClientConfpxe |
---|
| 152 | ##################### FIN FASE 9. algunos detallas del pxe |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | # Mostrar sumario de la instalación e instrucciones de post-instalación. |
---|
| 156 | installationSummary |
---|
| 157 | |
---|
| 158 | echoAndLog "OpenGnSys installation finished at $(date)" |
---|