[00a2c2c] | 1 | #!/bin/bash |
---|
| 2 | #@file boottoolsgenerator.sh |
---|
[16fc7ab] | 3 | #@brief Script generación del sistema opertativo cliente OpenGnsys |
---|
[00a2c2c] | 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 | |
---|
[d5c3ce2] | 13 | #mkdir -p /tmp/opengnsys_installer/opengnsys |
---|
[f81c486] | 14 | #svn export https://opengnsys.es/svn/branches/version1.1/client /tmp/opengnsys_installer/opengnsys |
---|
[841ce50] | 15 | |
---|
[00a2c2c] | 16 | |
---|
| 17 | #Variables |
---|
[e4060f1] | 18 | TYPECLIENT="${1:-host}" |
---|
[00a2c2c] | 19 | WORKDIR=/tmp/opengnsys_installer |
---|
| 20 | INSTALL_TARGET=/opt/opengnsys |
---|
| 21 | PROGRAMDIR=$(readlink -e $(dirname "$0")) |
---|
| 22 | |
---|
| 23 | # Solo ejecutable por usuario root |
---|
| 24 | if [ "$(whoami)" != 'root' ] |
---|
| 25 | then |
---|
| 26 | echo "ERROR: this program must run under root privileges!!" |
---|
| 27 | exit 1 |
---|
| 28 | fi |
---|
| 29 | |
---|
[385e255] | 30 | # Cambiar a directorio temporal. |
---|
| 31 | cd /tmp |
---|
| 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 | #funciones especificas del cliente. |
---|
| 39 | source $PROGRAMDIR/boottoolsfunctions.lib |
---|
| 40 | |
---|
[0d178ab] | 41 | ####################################################################3 |
---|
| 42 | echo "FASE 1 - Asignación de variables" |
---|
| 43 | #obtenemos las variables necesarias y la información del host. |
---|
| 44 | btogGetVar |
---|
[16fc7ab] | 45 | echoAndLog "OpenGnsys CLIENT installation begins at $(date)" |
---|
[77c1f6f] | 46 | btogGetOsInfo $TYPECLIENT |
---|
[00a2c2c] | 47 | ########################################################################## |
---|
[0d178ab] | 48 | echo "FASE 2 - Instalación de software adicional." |
---|
[5d62f74] | 49 | #grep "http://free.nchc.org.tw/drbl-core" /etc/apt/sources.list || echo "deb http://free.nchc.org.tw/drbl-core drbl stable" >> /etc/apt/sources.list |
---|
[11364a6] | 50 | apt-get update |
---|
| 51 | [ -n "$(apt-cache search gpxe)" ] && PXEPKG="gpxe" |
---|
| 52 | [ -n "$(apt-cache search ipxe)" ] && PXEPKG="ipxe" |
---|
| 53 | apt-get -y --force-yes install debootstrap subversion schroot squashfs-tools syslinux genisoimage $PXEPKG qemu lsof |
---|
[ed7e34d] | 54 | ###################################################################3 |
---|
[0d178ab] | 55 | echo "FASE 3 - Creación del Sistema raiz RootFS (Segundo Sistema archivos (img)) " |
---|
| 56 | echo "Fase 3.1 Generar y formatear el disco virtual. Generar el dispositivo loop." |
---|
[00a2c2c] | 57 | file $BTROOTFSIMG | grep "partition 1: ID=0x83" |
---|
| 58 | if [ $? == 1 ] |
---|
| 59 | then |
---|
| 60 | btogSetFsVirtual || exit 2 |
---|
| 61 | fi |
---|
[0d178ab] | 62 | echo "Fase 3.2 Generar sistema de archivos con debootstrap" |
---|
[00a2c2c] | 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 |
---|
[ed7e34d] | 70 | ###################################################################3 |
---|
[0d178ab] | 71 | echo "FASE 4 - Configurar acceso schroot al Segundo Sistema de archivos (img)" |
---|
[00a2c2c] | 72 | cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess |
---|
[ed7e34d] | 73 | ########################################################################### |
---|
[16fc7ab] | 74 | echo "FASE 5 - Incorporando ficheros OpenGnsys al sistema raíz rootfs " |
---|
[83d87a3] | 75 | cp -a ${BTDIR}/includes/usr/bin/* /tmp |
---|
[a1d0fb2] | 76 | chmod +x /tmp/boot-tools/*.sh |
---|
[16fc7ab] | 77 | # Incluir revisión. |
---|
[d6b5beb] | 78 | sed -i "1 s/$/ $GITRELEASE ($OSRELEASE)/" ${BTDIR}/includes/etc/initramfs-tools/scripts/VERSION.txt |
---|
[d5c3ce2] | 79 | # En Ubuntu 13.04+ es necesario matar proceso de "udev" antes de desmontar. |
---|
| 80 | umount $BTROOTFSMNT 2>/dev/null || (kill -9 $(lsof -t $BTROOTFSMNT); umount $BTROOTFSMNT 2>/dev/null) |
---|
[841ce50] | 81 | schroot -p -c IMGogclient -- /tmp/boot-tools/boottoolsFsOpengnsys.sh |
---|
[ed7e34d] | 82 | ############################################################################################ |
---|
[0d178ab] | 83 | echo "FASE 6 - Instalar software" |
---|
[ed7e34d] | 84 | echo "Fase 6.1 instalar paquetes deb con apt-get" |
---|
[27ee376] | 85 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh |
---|
[ed7e34d] | 86 | echo "Fase 6.2 compilar software." |
---|
[00a2c2c] | 87 | cd / |
---|
[27ee376] | 88 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh |
---|
[00a2c2c] | 89 | cd - |
---|
| 90 | |
---|
[0d178ab] | 91 | echo "FASE 7 - Personalizar el sistema creado" |
---|
| 92 | echo "Fase 7.1 Incorporar la clave publica del servidor" |
---|
[00a2c2c] | 93 | cd / |
---|
| 94 | ssh-keygen -q -f /root/.ssh/id_rsa -N "" |
---|
| 95 | cp /root/.ssh/id_rsa.pub /tmp |
---|
[27ee376] | 96 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh |
---|
[00a2c2c] | 97 | cd - |
---|
[0d178ab] | 98 | echo "Fase 7.2. Incorpoar la clave publica del propio cliente" |
---|
[ed7e34d] | 99 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh |
---|
| 100 | |
---|
[0d178ab] | 101 | echo "Fase 7.3. Configurando las locales" |
---|
[ed7e34d] | 102 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh |
---|
[00a2c2c] | 103 | |
---|
| 104 | |
---|
[82ae131] | 105 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
| 106 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
| 107 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
| 108 | |
---|
[ed7e34d] | 109 | ######################################################################### |
---|
[0d178ab] | 110 | echo "FASE 8 - Generar distribucion" |
---|
| 111 | echo "Fase 8.1 Generar el initrd" |
---|
[00a2c2c] | 112 | btogFsInitrd |
---|
[0d178ab] | 113 | echo "Fase 8.2 Generar fichero sqfs a partir del fichero img" |
---|
[27ee376] | 114 | btogFsSqfs |
---|
[77c1f6f] | 115 | umount $BTROOTFSMNT 2>/dev/null |
---|
[0d178ab] | 116 | echo "Fase 8.3 Generar la ISO" |
---|
[27ee376] | 117 | btogIsoGenerator |
---|
[ed7e34d] | 118 | ######################################################################3 |
---|
| 119 | ######################################################################## |
---|
[16fc7ab] | 120 | echoAndLog "OpenGnsys installation finished at $(date)" |
---|
[82ae131] | 121 | |
---|