source: client/engine/Boot.lib @ 99d1786

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 99d1786 was 75a296b, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0.2: configuración DHCP para Grub4Dos, suscitución función ogBoot para Grub4Dos, comandos para listar y cambiar plantilla de arranque y cambios en el actualizador (modifica #444)

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2331 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 18.7 KB
RevLine 
[b094c59]1#!/bin/bash
2#/**
3#@file    Boot.lib
4#@brief   Librería o clase Boot
5#@class   Boot
6#@brief   Funciones para arranque y post-configuración de sistemas de archivos.
7#@version 0.9
8#@warning License: GNU GPLv3+
9#*/
10
11
12#/**
13#         ogBoot int_ndisk int_npartition
14#@brief   Inicia el proceso de arranque de un sistema de archivos.
[42669ebf]15#@param   int_ndisk      nº de orden del disco
16#@param   int_npartition nº de orden de la partición
[b094c59]17#@return  (activar el sistema de archivos).
18#@exception OG_ERR_FORMAT    Formato incorrecto.
19#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
20#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
21#@exception OG_ERR_NOTOS     La partición no tiene instalado un sistema operativo.
[f5432db7]22#@note    En Linux, debe arrancarse la partición del directorio \c /boot
[985bef0]23#@version 0.1 - Integracion para OpenGNSys. - EAC: HDboot(); BootLinuxEX() en Boot.lib 
24#@author  Antonio J. Doblas Viso, Universidad de Malaga
[e05993a]25#@date    2008-10-27
[985bef0]26#@version 0.9 - Adaptacion para OpenGNSys.
[b094c59]27#@author  Ramon Gomez, ETSII Universidad de Sevilla
28#@date    2009-09-11
[1e7eaab]29#*/ ##
[42669ebf]30function ogBoot ()
31{
[b094c59]32# Variables locales.
[326cec3]33local PART TYPE MNTDIR PARAMS KERNEL INITRD APPEND FILE LOADER
[b094c59]34
[1e7eaab]35# Si se solicita, mostrar ayuda.
[b094c59]36if [ "$*" == "help" ]; then
37    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
38           "$FUNCNAME 1 1"
39    return
40fi
[1e7eaab]41# Error si no se reciben 2 parámetros.
[b094c59]42[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
43
[1e7eaab]44# Detectar tipo de sistema de archivos y montarlo.
[049eadbe]45PART=$(ogDiskToDev $1 $2) || return $?
[b094c59]46TYPE=$(ogGetFsType $1 $2) || return $?
[f5432db7]47MNTDIR=$(ogMount $1 $2) 2>/dev/null
48[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[b094c59]49
50case "$TYPE" in
[049eadbe]51    EXT[234]|REISERFS|REISER4|JFS|XFS)
[1e7eaab]52        # Obtiene los parámetros de arranque para Linux.
[f5432db7]53        PARAMS=$(ogLinuxBootParameters $1 $2) || return $?
54        read -e KERNEL INITRD APPEND <<<"$PARAMS"
[1e7eaab]55        # Si no hay kernel, no hay sistema operativo.
[f5432db7]56        [ -z "$KERNEL" ] && ogRaiseError $OG_ERR_NOTOS && return $?
[1e7eaab]57        # Arrancar de partición distinta a la original.
[049eadbe]58        [ -e "$MNTDIR/etc" ] && APPEND=$(echo $APPEND | awk -v P="$PART " '{sub (/root=[-+=_/a-zA-Z0-9]* /,"root="P);print}')
[f5432db7]59        # Configurar kernel Linux con los parámetros leídos de su GRUB.
[049eadbe]60        kexec -l "${MNTDIR}${KERNEL}" --append="$APPEND" --initrd="${MNTDIR}${INITRD}"
[f5432db7]61        ;;
62    NTFS|HNTFS|FAT32|HFAT32)
[1e7eaab]63        # Compruebar si hay un cargador de Windows.
[f5432db7]64        for f in io.sys ntldr bootmgr; do
65            FILE="$(ogGetPath $1 $2 $f 2>/dev/null)"
[d10549b]66            [ -n "$FILE" ] && LOADER="$f"
[f5432db7]67        done
68        [ -z "$LOADER" ] && ogRaiseError $OG_ERR_NOTOS && return $?
69        # Activar la partición y copiar Grub4DOS.
70        ogSetPartitionActive $1 $2
[6439d55]71        #FIXME: activar seguimiento inicio sesion Windows con grub4dos
[75a296b]72        if [ "$(ogGetOsType $1 $2)" == "Windows" ]; then
73            dd if=/dev/zero of=${MNTDIR}/ogboot.me bs=1024 count=3
74            dd if=/dev/zero of=${MNTDIR}/ogboot.firstboot bs=1024 count=3
75            dd if=/dev/zero of=${MNTDIR}/ogboot.secondboot bs=1024 count=3
76            ogLoadHiveWindows $1 $2
77            ogHiveNTRunMachine "cmd /c del c:\ogboot.*" ogcleanboot
78            ogUpdateHiveWindows
79            reboot
80        else       
81            cp $OGLIB/grub4dos/* $MNTDIR    # */ (Comentario Doxygen)
82            kexec -l $MNTDIR/grub.exe --append=--config-file="root (hd$[$1-1],$[$2-1]); chainloader (hd$[$1-1],$[$2-1])/$LOADER; tpm --init"
83        fi
[f5432db7]84        ;;
85    *)  ogRaiseError $OG_ERR_PARTITION "$1, $2"
[326cec3]86        return $?
[f5432db7]87        ;;
[b094c59]88esac
89
[1e7eaab]90# Arrancar.
[b094c59]91kexec -e
92}
93
94
95#/**
[3e1561d]96#         ogGetWindowsName int_ndisk int_npartition
97#@brief   Muestra el nombre del equipo en el registro de Windows.
[42669ebf]98#@param   int_ndisk      nº de orden del disco
99#@param   int_npartition nº de orden de la partición
[3e1561d]100#@return  str_name - nombre del equipo
101#@exception OG_ERR_FORMAT    Formato incorrecto.
102#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
103#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[f5432db7]104#@version 0.9 - Adaptación para OpenGNSys.
[3e1561d]105#@author  Ramon Gomez, ETSII Universidad de Sevilla
106#@date    2009-09-23
[1e7eaab]107#*/ ##
[42669ebf]108function ogGetWindowsName ()
109{
[3e1561d]110# Variables locales.
111local PART MNTDIR
112
[1e7eaab]113# Si se solicita, mostrar ayuda.
[3e1561d]114if [ "$*" == "help" ]; then
115    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
116           "$FUNCNAME 1 1  ==>  PRACTICA-PC"
117    return
118fi
[1e7eaab]119# Error si no se reciben 2 parámetros.
[3e1561d]120[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
121
[1e7eaab]122# Montar el sistema de archivos.
[f5432db7]123MNTDIR=$(ogMount $1 $2) 2>/dev/null
124[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[3e1561d]125
[1e7eaab]126# Obtener dato del valor de registro.
[3e1561d]127ogGetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName'
128}
129
130
131#/**
[4c63eb9]132#         ogLinuxBootParameters int_ndisk int_npartition
[b094c59]133#@brief   Muestra los parámetros de arranque de un sistema de archivos Linux.
[42669ebf]134#@param   int_ndisk      nº de orden del disco
135#@param   int_npartition nº de orden de la partición
136#@return  str_kernel str_initrd str_parameters ...
[b094c59]137#@exception OG_ERR_FORMAT    Formato incorrecto.
138#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
139#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[055adcf]140#@warning Función básica usada por \c ogBoot
141#@version 0.9 - Primera adaptación para OpenGNSys.
[b094c59]142#@author  Ramon Gomez, ETSII Universidad de Sevilla
143#@date    2009-09-11
[199bdf3]144#@version 0.9.2 - Soporta partición /boot independiente.
145#@author  Ramon Gomez, ETSII Universidad de Sevilla
146#@date    2010-07-20
[1e7eaab]147#*/ ##
[42669ebf]148function ogLinuxBootParameters ()
149{
[b094c59]150# Variables locales.
[199bdf3]151local MNTDIR CONFDIR CONFFILE
[b094c59]152
[1e7eaab]153# Si se solicita, mostrar ayuda.
[b094c59]154if [ "$*" == "help" ]; then
155    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
156           "$FUNCNAME 1 2  ==>  ..."
157    return
158fi
[1e7eaab]159# Error si no se reciben 2 parámetros.
[b094c59]160[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
161
[1e7eaab]162# Detectar id. de tipo de partición y codificar al mnemonico.
[f5432db7]163MNTDIR=$(ogMount $1 $2) 2>/dev/null
164[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[b094c59]165
166# Fichero de configuración de GRUB.
[199bdf3]167CONFDIR=$MNTDIR                               # Partición de arranque /boot.
168[ -d $MNTDIR/boot ] && CONFDIR=$MNTDIR/boot   # Partición raíz con directorio boot.
169CONFFILE="$CONFDIR/grub/menu.lst"
170[ ! -e $CONFFILE ] && CONFFILE="$CONFDIR/grub/grub.cfg"
171[ ! -e $CONFFILE ] && ogRaiseError $OG_ERR_NOTFOUND "grub.cfg" && return $?
[b094c59]172
[1e7eaab]173# Toma del fichero de configuracion los valores del kernel, initrd
[ee4a96e]174#       y parámetros de arranque usando las cláusulas por defecto
175#       ("default" en GRUB1, "set default" en GRUB2)
176#       y los formatea para que sean compatibles con \c kexec .  */
[1e7eaab]177# /* (comentario Doxygen)
[b094c59]178awk 'BEGIN {cont=-1;}
179     $1~/^default/      {sub(/=/," "); def=$2;}
[18f4bc2]180     $1~/^set/ && $2~/^default/ {gsub(/[="]/," "); def=$3;}
[ee4a96e]181     $1~/^title|^menuentry/ {cont++}
182     $1~/^kernel|^linux/ {if (def==cont) {
[b094c59]183                            kern=$2;
[1e7eaab]184                            sub($1,"");sub($1,"");sub(/^[ \t]*/,"");app=$0}  # /* (comentario Doxygen)
[b094c59]185                        }
186     $1~/^initrd/       {if (def==cont) init=$2}
187     END {if (kern!="") printf("%s %s %s", kern,init,app)}
[199bdf3]188    ' $CONFFILE
[1e7eaab]189# */ (comentario Doxygen)
[b094c59]190}
191
[3e1561d]192
193#/**
194#         ogSetWindowsName int_ndisk int_npartition str_name
195#@brief   Establece el nombre del equipo en el registro de Windows.
[42669ebf]196#@param   int_ndisk      nº de orden del disco
197#@param   int_npartition nº de orden de la partición
198#@param   str_name       nombre asignado
[3e1561d]199#@return  (nada)
200#@exception OG_ERR_FORMAT    Formato incorrecto.
201#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
202#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[f5432db7]203#@version 0.9 - Adaptación a OpenGNSys.
[3e1561d]204#@author  Ramon Gomez, ETSII Universidad de Sevilla
205#@date    2009-09-24
[1e7eaab]206#*/ ##
[42669ebf]207function ogSetWindowsName ()
208{
[3e1561d]209# Variables locales.
210local PART MNTDIR NAME
211
[1e7eaab]212# Si se solicita, mostrar ayuda.
[3e1561d]213if [ "$*" == "help" ]; then
[4b9cdda]214    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_name" \
[3e1561d]215           "$FUNCNAME 1 1 PRACTICA-PC"
216    return
217fi
[1e7eaab]218# Error si no se reciben 3 parámetros.
[3e1561d]219[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
220
[42669ebf]221# Montar el sistema de archivos.
[f5432db7]222MNTDIR=$(ogMount $1 $2) 2>/dev/null
223[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[3e1561d]224NAME="$3"
225
[1e7eaab]226# Modificar datos de los valores de registro.
[4b9cdda]227ogSetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName' "$NAME" 2>/dev/null
228ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\Hostname' "$NAME" 2>/dev/null
229ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\Hostname' "$NAME" 2>/dev/null
230ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\NV Hostname' "$NAME" 2>/dev/null
231ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\NV Hostname' "$NAME" 2>/dev/null
[3e1561d]232}
233
[f5432db7]234
[4b9cdda]235#/**
236#         ogSetWinlogonUser int_ndisk int_npartition str_username
237#@brief   Establece el nombre de usuario por defecto en la entrada de Windows.
238#@param   int_ndisk      nº de orden del disco
239#@param   int_npartition nº de orden de la partición
240#@param   str_username   nombre de usuario por defecto
241#@return  (nada)
242#@exception OG_ERR_FORMAT    Formato incorrecto.
243#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
244#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
245#@version 0.9.2 - Adaptación a OpenGNSys.
246#@author  Ramon Gomez, ETSII Universidad de Sevilla
247#@date    2010-07-20
248#*/ ##
249function ogSetWinlogonUser ()
250{
251# Variables locales.
252local PART MNTDIR NAME
253
254# Si se solicita, mostrar ayuda.
255if [ "$*" == "help" ]; then
256    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_username" \
257           "$FUNCNAME 1 1 USUARIO"
258    return
259fi
260# Error si no se reciben 3 parámetros.
261[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
262
263# Montar el sistema de archivos.
264MNTDIR=$(ogMount $1 $2) 2>/dev/null
265[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
266NAME="$3"
267
268# Modificar datos en el registro.
269ogSetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName' "$3"
270}
271
[38231e9]272
273#/**
[9e8773c]274#         ogBootMbrXP int_ndisk
[38231e9]275#@brief   Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows
[42669ebf]276#@param   int_ndisk      nº de orden del disco
[945b003]277#@return  salida del programa my-sys
[38231e9]278#@exception OG_ERR_FORMAT    Formato incorrecto.
279#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
280#@version 0.9 - Adaptación a OpenGNSys.
281#@author  Antonio J. Doblas Viso. Universidad de Málaga
282#@date    2009-09-24
283#*/ ##
284
[9e8773c]285function ogBootMbrXP ()
[e05993a]286{
[38231e9]287# Variables locales.
288local PART
289
290# Si se solicita, mostrar ayuda.
291if [ "$*" == "help" ]; then
292    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \
293           "$FUNCNAME 1 "
294    return
[945b003]295fi
[38231e9]296# Error si no se reciben 1 parámetros.
297[ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $?
298
[6e139c9]299PART="$(ogDiskToDev $1)" || return $?
[38231e9]300ms-sys -z -f $PART
301ms-sys -m -f $PART
[945b003]302}
[42669ebf]303
[fdad5a6]304
[9e8773c]305#/**
306#         ogBootMbrGeneric int_ndisk
307#@brief   Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
308#@param   int_ndisk      nº de orden del disco
309#@return  salida del programa my-sys
310#@exception OG_ERR_FORMAT    Formato incorrecto.
311#@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar.
312#@version 0.9 - Adaptación a OpenGNSys.
313#@author  Antonio J. Doblas Viso. Universidad de Málaga
314#@date    2009-09-24
315#*/ ##
316
317function ogBootMbrGeneric ()
318{
319# Variables locales.
320local PART
321
322# Si se solicita, mostrar ayuda.
323if [ "$*" == "help" ]; then
324    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \
325           "$FUNCNAME 1 "
326    return
327fi
328# Error si no se reciben 1 parámetros.
329[ $# == 1 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
330
331PART="$(ogDiskToDev $1)" || return $(ogRaiseError $OG_ERR_NOTFOUND; echo $?)
332ms-sys -z -f $PART
333ms-sys -s -f $PART
334}
335
336
337
[fdad5a6]338
339#/**
340#         ogFixBootSector int_ndisk int_parition
341#@brief   Corrige el boot sector de una particion activa para MS windows/dos -fat-ntfs
342#@param   int_ndisk      nº de orden del disco
343#@param   int_partition     nº de particion
344#@return 
345#@exception OG_ERR_FORMAT    Formato incorrecto.
346#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
347#@version 0.9 - Adaptación a OpenGNSys.
348#@author  Antonio J. Doblas Viso. Universidad de Málaga
349#@date    2009-09-24
350#*/ ##
351
352function ogFixBootSector ()
353{
354# Variables locales.
355local PART DISK FILE
356
357# Si se solicita, mostrar ayuda.
358if [ "$*" == "help" ]; then
359    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \
360           "$FUNCNAME 1 1 "
361    return
362fi
363
364# Error si no se reciben 2 parámetros.
365[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
366
367#TODO, solo si la particion existe
368#TODO, solo si es ntfs o fat
369PARTYPE=$(ogGetPartitionId $1 $2)
370case $PARTYPE in
371        1|4|6|7|b|c|e|f)
372        ;;
373        *)
374        return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
375        ;;
376esac
377
378ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
379
380#Preparando instruccion
381let DISK=$1-1   
382PART=$2
383FILE=/tmp/temporal
384cat > $FILE <<EOF
385disk=$DISK
386main_part=$PART
387fix_first_sector=yes
388EOF
389
[5fde4bc]390spartlnx.run -cui -nm -a -f $FILE &
391sleep 5
392ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
393
[fdad5a6]394
395}
396
397
398
399#/**
400#         ogWindowsBootParameters int_ndisk int_parition
[78b5dfe7]401#@brief   Configura el gestor de arranque de windows 7 / vista / XP / 2000
[fdad5a6]402#@param   int_ndisk      nº de orden del disco
403#@param   int_partition     nº de particion
404#@return 
405#@exception OG_ERR_FORMAT    Formato incorrecto.
406#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[78b5dfe7]407#@version 0.9 - Integración desde EAC para OpenGNSys.
[fdad5a6]408#@author  Antonio J. Doblas Viso. Universidad de Málaga
409#@date    2009-09-24
[78b5dfe7]410#@version 1.0.1 - Adapatacion para OpenGnsys.
411#@author  Antonio J. Doblas Viso. Universidad de Málaga
412#@date    2011-05-20
[fdad5a6]413#*/ ##
414
415
416function ogWindowsBootParameters ()
417{
418# Variables locales.
419local PART DISK FILE
[78b5dfe7]420#Preparando variables adaptadas a sintaxis windows.
421let DISK=$1-1
422PART=$2
423FILE=/tmp/temporal
[fdad5a6]424
425# Si se solicita, mostrar ayuda.
426if [ "$*" == "help" ]; then
427    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \
428           "$FUNCNAME 1 1 "
429    return
430fi
431
432# Error si no se reciben 2 parámetros.
433[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
434
435ogDiskToDev $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
436
437VERSION=$(ogGetOsVersion $1 $2)
438
[78b5dfe7]439if echo "$VERSION" | grep "Windows 7"
[fdad5a6]440then
441        WINVER="Windows 7"
[78b5dfe7]442elif echo "$VERSION" | grep "Windows Seven"
[fdad5a6]443then
444        WINVER="Windows Vista"
[78b5dfe7]445elif echo "$VERSION" | grep "XP"
446then
447        MOUNT=$(ogMount $1 $2)
448        [ -f ${MOUNT}/boot.ini ] || return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
449        cat ${MOUNT}/boot.ini | sed s/partition\([0-9]\)/partition\($PART\)/g | sed s/rdisk\([0-9]\)/rdisk\($DISK\)/g > ${MOUNT}/tmp.boot.ini; mv ${MOUNT}/tmp.boot.ini ${MOUNT}/boot.ini
450        return 0
[fdad5a6]451else
452        return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
453fi
454
455ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
[78b5dfe7]456
[fdad5a6]457
458#Preparando instruccion Windows Resume Application
459cat > $FILE <<EOF
460boot_disk=$DISK
461boot_main_part=$PART
462disk=$DISK
463main_part=$PART
464boot_entry=Windows Resume Application
465EOF
[5fde4bc]466spartlnx.run -cui -nm -w -f $FILE &
467sleep 5
468ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
469
470 
[fdad5a6]471
472#Preparando instruccion tipo windows
473cat > $FILE <<EOF
474boot_disk=$DISK
475boot_main_part=$PART
476disk=$DISK
477main_part=$PART
478boot_entry=$WINVER
479EOF
[5fde4bc]480spartlnx.run -cui -nm -w -f $FILE &
481sleep 5
482ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
483
[fdad5a6]484
[250742d]485##Preparando instruccion        Ramdisk Options
[5fde4bc]486cat > $FILE <<EOF
487boot_disk=$DISK
488boot_main_part=$PART
489disk=$DISK
490main_part=$PART
491boot_entry=Ramdisk Options
492EOF
493spartlnx.run -cui -nm -w -f $FILE &
494sleep 5
495ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
496
[fdad5a6]497
498#Preparando instruccion Windows Boot Manager
499cat > $FILE <<EOF
500boot_disk=$DISK
501boot_main_part=$PART
502disk=$DISK
503main_part=$PART
504boot_entry=Windows Boot Manager
505EOF
[5fde4bc]506spartlnx.run -cui -nm -w -f $FILE &
507sleep 5
508ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
509
[fdad5a6]510
511#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
[5fde4bc]512cat > $FILE <<EOF
513boot_disk=$DISK
514boot_main_part=$PART
515disk=$DISK
516main_part=$PART
517boot_entry=Herramienta de diagnóstico de memoria de Windows
518EOF
519spartlnx.run -cui -nm -w -f $FILE &
520sleep 5
521ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
[fdad5a6]522
523}
524       
525
[78b5dfe7]526#         ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition
[fdad5a6]527#@brief   Registra una partición en windows con un determinado volumen.
528#@param   int_ndisk      nº de orden del disco a registrar
529#@param   int_partition     nº de particion a registrar
530#@param   str_volumen      volumen a resgistar
531#@param   int_ndisk_windows      nº de orden del disco donde esta windows
532#@param   int_partition_windows     nº de particion donde esta windows
533#@return 
534#@exception OG_ERR_FORMAT    Formato incorrecto.
535#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
536#@version 0.9 - Adaptación a OpenGNSys.
537#@author  Antonio J. Doblas Viso. Universidad de Málaga
538#@date    2009-09-24
539#*/ ##
540
541
[78b5dfe7]542function ogWindowsRegisterPartition ()
[fdad5a6]543{       
544# Variables locales.
545local PART DISK FILE
546
547# Si se solicita, mostrar ayuda.
548if [ "$*" == "help" ]; then
549    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk_TO_registre int_partition_TO_registre str_NewVolume int_disk int_parition " \
550           "$FUNCNAME 1 1 c: 1 1"
551    return
552fi
553
554# Error si no se reciben 5 parámetros.
555[ $# == 5 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
556
557REGISTREDDISK=$1
558REGISTREDPART=$2
559REGISTREDVOL=$(echo $3 | cut -c1 | tr '[:lower:]' '[:upper:]')
560DISK=$4
561PART=$5
562FILE=/tmp/temporal
563
564ogDiskToDev $REGISTREDDISK $REGISTREDPART || return $(ogRaiseError $OG_ERR_PARTITION "particion a registrar "; echo $?)
565ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows"; echo $?)
566
567ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?)
568
569VERSION=$(ogGetOsVersion $DISK $PART)
570
571#Systemroot
572
573if ogGetPath $DISK $PART WINDOWS
574then
575        SYSTEMROOT="Windows"
576elif ogGetPath $DISK $PART WINNT
577then
578        SYSTEMROOT="winnt"
579else
580        return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
581fi
582
583ogUnmount $DISK $PART
584let DISK=$DISK-1
585let REGISTREDDISK=$REGISTREDDISK-1
586#Preparando instruccion Windows Boot Manager
587cat > $FILE <<EOF
588windows_disk=$DISK
589windows_main_part=$PART
590windows_dir=$SYSTEMROOT
591disk=$REGISTREDDISK
592main_part=$REGISTREDPART
593;ext_part
594part_letter=$REGISTREDVOL
595EOF
[5fde4bc]596spartlnx.run -cui -nm -u -f $FILE &
597sleep 5
598ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
599
[e0c0d93]600}
Note: See TracBrowser for help on using the repository browser.