[58828de] | 1 | |
---|
| 2 | ogClientVar() |
---|
| 3 | { |
---|
[88b75ac] | 4 | export SVNCLIENTDIR=/tmp/opengnsys_installer/opengnsys/client/boot-tools |
---|
[58828de] | 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/ |
---|
[88b75ac] | 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 | |
---|
[58828de] | 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 | ogClientConfpxe() |
---|
| 389 | { |
---|
| 390 | ################## DEJAMOS FICHERO DE EJEMPLOS PARA: |
---|
| 391 | #default |
---|
| 392 | cat << FIN >> /var/lib/tftpboot/pxelinux.cfg/defaultNEWClient |
---|
| 393 | LABEL pxe-${OGRELEASE} |
---|
| 394 | KERNEL ogclient/vmlinuz-$OGRELEASE |
---|
| 395 | APPEND initrd=ogclient/initrd.img-$OGRELEASE ip=dhcp ro boot=og vga=788 irqpoll acpi=on reposerver= |
---|
| 396 | LABEL pxe-2.6.32-21-generic-pae |
---|
| 397 | KERNEL ogclient/vmlinuz-2.6.32-21-generic-pae |
---|
| 398 | 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 |
---|
| 399 | LABEL cache |
---|
| 400 | KERNEL grub.exe |
---|
| 401 | 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" |
---|
| 402 | LABEL net |
---|
| 403 | KERNEL grub.exe |
---|
| 404 | 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" |
---|
| 405 | LABEL IfNOTcacheGOnet |
---|
| 406 | KERNEL grub.exe |
---|
| 407 | 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" |
---|
| 408 | #LABEL pxe-2.6.32-21-generic-pae |
---|
| 409 | #KERNEL ogclient/vmlinuz-2.6.32-21-generic-pae |
---|
| 410 | #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 |
---|
| 411 | #LABEL grub |
---|
| 412 | #KERNEL grub.exe |
---|
| 413 | #APPEND keeppxe |
---|
| 414 | FIN |
---|
| 415 | #/etc/hosts |
---|
| 416 | echo "/var/lib/tftpboot *(ro,no_subtree_check,no_root_squash,sync)" > /etc/exportsNEWClient |
---|
| 417 | /etc/init.d/nfs-kernel-server restart |
---|
| 418 | ##################################################################### |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | |
---|
| 423 | ############### No usados en el instalador, solo en actualizaciones. |
---|
| 424 | #/** |
---|
| 425 | # ogClientMount [str_program] |
---|
| 426 | #@brief Acceso al 2nd FS del cliente desde el Servidor Opengnsys |
---|
| 427 | #@param 1 Opciona: scripts o programa a ejecutar para automatizaciones |
---|
| 428 | #@return Si no hay parametros: login de acceso. |
---|
| 429 | #@return con un parametro: La salida del programa ejecutado |
---|
| 430 | #@exception |
---|
| 431 | #@note |
---|
| 432 | #@todo |
---|
| 433 | #@version 0.9 - Primera versión para OpenGnSys |
---|
| 434 | #@author Antonio J. Doblas Viso, Universidad de Málaga |
---|
| 435 | #@date 2010/02/15 |
---|
| 436 | #*/ ## |
---|
| 437 | function ogClientMount () |
---|
| 438 | { |
---|
| 439 | #TODO comprobar que OGFILE y OGFILEMOUNT existe. |
---|
| 440 | mount | grep $OGCLIENTFILE > /dev/null || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
| 441 | mount | grep $OGCLIENTMOUNT/proc > /dev/null || mount --bind /proc $OGCLIENTMOUNT/proc |
---|
| 442 | mount | grep $OGCLIENTMOUNT/sys > /dev/null || mount --bind /sys $OGCLIENTMOUNT/sys |
---|
| 443 | mount | grep $OGCLIENTMOUNT/tmp > /dev/null || mount --bind /tmp $OGCLIENTMOUNT/tmp |
---|
| 444 | mount | grep $OGCLIENTMOUNT/dev > /dev/null || mount --bind /dev $OGCLIENTMOUNT/dev |
---|
| 445 | mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null || mount --bind /dev/pts $OGCLIENTMOUNT/dev/pts |
---|
| 446 | |
---|
| 447 | |
---|
| 448 | [ $# = 0 ] && $(chroot $OGCLIENTMOUNT /sbin/getty 38400 `tty`) |
---|
| 449 | [ $# = 1 ] && chroot $OGCLIENTMOUNT $1 |
---|
| 450 | |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | #/** |
---|
| 454 | # ogClientUnmount |
---|
| 455 | #@brief Desmonta el 2nd FS del cliente desde el Servidor Opengnsys |
---|
| 456 | #@param |
---|
| 457 | #@return |
---|
| 458 | #@exception |
---|
| 459 | #@note |
---|
| 460 | #@todo |
---|
| 461 | #@version 0.9 - Primera versión para OpenGnSys |
---|
| 462 | #@author Antonio J. Doblas Viso, Universidad de Málaga |
---|
| 463 | #@date 2010/02/15 |
---|
| 464 | #*/ ## |
---|
| 465 | |
---|
| 466 | function ogClientUnmount () |
---|
| 467 | { |
---|
| 468 | cd /tmp |
---|
| 469 | echo "desmontando cliente espere" |
---|
| 470 | sleep 5 |
---|
| 471 | mount | grep $OGCLIENTMOUNT/dev > /dev/null && umount $OGCLIENTMOUNT/dev || ogClientUnmount |
---|
| 472 | mount | grep $OGCLIENTMOUNT/dev/pts > /dev/null && umount $OGCLIENTMOUNT/dev/pts || ogClientUnmount |
---|
| 473 | mount | grep $OGCLIENTMOUNT/proc > /dev/null && umount $OGCLIENTMOUNT/proc || ogClientUnmount |
---|
| 474 | mount | grep $OGCLIENTMOUNT/sys > /dev/null && umount $OGCLIENTMOUNT/sys || ogClientUnmount |
---|
| 475 | mount | grep $OGCLIENTMOUNT/tmp > /dev/null && umount $OGCLIENTMOUNT/tmp || ogClientUnmount |
---|
| 476 | mount | grep $OGCLIENTMOUNT > /dev/null && umount $OGCLIENTMOUNT || ogClientUnmount |
---|
| 477 | #-d -f -l |
---|
| 478 | |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | |
---|
| 482 | ############################ hasta el final del archivo antiguos |
---|
| 483 | ############################# ANTIGUOS |
---|
| 484 | function ogClientGetRelease () |
---|
| 485 | { |
---|
| 486 | #1 OSCODENAME jaunty|karmic|lucid |
---|
| 487 | case $1 in |
---|
| 488 | jaunty|JAUNTY) |
---|
| 489 | OSCODENAME=jaunty |
---|
| 490 | OGRELEASE="2.6.28-11-generic" |
---|
| 491 | echo $OGRELEASE |
---|
| 492 | ;; |
---|
| 493 | lenny|LENNY) |
---|
| 494 | OSCODENAME=lenny |
---|
| 495 | OGRELEASE="2.6.28-11-generic" |
---|
| 496 | echo $OGRELEASE |
---|
| 497 | ;; |
---|
| 498 | squeeze|SQUEEZE) |
---|
| 499 | OSCODENAME=squeeze |
---|
| 500 | OGRELEASE="2.6.28-11-generic" |
---|
| 501 | echo $OGRELEASE |
---|
| 502 | ;; |
---|
| 503 | karmic|KARMIC) |
---|
| 504 | OSCODENAME=karmic |
---|
| 505 | OGRELEASE="2.6.31-14-generic" |
---|
| 506 | echo $OGRELEASE |
---|
| 507 | ;; |
---|
| 508 | lucid|LUCID) |
---|
| 509 | OSCODENAME=lucid |
---|
| 510 | OGRELEASE="2.6.32-21-generic-pae" |
---|
| 511 | echo $OGRELEASE |
---|
| 512 | ;; |
---|
| 513 | *) |
---|
| 514 | return 1 |
---|
| 515 | ;; |
---|
| 516 | esac |
---|
| 517 | |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | |
---|
| 521 | #/** |
---|
| 522 | # ogClientGenerator str_versionUbuntu str_release |
---|
| 523 | #@brief Crea el 2nd FS del cliente desde el Servidor Opengnsys |
---|
| 524 | #@param 1 Versión de ubuntu a generar, jaunty karmic |
---|
| 525 | #@return |
---|
| 526 | #@exception |
---|
| 527 | #@note |
---|
| 528 | #@todo |
---|
| 529 | #@version 0.9 - Primera versión para OpenGnSys |
---|
| 530 | #@author Antonio J. Doblas Viso, Universidad de Málaga |
---|
| 531 | #@date 2010/02/15 |
---|
| 532 | #*/ ## |
---|
| 533 | |
---|
| 534 | function ogClientGeneratorDebootstrap () |
---|
| 535 | { |
---|
| 536 | if [ $# != 2 ] |
---|
| 537 | then |
---|
| 538 | echo Debes introducir como argumento1: jaunty karmic lucid |
---|
| 539 | echo Debes introducir como argumento2: la release |
---|
| 540 | echo utiliza como entrada ogClientCheckVersion |
---|
| 541 | return |
---|
| 542 | fi |
---|
| 543 | OSCODENAME=$1 |
---|
| 544 | OGRELEASE=$2 |
---|
| 545 | |
---|
| 546 | # instalamos el ultimo debotstrap para permitir instalar versiones superiores a nuestro sistema |
---|
| 547 | #apt-get install gdebi-core |
---|
| 548 | #wget $LASTDEBOOTSTRAP |
---|
| 549 | #gdebi -n debootstrap_1.0.20_all.deb |
---|
| 550 | |
---|
| 551 | #Desmontamos por si acaso el dispositivo virtual |
---|
| 552 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTMOUNT |
---|
| 553 | |
---|
| 554 | #Creamos el directorio donde montaremos el disco virtual |
---|
| 555 | mkdir -p $OGCLIENTMOUNT |
---|
| 556 | |
---|
| 557 | #Creamos el disco virtual con el filesystem del cliente. |
---|
| 558 | dd if=/dev/zero of=$OGCLIENTFILE bs=1048576 count=$OGCLIENTSIZEMB |
---|
| 559 | #qemu-img create $OGCLIENTFILE 3G |
---|
| 560 | #dd if=/dev/zero of=$OGCLIENTFILE bs=1k count=$OGCLIENTSIZEKB # necesita 500MB |
---|
| 561 | |
---|
| 562 | |
---|
| 563 | #particionamos el disco virtual |
---|
| 564 | losetup /dev/loop0 $OGCLIENTFILE |
---|
| 565 | echo -e "n\np\n1\n\n\nt\n83\nw" | fdisk /dev/loop0 |
---|
| 566 | losetup -d /dev/loop0 |
---|
| 567 | |
---|
| 568 | |
---|
| 569 | #formateamos la particion principal. |
---|
| 570 | losetup -o 32256 /dev/loop1 $OGCLIENTFILE |
---|
| 571 | mkfs.ext3 -b 4096 -L $OGCLIENTLABEL /dev/loop1 |
---|
| 572 | #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 |
---|
| 573 | #mkfs.ext3 -L $OGCLIENTLABEL /dev/loop1 |
---|
| 574 | losetup -d /dev/loop1 |
---|
| 575 | |
---|
| 576 | #Montamos el dispositivo virtual en su punto de montaje. |
---|
| 577 | mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256 |
---|
| 578 | |
---|
| 579 | #TODO Comprobar arquitectura |
---|
| 580 | #Iniciamos la creación del sistema en el directorio de clientes. |
---|
| 581 | #echo debootstrap --include=linux-image-${OGRELEASE},dbus --arch=i386 --components=main,universe $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
| 582 | debootstrap --include=linux-image-${OGRELEASE},linux-headers-${OGRELEASE} --arch=i386 --components=main,universe $OSCODENAME $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
| 583 | ##preubas |
---|
| 584 | #debootstrap --include=linux-image-${OGRELEASE} --arch=i386 --variant=minbase $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
| 585 | #debootstrap --variant=minbase --include=linux-image-${OGRELEASE} --arch=i386 $OGVERSION $OGCLIENTMOUNT http://es.archive.ubuntu.com/ubuntu/ |
---|
| 586 | |
---|
| 587 | if [ $? -ne 0 ]; then |
---|
| 588 | errorAndLog "ogClientGeneratorDebootstrap(): ha fallado!" |
---|
| 589 | return 1 |
---|
| 590 | else |
---|
| 591 | echoAndLog "ogClientGeneratorDebootstrap(): ok" |
---|
| 592 | return 0 |
---|
| 593 | fi |
---|
| 594 | sleep 5 |
---|
| 595 | |
---|
| 596 | mount | grep $OGCLIENTMOUNT && umount $OGCLIENTFILE |
---|
| 597 | |
---|
| 598 | cat << EOF > /etc/schroot/schroot.conf |
---|
| 599 | [DIRogclient] |
---|
| 600 | type=directory |
---|
| 601 | directory=/var/lib/tftpboot/ogclient/ogclientmount |
---|
| 602 | description=ogclient ubuntu lucid DIR |
---|
| 603 | priority=2 |
---|
| 604 | users=root |
---|
| 605 | groups=root |
---|
| 606 | root-groups=root |
---|
| 607 | root-users=root |
---|
| 608 | EOF |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | |
---|
| 612 | |
---|
| 613 | |
---|
| 614 | |
---|