[00a2c2c] | 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 | |
---|
[841ce50] | 13 | #mkdir -p /tmp/opengnsys_installer/opengnsys; |
---|
| 14 | #mkdir -p /tmp/opengnsys_installer/opengnsys2; |
---|
| 15 | #cp -prv /home/administrador/workspace/OpenGnsys/branches/version2/* /tmp/opengnsys_installer/opengnsys2/; |
---|
| 16 | #cp -prv /home/administrador/workspace/OpenGnsys/branches/version1.0/client/ /tmp/opengnsys_installer/opengnsys/; |
---|
| 17 | |
---|
| 18 | #find /tmp/opengnsys_installer/ -name .svn -type d -exec rm -fr {} \; 2>/dev/null; |
---|
| 19 | |
---|
[00a2c2c] | 20 | |
---|
| 21 | #Variables |
---|
| 22 | TYPECLIENT=host |
---|
| 23 | WORKDIR=/tmp/opengnsys_installer |
---|
| 24 | INSTALL_TARGET=/opt/opengnsys |
---|
| 25 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
| 26 | |
---|
| 27 | # Solo ejecutable por usuario root |
---|
| 28 | if [ "$(whoami)" != 'root' ] |
---|
| 29 | then |
---|
| 30 | echo "ERROR: this program must run under root privileges!!" |
---|
| 31 | exit 1 |
---|
| 32 | fi |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | #funciones especificas del cliente. |
---|
| 36 | source $PROGRAMDIR/boottoolsfunctions.lib |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | echoAndLog "OpenGnSys CLIENT installation begins at $(date)" |
---|
| 40 | |
---|
| 41 | ########################################################################## |
---|
| 42 | ## FASE 1 - Instalación de software adicional. |
---|
[27ee376] | 43 | cat /etc/apt/sources.list | grep "http://free.nchc.org.tw/drbl-core" || echo "deb http://free.nchc.org.tw/drbl-core drbl stable " >> /etc/apt/sources.list |
---|
[00a2c2c] | 44 | apt-get update |
---|
[841ce50] | 45 | apt-get -y --force-yes install debootstrap subversion schroot squashfs-tools syslinux genisoimage gpxe qemu |
---|
[00a2c2c] | 46 | |
---|
| 47 | ##### FASE 2 - Asignación de variables |
---|
[27ee376] | 48 | #obtenemos las variables necesarias y la información del host. |
---|
| 49 | btogGetVar && btogGetOsInfo |
---|
[00a2c2c] | 50 | |
---|
[27ee376] | 51 | ############# FASE 3: Creación del Sistema raiz RootFS (Segundo Sistema archivos (img)) |
---|
[00a2c2c] | 52 | ##3.1 creación y formateo del disco virtual. generamos el dispositivo loop. |
---|
| 53 | file $BTROOTFSIMG | grep "partition 1: ID=0x83" |
---|
| 54 | if [ $? == 1 ] |
---|
| 55 | then |
---|
| 56 | btogSetFsVirtual || exit 2 |
---|
| 57 | fi |
---|
| 58 | #3.2 generamos el Sistema de archivos con debootstrap |
---|
| 59 | schroot -p -c IMGogclient -- touch /tmp/ogclientOK |
---|
| 60 | if [ -f /tmp/ogclientOK ] |
---|
| 61 | then |
---|
| 62 | rm /tmp/ogclientOK |
---|
| 63 | else |
---|
| 64 | btogSetFsBase || exit 3 |
---|
| 65 | fi |
---|
| 66 | |
---|
[27ee376] | 67 | # FASE 4: Configuración el acceso al Segundo Sistema de archivos (img), para schroot |
---|
[00a2c2c] | 68 | cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess |
---|
| 69 | |
---|
[27ee376] | 70 | # FASE 5: Incorporando con ficheros OG el sistema raiz rootfs |
---|
| 71 | cp -prv ${BTSVNBOOTTOOLS}/includes/usr/bin/* /tmp/ |
---|
[841ce50] | 72 | chmod 777 /tmp/boot-tools/*.sh |
---|
| 73 | schroot -p -c IMGogclient -- /tmp/boot-tools/boottoolsFsOpengnsys.sh |
---|
[00a2c2c] | 74 | |
---|
[27ee376] | 75 | # FASE6: Instalacion de software |
---|
| 76 | # 6.1 instalacion de software con apt-get |
---|
| 77 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh |
---|
[00a2c2c] | 78 | echo "saltando" |
---|
| 79 | if [ $? -ne 0 ]; then |
---|
| 80 | errorAndLog "Instalando sofware adicional OG : ERROR" |
---|
| 81 | exit |
---|
| 82 | else |
---|
| 83 | echoAndLog "Instalando sofware adicional OG: OK" |
---|
| 84 | fi |
---|
[27ee376] | 85 | # 6.2 compilación de software. |
---|
[00a2c2c] | 86 | cd / |
---|
[27ee376] | 87 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh |
---|
[00a2c2c] | 88 | cd - |
---|
| 89 | |
---|
[27ee376] | 90 | #Fase 7. Personalizando |
---|
| 91 | ### 7.1 incorporamos la clave publica del servidor |
---|
[00a2c2c] | 92 | cd / |
---|
| 93 | ssh-keygen -q -f /root/.ssh/id_rsa -N "" |
---|
| 94 | cp /root/.ssh/id_rsa.pub /tmp |
---|
[27ee376] | 95 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh |
---|
[00a2c2c] | 96 | cd - |
---|
[27ee376] | 97 | ### 7.2 y la del propio cliente. |
---|
| 98 | schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh |
---|
[00a2c2c] | 99 | |
---|
[27ee376] | 100 | ## 7.3 configuramos los locales. |
---|
| 101 | schroot -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh |
---|
[00a2c2c] | 102 | |
---|
| 103 | |
---|
[27ee376] | 104 | #Fase 7. Generando la ISO. |
---|
| 105 | #7.1 el initrd |
---|
[00a2c2c] | 106 | btogFsInitrd |
---|
[841ce50] | 107 | |
---|
| 108 | |
---|
[27ee376] | 109 | #7.2 Convertivos el sistema raiz img en formato sqfs |
---|
| 110 | btogFsSqfs |
---|
| 111 | #7.3 Generamos la iso |
---|
| 112 | btogIsoGenerator |
---|
[00a2c2c] | 113 | |
---|
[841ce50] | 114 | |
---|
[00a2c2c] | 115 | # Mostrar sumario de la instalación e instrucciones de post-instalación. |
---|
| 116 | installationSummary |
---|
| 117 | |
---|
| 118 | echoAndLog "OpenGnSys installation finished at $(date)" |
---|