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 | #mkdir -p /tmp/opengnsys_installer/opengnsys |
---|
14 | #svn export http://opengnsys.es/svn/branches/version1.0/client /tmp/opengnsys_installer/opengnsys |
---|
15 | |
---|
16 | |
---|
17 | #Variables |
---|
18 | TYPECLIENT="host" |
---|
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 | |
---|
30 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
31 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
32 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
33 | |
---|
34 | |
---|
35 | #funciones especificas del cliente. |
---|
36 | source $PROGRAMDIR/boottoolsfunctions.lib |
---|
37 | |
---|
38 | ####################################################################3 |
---|
39 | echo "FASE 1 - Asignación de variables" |
---|
40 | #obtenemos las variables necesarias y la información del host. |
---|
41 | btogGetVar |
---|
42 | echoAndLog "OpenGnSys CLIENT installation begins at $(date)" |
---|
43 | btogGetOsInfo $TYPECLIENT |
---|
44 | ########################################################################## |
---|
45 | echo "FASE 2 - Instalación de software adicional." |
---|
46 | 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 |
---|
47 | apt-get update; apt-get -y --force-yes install debootstrap subversion schroot squashfs-tools syslinux genisoimage gpxe qemu lsof |
---|
48 | ###################################################################3 |
---|
49 | echo "FASE 3 - Creación del Sistema raiz RootFS (Segundo Sistema archivos (img)) " |
---|
50 | echo "Fase 3.1 Generar y formatear el disco virtual. Generar el dispositivo loop." |
---|
51 | file $BTROOTFSIMG | grep "partition 1: ID=0x83" |
---|
52 | if [ $? == 1 ] |
---|
53 | then |
---|
54 | btogSetFsVirtual || exit 2 |
---|
55 | fi |
---|
56 | echo "Fase 3.2 Generar sistema de archivos con debootstrap" |
---|
57 | schroot -p -c IMGogclient -- touch /tmp/ogclientOK |
---|
58 | if [ -f /tmp/ogclientOK ] |
---|
59 | then |
---|
60 | rm /tmp/ogclientOK |
---|
61 | else |
---|
62 | btogSetFsBase || exit 3 |
---|
63 | fi |
---|
64 | ###################################################################3 |
---|
65 | echo "FASE 4 - Configurar acceso schroot al Segundo Sistema de archivos (img)" |
---|
66 | cat /etc/schroot/schroot.conf | grep $BTROOTFSIMG || btogSetFsAccess |
---|
67 | ########################################################################### |
---|
68 | echo "FASE 5 - Incorporando ficheros OpenGnSys el sistema raiz rootfs " |
---|
69 | cp -a ${BTSVNBOOTTOOLS}/includes/usr/bin/* /tmp |
---|
70 | chmod +x /tmp/boot-tools/*.sh |
---|
71 | # En Ubuntu 13.04+ es necesario matar proceso de "udev" antes de desmontar. |
---|
72 | umount $BTROOTFSMNT 2>/dev/null || (kill -9 $(lsof -t $BTROOTFSMNT); umount $BTROOTFSMNT 2>/dev/null) |
---|
73 | schroot -p -c IMGogclient -- /tmp/boot-tools/boottoolsFsOpengnsys.sh |
---|
74 | ############################################################################################ |
---|
75 | echo "FASE 6 - Instalar software" |
---|
76 | echo "Fase 6.1 instalar paquetes deb con apt-get" |
---|
77 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareInstall.sh |
---|
78 | echo "Fase 6.2 compilar software." |
---|
79 | cd / |
---|
80 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSoftwareCompile.sh |
---|
81 | cd - |
---|
82 | |
---|
83 | echo "FASE 7 - Personalizar el sistema creado" |
---|
84 | echo "Fase 7.1 Incorporar la clave publica del servidor" |
---|
85 | cd / |
---|
86 | ssh-keygen -q -f /root/.ssh/id_rsa -N "" |
---|
87 | cp /root/.ssh/id_rsa.pub /tmp |
---|
88 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshServer.sh |
---|
89 | cd - |
---|
90 | echo "Fase 7.2. Incorpoar la clave publica del propio cliente" |
---|
91 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsSshClient.sh |
---|
92 | |
---|
93 | echo "Fase 7.3. Configurando las locales" |
---|
94 | schroot -p -c IMGogclient -- /usr/bin/boot-tools/boottoolsFsLocales.sh |
---|
95 | |
---|
96 | |
---|
97 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
98 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
99 | for i in `mount | grep IMGogclient | grep /var | cut -f3 -d" "`; do echo $i; umount $i; done |
---|
100 | |
---|
101 | ######################################################################### |
---|
102 | echo "FASE 8 - Generar distribucion" |
---|
103 | echo "Fase 8.1 Generar el initrd" |
---|
104 | btogFsInitrd |
---|
105 | echo "Fase 8.2 Generar fichero sqfs a partir del fichero img" |
---|
106 | btogFsSqfs |
---|
107 | umount $BTROOTFSMNT 2>/dev/null |
---|
108 | echo "Fase 8.3 Generar la ISO" |
---|
109 | btogIsoGenerator |
---|
110 | ######################################################################3 |
---|
111 | ######################################################################## |
---|
112 | echoAndLog "OpenGnSys installation finished at $(date)" |
---|
113 | |
---|