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