1 | |
---|
2 | ogClientVar() |
---|
3 | { |
---|
4 | export SVNCLIENTDIR=/tmp/opengnsys_installer/opengnsys/client/boot-tools |
---|
5 | export SVNCLIENTSTRUCTURE=/tmp/opengnsys_installer/opengnsys/client/shared |
---|
6 | export SVNCLIENTENGINE=/tmp/opengnsys_installer/opengnsys/client/engine |
---|
7 | |
---|
8 | export OGCLIENTBASEDIR=/var/lib/tftpboot/ogclient/ |
---|
9 | export OGCLIENTFILE=${OGCLIENTBASEDIR}ogclient.img |
---|
10 | export OGCLIENTMOUNT=${OGCLIENTBASEDIR}ogclientmount |
---|
11 | # tamaño maximo limitado por schroot 2GB |
---|
12 | export OGCLIENTSIZEMB=1900 |
---|
13 | #export OGCLIENTSIZEMB=1000 |
---|
14 | # export OGCLIENTSIZEKB=500 |
---|
15 | export OGCLIENTLABEL=ogClient |
---|
16 | #export OGLIB=/opt/opengnsys/client/lib |
---|
17 | } |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | function ogClientOsInfo () |
---|
22 | { |
---|
23 | #TODO según host, un OSHHTP u otro OSARCH |
---|
24 | #1 OSCODENAME jaunty|karmic|lucid |
---|
25 | #devuelve OSDISTRIB(ubuntu,debian),OSCODENAME(lucid,karmic,squeeze):OGRELEASE:httpAPT |
---|
26 | case $1 in |
---|
27 | host | HOST) |
---|
28 | export OSDISTRIB=$(lsb_release -i | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null |
---|
29 | #OSCODENAME=$(lsb_release -c | awk -F: '{sub(/\t/,""); print $2}') 2>/dev/null |
---|
30 | export OSCODENAME=$(cat /etc/lsb-release | grep CODENAME | awk -F= '{print $NF}') |
---|
31 | export OSRELEASE=$(uname -a | awk '{print $3}') |
---|
32 | uname -a | grep x86_64 > /dev/null && export OSARCH=amd64 || export OSARCH=i386 |
---|
33 | export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" |
---|
34 | ;; |
---|
35 | jaunty|JAUNTY) |
---|
36 | export OSDISTRIB=ubuntu |
---|
37 | export OSCODENAME=jaunty |
---|
38 | export OSRELEASE="2.6.28-11-generic" |
---|
39 | export OSARCH=i386 |
---|
40 | export OSHTTP="http://es.archive.ubuntu.com/ubuntu/" |
---|
41 | ;; |
---|
42 | lenny|LENNY) |
---|
43 | export OSDISTRIB=debian |
---|
44 | export OSCODENAME=lenny |
---|
45 | export OSRELEASE="2.6.28-11-generic" |
---|
46 | export OSARCH=i386 |
---|
47 | export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " |
---|
48 | ;; |
---|
49 | squeeze|SQUEEZE) |
---|
50 | export OSDISTRIB=debian |
---|
51 | export OSCODENAME=squeeze |
---|
52 | export OSRELEASE="2.6.28-11-generic" |
---|
53 | export OSARCH=i386 |
---|
54 | export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " |
---|
55 | ;; |
---|
56 | karmic|KARMIC) |
---|
57 | export OSDISTRIB=ubuntu |
---|
58 | export OSCODENAME=karmic |
---|
59 | export OSRELEASE="2.6.31-14-generic" |
---|
60 | export OSARCH=i386 |
---|
61 | export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " |
---|
62 | ;; |
---|
63 | lucid|LUCID) |
---|
64 | export OSDISTRIB=ubuntu |
---|
65 | export OSCODENAME=lucid |
---|
66 | export OSRELEASE="2.6.32-21-generic-pae" |
---|
67 | export OSARCH=i386 |
---|
68 | export OSHTTP="http://es.archive.ubuntu.com/ubuntu/ " |
---|
69 | ;; |
---|
70 | *) |
---|
71 | return 1 |
---|
72 | ;; |
---|
73 | esac |
---|
74 | echo $OSDISTRIB:$OSCODENAME:$OSRELEASE:$OSARCH:$OSHTTP |
---|
75 | } |
---|
76 | |
---|
77 | #creación y formateo del disco virtual. |
---|
78 | ogClient2ndFile () |
---|
79 | { |
---|
80 | local RERROR DISKLOOP PARTLOOP #return code error |
---|
81 | echoAndLog "$FUNCNAME(): Creación y formateo del disco virtual $OGCLIENTSIZEMB MB " |
---|
82 | #Desmontamos por si acaso el dispositivo virtual |
---|
83 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
84 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
85 | echo "$FUNCNAME(): Creando el directorio donde se montará el disco virtual $OGCLIENTMOUNT" |
---|
86 | mkdir -p $OGCLIENTMOUNT |
---|
87 | if [ $? -ne 0 ] |
---|
88 | then |
---|
89 | errorAndLog "$FUNCNAME(): Creando directorio $OGCLIENTMOUNT : ERROR" |
---|
90 | return 1 |
---|
91 | fi |
---|
92 | echo "$FUNCNAME(): Creando el disco virtual que almacenará el FS del cliente $OGCLIENTSIZEMB MB de datos físicos" |
---|
93 | dd if=/dev/zero of=$OGCLIENTFILE bs=1048576 count=$OGCLIENTSIZEMB |
---|
94 | #qemu-img create $OGCLIENTFILE 3G |
---|
95 | #dd if=/dev/zero of=$OGCLIENTFILE bs=1k count=$OGCLIENTSIZEKB # necesita 500MB |
---|
96 | if [ $? -ne 0 ] |
---|
97 | then |
---|
98 | errorAndLog "$FUNCNAME(): Creando el disco virtual: ERROR" |
---|
99 | return 1 |
---|
100 | fi |
---|
101 | |
---|
102 | DISKLOOP=$(losetup -f) |
---|
103 | losetup $DISKLOOP $OGCLIENTFILE |
---|
104 | echo "$FUNCNAME(): particiondo el disco virtual - $DISKLOOP - con una particion primaria" |
---|
105 | echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk $DISKLOOP |
---|
106 | #echo $? |
---|
107 | # da error, porque no puede actualizar el kernel. |
---|
108 | #if [ $? -ne 0 ] |
---|
109 | #then |
---|
110 | # errorAndLog "$FUNCNAME(): Particionando el disco virutal: ERROR" |
---|
111 | # return 1 |
---|
112 | #fi |
---|
113 | |
---|
114 | echoAndLog "$FUNCNAME(): Desmontando $DISKLOOP despues del particionado " |
---|
115 | losetup -d $DISKLOOP |
---|
116 | |
---|
117 | if [ $? -ne 0 ] |
---|
118 | then |
---|
119 | errorAndLog "$FUNCNAME(): Liberando disco virtual despues del particionado: ERROR" |
---|
120 | return 1 |
---|
121 | fi |
---|
122 | |
---|
123 | |
---|
124 | #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 |
---|
125 | #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 |
---|
126 | PARTLOOP=$(losetup -f) |
---|
127 | echo "$FUNCNAME(): Formateando la particion principal $PARTLOOP" |
---|
128 | losetup -o 32256 $PARTLOOP $OGCLIENTFILE && mkfs.ext3 -b 4096 -L $OGCLIENTLABEL $PARTLOOP |
---|
129 | if [ $? -ne 0 ] |
---|
130 | then |
---|
131 | errorAndLog "$FUNCNAME(): Formateando la particion principal del disco virtual: ERROR" |
---|
132 | return 1 |
---|
133 | fi |
---|
134 | echoAndLog "$FUNCNAME(): Desmontando $PARTLOOP despues del formateo " |
---|
135 | losetup -d $PARTLOOP |
---|
136 | if [ $? -ne 0 ] |
---|
137 | then |
---|
138 | errorAndLog "$FUNCNAME(): Liberando la particion virtual despues del formateo: ERROR" |
---|
139 | return 1 |
---|
140 | else |
---|
141 | echoAndLog "$FUNCNAME(): $OGCLIENTFILE $OGCLIENTSIZEMB MB : OK" |
---|
142 | fi |
---|
143 | } |
---|
144 | |
---|
145 | |
---|
146 | |
---|
147 | |
---|
148 | |
---|
149 | ogClient2ndFs () |
---|
150 | { |
---|
151 | ogClientOsInfo $1 |
---|
152 | echoAndLog "$FUNCNAME: Iniciando la generación del sistema de archivos " |
---|
153 | #Montamos el dispositivo virtual en su punto de montaje. |
---|
154 | mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
155 | |
---|
156 | mount | grep $OGCLIENTMOUNT && echoAndLog "$FUNCNAME: mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 OK " || errorAndLog "$FUNCNAME: mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 : FAILURE " |
---|
157 | |
---|
158 | #debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe ${OSCODENAME} ${OGCLIENTMOUNT} ${OSHTTP} |
---|
159 | debootstrap --arch=$OSARCH --components=main,universe ${OSCODENAME} ${OGCLIENTMOUNT} ${OSHTTP} |
---|
160 | |
---|
161 | |
---|
162 | if [ $? -ne 0 ]; then |
---|
163 | errorAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $OGCLIENTMOUNT $OSHTTP |
---|
164 | : ha fallado!" |
---|
165 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
166 | return 1 |
---|
167 | else |
---|
168 | echoAndLog "$FUNCNAME: debootstrap --include=linux-image-${OSRELEASE},linux-headers-${OSRELEASE} --arch=$OSARCH --components=main,universe $OSCODENAME $OGCLIENTMOUNT $OSHTTP |
---|
169 | : ok" |
---|
170 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
171 | return 0 |
---|
172 | fi |
---|
173 | sleep 5 |
---|
174 | |
---|
175 | ##preubas revisar OSRELEASE |
---|
176 | #debootstrap --include=linux-image-${OSRELEASE} --arch=i386 --variant=minbase $OSVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
177 | #debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
178 | #echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
179 | } |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | ########## configura el segundo sistema de archivos |
---|
185 | ########### parametro: "host" |
---|
186 | function ogClient2ndSVN() |
---|
187 | { |
---|
188 | ogClientOsInfo $1 |
---|
189 | #1 la salida de ogClientOsInfo |
---|
190 | local LERROR |
---|
191 | LERROR=TRUE |
---|
192 | echoAndLog "$FUNCNAME: Iniciando la personalización con datos del SVN " |
---|
193 | # comprobar que está montado $OGCLIENTMOUNT |
---|
194 | mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
195 | |
---|
196 | # parseamos del apt.source |
---|
197 | sed -e "s/OSCODENAME/$OSCODENAME/g" ${SVNCLIENTDIR}/clientstructure/etc/apt/sources.list.ubuntu > ${SVNCLIENTDIR}/clientstructure/etc/apt/sources.list |
---|
198 | if [ $? -ne 0 ] |
---|
199 | then |
---|
200 | errorAndLog "$FUNCNAME(): Parsing apt.sources : ERROR" |
---|
201 | return 1 |
---|
202 | fi |
---|
203 | |
---|
204 | #parseamos el script de generación del initrd. |
---|
205 | sed -e "s/OSRELEASE/$OSRELEASE/g" ${SVNCLIENTDIR}/clientstructure/root/GenerateInitrd.generic.sh > ${SVNCLIENTDIR}/clientstructure/root/GenerateInitrd.sh |
---|
206 | if [ $? -ne 0 ] |
---|
207 | then |
---|
208 | errorAndLog "$FUNCNAME(): Parsing GenerateInitrd.sh : ERROR" |
---|
209 | return 1 |
---|
210 | fi |
---|
211 | |
---|
212 | #damos permiso al directorio de scripts |
---|
213 | chmod 775 ${SVNCLIENTDIR}/clientstructure/root/* |
---|
214 | |
---|
215 | # los copiamos |
---|
216 | cp -prv ${SVNCLIENTDIR}/clientstructure/* $OGCLIENTMOUNT |
---|
217 | mkdir -p ${OGCLIENTMOUNT}/opt/opengnsys/ |
---|
218 | cp -prv ${SVNCLIENTSTRUCTURE}/* ${OGCLIENTMOUNT}/opt/opengnsys/ |
---|
219 | cp -prv ${SVNCLIENTENGINE}/* ${OGCLIENTMOUNT}/opt/opengnsys/lib/engine/bin/ |
---|
220 | |
---|
221 | if [ $? -ne 0 ] |
---|
222 | then |
---|
223 | errorAndLog "$FUNCNAME(): Copying client data : ERROR" |
---|
224 | return 1 |
---|
225 | fi |
---|
226 | |
---|
227 | # copiamos algunas cosas del nfsexport |
---|
228 | |
---|
229 | #### Tipos de letra para el Browser. |
---|
230 | cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/lib/fonts |
---|
231 | #### Crear enlaces para compatibilidad con las distintas versiones del Browser. |
---|
232 | mkdir -p $OGCLIENTMOUNT/usr/local/Trolltech/QtEmbedded-4.5.1/lib/ |
---|
233 | mkdir -p $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.2/lib/ |
---|
234 | mkdir -p $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.3/lib/ |
---|
235 | #ln -fs $OGCLIENTMOUNT/usr/local/lib/fonts /usr/local/Trolltech/QtEmbedded-4.5.1/lib/fonts |
---|
236 | #ln -fs $OGCLIENTMOUNT/usr/local/lib/fonts /usr/local/QtEmbedded-4.6.2/lib/fonts |
---|
237 | #ln -fs $OGCLIENTMOUNT/usr/local/lib/fonts /usr/local/QtEmbedded-4.6.3/lib/fonts |
---|
238 | cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/Trolltech/QtEmbedded-4.5.1/lib/fonts |
---|
239 | cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.2/lib/fonts |
---|
240 | cp -pr ${SVNCLIENTSTRUCTURE}/lib/fonts $OGCLIENTMOUNT/usr/local/QtEmbedded-4.6.3/lib/fonts |
---|
241 | |
---|
242 | |
---|
243 | |
---|
244 | |
---|
245 | if [ $? -ne 0 ] |
---|
246 | then |
---|
247 | errorAndLog "$FUNCNAME(): Linking Browser fonts : ERROR" |
---|
248 | return 1 |
---|
249 | fi |
---|
250 | |
---|
251 | # B ######################################################## |
---|
252 | cp -pr ${SVNCLIENTSTRUCTURE}/lib/pci.ids $OGCLIENTMOUNT/etc |
---|
253 | if [ $? -ne 0 ] |
---|
254 | then |
---|
255 | errorAndLog "$FUNCNAME(): Copying pci.ids : ERROR" |
---|
256 | return 1 |
---|
257 | fi |
---|
258 | |
---|
259 | cp ${SVNCLIENTSTRUCTURE}/bin/browser $OGCLIENTMOUNT/bin |
---|
260 | if [ $? -ne 0 ] |
---|
261 | then |
---|
262 | errorAndLog "$FUNCNAME(): Copying Browser : ERROR" |
---|
263 | return 1 |
---|
264 | fi |
---|
265 | |
---|
266 | cp ${SVNCLIENTSTRUCTURE}/bin/ogAdmClient $OGCLIENTMOUNT/bin |
---|
267 | if [ $? -ne 0 ] |
---|
268 | then |
---|
269 | errorAndLog "$FUNCNAME(): Copying ogAdmClient : ERROR" |
---|
270 | return 1 |
---|
271 | else |
---|
272 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
273 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
274 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
275 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
276 | echoAndLog "$FUNCNAME: Finalizado: OK " |
---|
277 | return 0 |
---|
278 | fi |
---|
279 | } |
---|
280 | |
---|
281 | |
---|
282 | ogClientSchrootConf() |
---|
283 | { |
---|
284 | echoAndLog "$FUNCNAME: Iniciando la configuración del schroot " |
---|
285 | cp /etc/schroot/schroot.conf /etc/schroot/schroot.conf.`getDateTime` |
---|
286 | cat << EOF > /etc/schroot/schroot.conf |
---|
287 | [IMGogclient] |
---|
288 | type=loopback |
---|
289 | file=/var/lib/tftpboot/ogclient/ogclient.img |
---|
290 | description=ogclient ubuntu luc IMGi |
---|
291 | priority=1 |
---|
292 | users=root |
---|
293 | groups=root |
---|
294 | root-groups=root |
---|
295 | mount-options=-o offset=32256 |
---|
296 | root-users=root |
---|
297 | [DIRogclient] |
---|
298 | type=directory |
---|
299 | directory=/var/lib/tftpboot/ogclient/ogclientmount |
---|
300 | description=ogclient ubuntu lucid DIR |
---|
301 | priority=2 |
---|
302 | users=root |
---|
303 | groups=root |
---|
304 | root-groups=root |
---|
305 | root-users=root |
---|
306 | EOF |
---|
307 | cp /etc/schroot/mount-defaults /etc/schroot/mount-defaults.`getDateTime` |
---|
308 | cat << EOF > /etc/schroot/mount-defaults |
---|
309 | # mount.defaults: static file system information for chroots. |
---|
310 | # Note that the mount point will be prefixed by the chroot path |
---|
311 | # (CHROOT_PATH) |
---|
312 | # |
---|
313 | # <file system> <mount point> <type> <options> <dump> <pass> |
---|
314 | proc /proc proc defaults 0 0 |
---|
315 | #procbususb /proc/bus/usb usbfs defaults 0 0 |
---|
316 | #/dev /dev none rw,bind 0 0 |
---|
317 | /dev/pts /dev/pts none rw,bind 0 0 |
---|
318 | /dev/shm /dev/shm none rw,bind 0 0 |
---|
319 | #/home /home none rw,bind 0 0 |
---|
320 | /tmp /tmp none rw,bind 0 0 |
---|
321 | EOF |
---|
322 | |
---|
323 | echoAndLog "$FUNCNAME: Finalizado: OK " |
---|
324 | return 0 |
---|
325 | } |
---|
326 | |
---|
327 | |
---|
328 | |
---|
329 | ########### param1 "host" |
---|
330 | ogClientInitrd() |
---|
331 | { |
---|
332 | ogClientVar |
---|
333 | cd / |
---|
334 | ogClientOsInfo $1 |
---|
335 | schroot -c IMGogclient -- /root/GenerateInitrd.generic.sh |
---|
336 | echo "cp /tmp/*-${OSRELEASE} $OGCLIENTBASEDIR" |
---|
337 | cp /tmp/*-${OSRELEASE} $OGCLIENTBASEDIR |
---|
338 | cp /tmp/initrd.img-${OSRELEASE} ${OGCLIENTBASEDIR}/oginitrd.img |
---|
339 | cp /tmp/vmlinuz-${OSRELEASE} ${OGCLIENTBASEDIR}/ogvmlinuz |
---|
340 | cd - |
---|
341 | } |
---|
342 | |
---|
343 | |
---|
344 | ogClient2ndSqfs() |
---|
345 | { |
---|
346 | ogClientVar |
---|
347 | echoAndLog "$FUNCNAME: Iniciando la creación del sistema de archivos en sqfs " |
---|
348 | # si ya existe un sqfs lo renombramos |
---|
349 | [ -f $OGCLIENTBASEDIR/ogclient.sqfs ] && mv $OGCLIENTBASEDIR/ogclient.sqfs $OGCLIENTBASEDIR/ogclient.sqfs.`date +%Y%m%d-%H%M%S` |
---|
350 | mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
351 | mksquashfs $OGCLIENTMOUNT $OGCLIENTBASEDIR/ogclient.sqfs |
---|
352 | chmod 744 $OGCLIENTBASEDIR/ogclient.sqfs |
---|
353 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
354 | } |
---|
355 | |
---|
356 | |
---|
357 | |
---|
358 | |
---|
359 | ogClientSshkeys() |
---|
360 | { |
---|
361 | echo comprobamos clave rsa en el host REPO OG. |
---|
362 | if [ ! -f /root/.ssh/id_rsa.pub ] |
---|
363 | then |
---|
364 | echo "creando claves rsa" |
---|
365 | ssh-keygen -q -f /root/.ssh/id_dsa -t dsa -N "opengnsys" |
---|
366 | else |
---|
367 | echo "la claves ya estan creadas" |
---|
368 | fi |
---|
369 | echo "copiamos la clave publica a /tmp" |
---|
370 | cp /root/.ssh/id_dsa.pub /tmp |
---|
371 | |
---|
372 | cat /tmp/id_dsa.pub |
---|
373 | |
---|
374 | echo "schroot con instrucciones." |
---|
375 | schroot -c IMGogclient -- /root/importSshKeys.sh |
---|
376 | |
---|
377 | echo "limpiando" |
---|
378 | rm /tmp/id_dsa.pub |
---|
379 | |
---|
380 | ## copiamos ssh rsa del host al guest como authorized-key2 |
---|
381 | ##rm ${OGCLIENTMOUNT}/root/.ssh/authorized-key2 |
---|
382 | ##cat /root/.ssh/id_rsa.pub >> ${OGCLIENTMOUNT}/root/.ssh/authorized-key2 |
---|
383 | #cat ${OGCLIENTMOUNT}/root/.ssh/id_rsa.pub >> ${OGCLIENTMOUNT}/root/.ssh/authorized-key2 |
---|
384 | ##mount | grep $OGCLIENTMOUNT || umount $OGCLIENTMOUNT |
---|
385 | } |
---|
386 | |
---|
387 | |
---|
388 | |
---|
389 | function ogCrearISO { |
---|
390 | apt-get install syslinux genisoimage |
---|
391 | #TODO: deb http://free.nchc.org.tw/drbl-core drbl stable |
---|
392 | #apt-get install gpxe |
---|
393 | mkdir -p /tmp/iso/isolinux |
---|
394 | #cd tmp/iso/ |
---|
395 | cp -prv /usr/lib/syslinux/* /tmp/iso/isolinux/ |
---|
396 | cp -prv /usr/share/gpxe/* /tmp/iso/isolinux/ |
---|
397 | mkdir -p /tmp/iso/ogclient |
---|
398 | #el ogclienteToISO debe tener una copia del ogvmlinuz como linuxISO |
---|
399 | cp -prv /var/lib/tftpboot/ogclientToIso/* /tmp/iso/ogclient |
---|
400 | |
---|
401 | |
---|
402 | cat << FIN > /tmp/iso/isolinux/isolinux.cfg |
---|
403 | DEFAULT menu.c32 |
---|
404 | PROMPT 0 |
---|
405 | ALLOWOPTIONS 1 |
---|
406 | |
---|
407 | MENU TITLE OpenGnsys 1.0.1 v00 |
---|
408 | |
---|
409 | LABEL gpxe |
---|
410 | MENU LABEL gpxe |
---|
411 | KERNEL /clonezilla/live/vmlinuz1 |
---|
412 | APPEND initrd=/clonezilla/live/initrd1.img boot=live union=aufs noswap vga=788 ip=frommedia |
---|
413 | |
---|
414 | |
---|
415 | #default 0 |
---|
416 | #prompt 1 |
---|
417 | #timeout 100 |
---|
418 | |
---|
419 | #display mensaje.txt |
---|
420 | |
---|
421 | |
---|
422 | |
---|
423 | |
---|
424 | LABEL 0 |
---|
425 | MENU LABEL ogClient vga irqpool acpi ogdebug ip:none |
---|
426 | KERNEL /ogclient/linuxISO |
---|
427 | APPEND initrd=/ogclient/oginitrd.img ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none |
---|
428 | |
---|
429 | LABEL 1 |
---|
430 | MENU LABEL ogClient irqpoll acpi ip:none |
---|
431 | KERNEL /ogclient/linuxISO |
---|
432 | APPEND initrd=/ogclient/oginitrd.img ro irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=none |
---|
433 | |
---|
434 | LABEL 2 |
---|
435 | MENU LABEL ogClient acpi debug ip=dhcp |
---|
436 | KERNEL /ogclient/linuxISO |
---|
437 | APPEND initrd=/ogclient/oginitrd.img ro acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=dhcp |
---|
438 | |
---|
439 | LABEL 3 |
---|
440 | MENU LABEL ogClient ip=dhcp |
---|
441 | KERNEL /ogclient/linuxISO |
---|
442 | APPEND initrd=/ogclient/oginitrd.img ro acpi=off boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=false ip=dhcp |
---|
443 | |
---|
444 | |
---|
445 | #LABEL ogclient |
---|
446 | #KERNEL /ogclient/linuxISO |
---|
447 | #APPEND initrd=/ogclient/initrdISO.img |
---|
448 | |
---|
449 | #KERNEL linuxISO |
---|
450 | #APPEND initrd=initrdISO.img |
---|
451 | |
---|
452 | LABEL 4 |
---|
453 | MENU LABEL local |
---|
454 | localboot 0x80 |
---|
455 | append - |
---|
456 | |
---|
457 | |
---|
458 | label 5 |
---|
459 | MENU LABEL Network boot via gPXE lkrn |
---|
460 | KERNEL gpxe.lkrn |
---|
461 | |
---|
462 | label 5 |
---|
463 | MENU LABEL Network boot via gPXE usb |
---|
464 | KERNEL gpxe.usb |
---|
465 | |
---|
466 | label 5 |
---|
467 | MENU LABEL Network boot via gPXE pxe |
---|
468 | KERNEL gpxe.pxe |
---|
469 | |
---|
470 | label 5 |
---|
471 | MENU LABEL Network boot via gPXE iso |
---|
472 | KERNEL gpxe.iso |
---|
473 | FIN |
---|
474 | #### /tmp/iso# |
---|
475 | mkisofs -V ogClient -o ogClient.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -J -no-emul-boot -boot-load-size 4 -boot-info-table tmp/iso |
---|
476 | |
---|
477 | ### vi /etc/grub.d/40_custom |
---|
478 | ## |
---|
479 | #menuentry "og cache " { |
---|
480 | #set root=(hd0,4) |
---|
481 | #linux /ogvmlinuz ro vga=788 irqpoll acpi=on boot=oginit og2nd=sqfs ogprotocol=local ogactiveadmin=true ogdebug=true ip=none |
---|
482 | #initrd /oginitrd.img |
---|
483 | #} |
---|
484 | |
---|
485 | |
---|
486 | } |
---|
487 | |
---|
488 | function ogprobarISO { |
---|
489 | #/tmp/iso |
---|
490 | qemu -m 256 -boot d -cdrom ogClient.iso |
---|
491 | } |
---|
492 | |
---|
493 | |
---|
494 | |
---|
495 | |
---|
496 | |
---|
497 | |
---|
498 | |
---|
499 | ogClientConfpxe() |
---|
500 | { |
---|
501 | ################## DEJAMOS FICHERO DE EJEMPLOS PARA: |
---|
502 | #default |
---|
503 | cat << FIN >> /var/lib/tftpboot/pxelinux.cfg/defaultNEWClient |
---|
504 | LABEL pxe-${OGRELEASE} |
---|
505 | KERNEL ogclient/vmlinuz-$OGRELEASE |
---|
506 | APPEND initrd=ogclient/initrd.img-$OGRELEASE ip=dhcp ro boot=og vga=788 irqpoll acpi=on reposerver= |
---|
507 | LABEL pxe-2.6.32-21-generic-pae |
---|
508 | KERNEL ogclient/vmlinuz-2.6.32-21-generic-pae |
---|
509 | APPEND initrd=ogclient/initrd.img-2.6.32-21-generic-pae ip=dhcp ro boot=oginit vga=788 irqpoll acpi=on ogrepo=172.17.36.11 ogprotocol=nfs og2nd=sqfs |
---|
510 | LABEL cache |
---|
511 | KERNEL grub.exe |
---|
512 | APPEND --config-file="find --set-root /vmlinuz; kernel /vmlinuz ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd /initrd.img" |
---|
513 | LABEL net |
---|
514 | KERNEL grub.exe |
---|
515 | APPEND keeppxe --config-file="pxe detect; kernel (pd)/ogclient/vmlinuz-2.6.32-21-generic-pae ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd (pd)/ogclient/initrd.img-2.6.32-21-generic-pae" |
---|
516 | LABEL IfNOTcacheGOnet |
---|
517 | KERNEL grub.exe |
---|
518 | APPEND keeppxe --config-file="pxe detect; default 0; timeout 0; hiddenmenu; title cache; fallback 1; find --set-root /vmlinuz; kernel /vmlinuz ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd /initrd.img; boot; title net; kernel (pd)/ogclient/vmlinuz-2.6.32-21-generic-pae ip=dhcp ro boot=og vga=788 irqpoll acpi=on engine=testing reposerver=172.17.32.242; initrd (pd)/ogclient/initrd.img-2.6.32-21-generic-pae; boot" |
---|
519 | #LABEL pxe-2.6.32-21-generic-pae |
---|
520 | #KERNEL ogclient/vmlinuz-2.6.32-21-generic-pae |
---|
521 | #APPEND initrd=ogclient/initrd.img-2.6.32-21-generic-pae ip=dhcp ro boot=og vga=788 irqpoll acpi=on reposerver=172.17.32.242 |
---|
522 | #LABEL grub |
---|
523 | #KERNEL grub.exe |
---|
524 | #APPEND keeppxe |
---|
525 | FIN |
---|
526 | #/etc/hosts |
---|
527 | echo "/var/lib/tftpboot *(ro,no_subtree_check,no_root_squash,sync)" > /etc/exportsNEWClient |
---|
528 | /etc/init.d/nfs-kernel-server restart |
---|
529 | ##################################################################### |
---|
530 | } |
---|
531 | |
---|
532 | |
---|
533 | |
---|
534 | ############### No usados en el instalador, solo en actualizaciones. |
---|
535 | #/** |
---|
536 | # ogClientMount [str_program] |
---|
537 | #@brief Acceso al 2nd FS del cliente desde el Servidor Opengnsys |
---|
538 | #@param 1 Opciona: scripts o programa a ejecutar para automatizaciones |
---|
539 | #@return Si no hay parametros: login de acceso. |
---|
540 | #@return con un parametro: La salida del programa ejecutado |
---|
541 | #@exception |
---|
542 | #@note |
---|
543 | #@todo |
---|
544 | #@version 0.9 - Primera versión para OpenGnSys |
---|
545 | #@author Antonio J. Doblas Viso, Universidad de Málaga |
---|
546 | #@date 2010/02/15 |
---|
547 | #*/ ## |
---|
548 | function ogClientMount () |
---|
549 | { |
---|
550 | #TODO comprobar que OGFILE y OGFILEMOUNT existe. |
---|
551 | mount | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
552 | mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc |
---|
553 | mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys |
---|
554 | mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp |
---|
555 | mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev |
---|
556 | mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts |
---|
557 | |
---|
558 | |
---|
559 | [ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`) |
---|
560 | [ $# = 1 ] && chroot $OGCLIENTMOUNT $1 |
---|
561 | |
---|
562 | } |
---|
563 | |
---|
564 | #/** |
---|
565 | # ogClientUnmount |
---|
566 | #@brief Desmonta el 2nd FS del cliente desde el Servidor Opengnsys |
---|
567 | #@param |
---|
568 | #@return |
---|
569 | #@exception |
---|
570 | #@note |
---|
571 | #@todo |
---|
572 | #@version 0.9 - Primera versión para OpenGnSys |
---|
573 | #@author Antonio J. Doblas Viso, Universidad de Málaga |
---|
574 | #@date 2010/02/15 |
---|
575 | #*/ ## |
---|
576 | |
---|
577 | function ogClientUnmount () |
---|
578 | { |
---|
579 | cd /tmp |
---|
580 | echo "desmontando cliente espere" |
---|
581 | sleep 5 |
---|
582 | mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount |
---|
583 | mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount |
---|
584 | mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount |
---|
585 | mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount |
---|
586 | mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount |
---|
587 | mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount |
---|
588 | #-d -f -l |
---|
589 | |
---|
590 | } |
---|
591 | |
---|
592 | |
---|
593 | ############################ hasta el final del archivo antiguos |
---|
594 | ############################# ANTIGUOS |
---|
595 | function ogClientGetRelease () |
---|
596 | { |
---|
597 | #1 OSCODENAME jaunty|karmic|lucid |
---|
598 | case $1 in |
---|
599 | jaunty|JAUNTY) |
---|
600 | OSCODENAME=jaunty |
---|
601 | OGRELEASE="2.6.28-11-generic" |
---|
602 | echo $OGRELEASE |
---|
603 | ;; |
---|
604 | lenny|LENNY) |
---|
605 | OSCODENAME=lenny |
---|
606 | OGRELEASE="2.6.28-11-generic" |
---|
607 | echo $OGRELEASE |
---|
608 | ;; |
---|
609 | squeeze|SQUEEZE) |
---|
610 | OSCODENAME=squeeze |
---|
611 | OGRELEASE="2.6.28-11-generic" |
---|
612 | echo $OGRELEASE |
---|
613 | ;; |
---|
614 | karmic|KARMIC) |
---|
615 | OSCODENAME=karmic |
---|
616 | OGRELEASE="2.6.31-14-generic" |
---|
617 | echo $OGRELEASE |
---|
618 | ;; |
---|
619 | lucid|LUCID) |
---|
620 | OSCODENAME=lucid |
---|
621 | OGRELEASE="2.6.32-21-generic-pae" |
---|
622 | echo $OGRELEASE |
---|
623 | ;; |
---|
624 | *) |
---|
625 | return 1 |
---|
626 | ;; |
---|
627 | esac |
---|
628 | |
---|
629 | } |
---|
630 | |
---|
631 | |
---|
632 | #/** |
---|
633 | # ogClientGenerator str_versionUbuntu str_release |
---|
634 | #@brief Crea el 2nd FS del cliente desde el Servidor Opengnsys |
---|
635 | #@param 1 Versión de ubuntu a generar, jaunty karmic |
---|
636 | #@return |
---|
637 | #@exception |
---|
638 | #@note |
---|
639 | #@todo |
---|
640 | #@version 0.9 - Primera versión para OpenGnSys |
---|
641 | #@author Antonio J. Doblas Viso, Universidad de Málaga |
---|
642 | #@date 2010/02/15 |
---|
643 | #*/ ## |
---|
644 | |
---|
645 | function ogClientGeneratorDebootstrap () |
---|
646 | { |
---|
647 | if [ $# != 2 ] |
---|
648 | then |
---|
649 | echo Debes introducir como argumento1: jaunty karmic lucid |
---|
650 | echo Debes introducir como argumento2: la release |
---|
651 | echo utiliza como entrada ogClientCheckVersion |
---|
652 | return |
---|
653 | fi |
---|
654 | OSCODENAME=$1 |
---|
655 | OGRELEASE=$2 |
---|
656 | |
---|
657 | # instalamos el ultimo debotstrap para permitir instalar versiones superiores a nuestro sistema |
---|
658 | #apt-get install gdebi-core |
---|
659 | #wget $LASTDEBOOTSTRAP |
---|
660 | #gdebi -n debootstrap_1.0.20_all.deb |
---|
661 | |
---|
662 | #Desmontamos por si acaso el dispositivo virtual |
---|
663 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
664 | |
---|
665 | #Creamos el directorio donde montaremos el disco virtual |
---|
666 | mkdir -p $OGCLIENTMOUNT |
---|
667 | |
---|
668 | #Creamos el disco virtual con el filesystem del cliente. |
---|
669 | dd if=/dev/zero of=$OGCLIENTFILE bs=1048576 count=$OGCLIENTSIZEMB |
---|
670 | #qemu-img create $OGCLIENTFILE 3G |
---|
671 | #dd if=/dev/zero of=$OGCLIENTFILE bs=1k count=$OGCLIENTSIZEKB # necesita 500MB |
---|
672 | |
---|
673 | |
---|
674 | #particionamos el disco virtual |
---|
675 | losetup /dev/loop0 $OGCLIENTFILE |
---|
676 | echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk /dev/loop0 |
---|
677 | losetup -d /dev/loop0 |
---|
678 | |
---|
679 | |
---|
680 | #formateamos la particion principal. |
---|
681 | losetup -o 32256 /dev/loop1 $OGCLIENTFILE |
---|
682 | mkfs.ext3 -b 4096 -L $OGCLIENTLABEL /dev/loop1 |
---|
683 | #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 |
---|
684 | #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 |
---|
685 | losetup -d /dev/loop1 |
---|
686 | |
---|
687 | #Montamos el dispositivo virtual en su punto de montaje. |
---|
688 | mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
689 | |
---|
690 | #TODO Comprobar arquitectura |
---|
691 | #Iniciamos la creación del sistema en el directorio de clientes. |
---|
692 | #echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
693 | debootstrap --include=linux-image-${OGRELEASE},linux-headers-${OGRELEASE} --arch=i386 --components=main,universe $OSCODENAME $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
694 | ##preubas |
---|
695 | #debootstrap --include=linux-image-${OGRELEASE} --arch=i386 --variant=minbase $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
696 | #debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
697 | |
---|
698 | if [ $? -ne 0 ]; then |
---|
699 | errorAndLog "ogClientGeneratorDebootstrap(): ha fallado!" |
---|
700 | return 1 |
---|
701 | else |
---|
702 | echoAndLog "ogClientGeneratorDebootstrap(): ok" |
---|
703 | return 0 |
---|
704 | fi |
---|
705 | sleep 5 |
---|
706 | |
---|
707 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTFILE |
---|
708 | |
---|
709 | cat << EOF > /etc/schroot/schroot.conf |
---|
710 | [DIRogclient] |
---|
711 | type=directory |
---|
712 | directory=/var/lib/tftpboot/ogclient/ogclientmount |
---|
713 | description=ogclient ubuntu lucid DIR |
---|
714 | priority=2 |
---|
715 | users=root |
---|
716 | groups=root |
---|
717 | root-groups=root |
---|
718 | root-users=root |
---|
719 | EOF |
---|
720 | } |
---|
721 | |
---|
722 | |
---|
723 | |
---|
724 | |
---|
725 | |
---|