source: client/engine/Boot.lib @ 5c8cf58c

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 5c8cf58c was 5fde4bc, checked in by adv <adv@…>, 14 years ago

branch version 1.0 ticket #438 acceso al registro bcd de windows

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

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