source: client/engine/Boot.lib @ 1616b6e

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 1616b6e 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
Line 
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.
15#@param   int_ndisk      nº de orden del disco
16#@param   int_npartition nº de orden de la partición
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.
22#@note    En Linux, debe arrancarse la partición del directorio \c /boot
23#@version 0.1 - Integracion para OpenGNSys. - EAC: HDboot(); BootLinuxEX() en Boot.lib 
24#@author  Antonio J. Doblas Viso, Universidad de Malaga
25#@date    2008-10-27
26#@version 0.9 - Adaptacion para OpenGNSys.
27#@author  Ramon Gomez, ETSII Universidad de Sevilla
28#@date    2009-09-11
29#*/ ##
30function ogBoot ()
31{
32# Variables locales.
33local PART TYPE MNTDIR PARAMS KERNEL INITRD APPEND FILE LOADER
34
35# Si se solicita, mostrar ayuda.
36if [ "$*" == "help" ]; then
37    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
38           "$FUNCNAME 1 1"
39    return
40fi
41# Error si no se reciben 2 parámetros.
42[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
43
44# Detectar tipo de sistema de archivos y montarlo.
45PART=$(ogDiskToDev $1 $2) || return $?
46TYPE=$(ogGetFsType $1 $2) || return $?
47MNTDIR=$(ogMount $1 $2) 2>/dev/null
48[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
49
50case "$TYPE" in
51    EXT[234]|REISERFS|REISER4|JFS|XFS)
52        # Obtiene los parámetros de arranque para Linux.
53        PARAMS=$(ogLinuxBootParameters $1 $2) || return $?
54        read -e KERNEL INITRD APPEND <<<"$PARAMS"
55        # Si no hay kernel, no hay sistema operativo.
56        [ -z "$KERNEL" ] && ogRaiseError $OG_ERR_NOTOS && return $?
57        # Arrancar de partición distinta a la original.
58        [ -e "$MNTDIR/etc" ] && APPEND=$(echo $APPEND | awk -v P="$PART " '{sub (/root=[-+=_/a-zA-Z0-9]* /,"root="P);print}')
59        # Configurar kernel Linux con los parámetros leídos de su GRUB.
60        kexec -l "${MNTDIR}${KERNEL}" --append="$APPEND" --initrd="${MNTDIR}${INITRD}"
61        ;;
62    NTFS|HNTFS|FAT32|HFAT32)
63        # Compruebar si hay un cargador de Windows.
64        for f in io.sys ntldr bootmgr; do
65            FILE="$(ogGetPath $1 $2 $f 2>/dev/null)"
66            [ -n "$FILE" ] && LOADER="$f"
67        done
68        [ -z "$LOADER" ] && ogRaiseError $OG_ERR_NOTOS && return $?
69        # Activar la partición y copiar Grub4DOS.
70        ogSetPartitionActive $1 $2
71        #FIXME: activar seguimiento inicio sesion Windows con grub4dos
72        #if `ogGetOsVersion $1 $2 | grep "Windows" > /dev/null`
73        #then
74        #   for i in `ls /mnt/`; do rm /mnt/$i/ogboot.* &>/dev/null; done
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
79        #       ogHiveNTRunMachine "cmd /c del c:\ogboot.* "  ogcleanboot
80        #       ogUpdateHiveWindows
81        #       reboot
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"
86        #fi
87        ;;
88    *)  ogRaiseError $OG_ERR_PARTITION "$1, $2"
89        return $?
90        ;;
91esac
92
93# Arrancar.
94kexec -e
95}
96
97
98#/**
99#         ogGetWindowsName int_ndisk int_npartition
100#@brief   Muestra el nombre del equipo en el registro de Windows.
101#@param   int_ndisk      nº de orden del disco
102#@param   int_npartition nº de orden de la partición
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.
107#@version 0.9 - Adaptación para OpenGNSys.
108#@author  Ramon Gomez, ETSII Universidad de Sevilla
109#@date    2009-09-23
110#*/ ##
111function ogGetWindowsName ()
112{
113# Variables locales.
114local PART MNTDIR
115
116# Si se solicita, mostrar ayuda.
117if [ "$*" == "help" ]; then
118    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
119           "$FUNCNAME 1 1  ==>  PRACTICA-PC"
120    return
121fi
122# Error si no se reciben 2 parámetros.
123[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
124
125# Montar el sistema de archivos.
126MNTDIR=$(ogMount $1 $2) 2>/dev/null
127[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
128
129# Obtener dato del valor de registro.
130ogGetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName'
131}
132
133
134#/**
135#         ogLinuxBootParameters int_ndisk int_npartition
136#@brief   Muestra los parámetros de arranque de un sistema de archivos Linux.
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 ...
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.
143#@warning Función básica usada por \c ogBoot
144#@version 0.9 - Primera adaptación para OpenGNSys.
145#@author  Ramon Gomez, ETSII Universidad de Sevilla
146#@date    2009-09-11
147#@version 0.9.2 - Soporta partición /boot independiente.
148#@author  Ramon Gomez, ETSII Universidad de Sevilla
149#@date    2010-07-20
150#*/ ##
151function ogLinuxBootParameters ()
152{
153# Variables locales.
154local MNTDIR CONFDIR CONFFILE
155
156# Si se solicita, mostrar ayuda.
157if [ "$*" == "help" ]; then
158    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
159           "$FUNCNAME 1 2  ==>  ..."
160    return
161fi
162# Error si no se reciben 2 parámetros.
163[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
164
165# Detectar id. de tipo de partición y codificar al mnemonico.
166MNTDIR=$(ogMount $1 $2) 2>/dev/null
167[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
168
169# Fichero de configuración de GRUB.
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 $?
175
176# Toma del fichero de configuracion los valores del kernel, initrd
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 .  */
180# /* (comentario Doxygen)
181awk 'BEGIN {cont=-1;}
182     $1~/^default/      {sub(/=/," "); def=$2;}
183     $1~/^set/ && $2~/^default/ {gsub(/[="]/," "); def=$3;}
184     $1~/^title|^menuentry/ {cont++}
185     $1~/^kernel|^linux/ {if (def==cont) {
186                            kern=$2;
187                            sub($1,"");sub($1,"");sub(/^[ \t]*/,"");app=$0}  # /* (comentario Doxygen)
188                        }
189     $1~/^initrd/       {if (def==cont) init=$2}
190     END {if (kern!="") printf("%s %s %s", kern,init,app)}
191    ' $CONFFILE
192# */ (comentario Doxygen)
193}
194
195
196#/**
197#         ogSetWindowsName int_ndisk int_npartition str_name
198#@brief   Establece el nombre del equipo en el registro de Windows.
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
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.
206#@version 0.9 - Adaptación a OpenGNSys.
207#@author  Ramon Gomez, ETSII Universidad de Sevilla
208#@date    2009-09-24
209#*/ ##
210function ogSetWindowsName ()
211{
212# Variables locales.
213local PART MNTDIR NAME
214
215# Si se solicita, mostrar ayuda.
216if [ "$*" == "help" ]; then
217    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_name" \
218           "$FUNCNAME 1 1 PRACTICA-PC"
219    return
220fi
221# Error si no se reciben 3 parámetros.
222[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
223
224# Montar el sistema de archivos.
225MNTDIR=$(ogMount $1 $2) 2>/dev/null
226[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
227NAME="$3"
228
229# Modificar datos de los valores de registro.
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
235}
236
237
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
275
276#/**
277#         ogBootMbrXP int_ndisk
278#@brief   Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows
279#@param   int_ndisk      nº de orden del disco
280#@return  salida del programa my-sys
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
288function ogBootMbrXP ()
289{
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
298fi
299# Error si no se reciben 1 parámetros.
300[ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $?
301
302PART="$(ogDiskToDev $1)" || return $?
303ms-sys -z -f $PART
304ms-sys -m -f $PART
305}
306
307
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
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
393spartlnx.run -cui -nm -a -f $FILE &
394sleep 5
395ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
396
397
398}
399
400
401
402#/**
403#         ogWindowsBootParameters int_ndisk int_parition
404#@brief   Configura el gestor de arranque de windows 7 / vista / XP / 2000
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.
410#@version 0.9 - Integración desde EAC para OpenGNSys.
411#@author  Antonio J. Doblas Viso. Universidad de Málaga
412#@date    2009-09-24
413#@version 1.0.1 - Adapatacion para OpenGnsys.
414#@author  Antonio J. Doblas Viso. Universidad de Málaga
415#@date    2011-05-20
416#*/ ##
417
418
419function ogWindowsBootParameters ()
420{
421# Variables locales.
422local PART DISK FILE
423#Preparando variables adaptadas a sintaxis windows.
424let DISK=$1-1
425PART=$2
426FILE=/tmp/temporal
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
442if echo "$VERSION" | grep "Windows 7"
443then
444        WINVER="Windows 7"
445elif echo "$VERSION" | grep "Windows Seven"
446then
447        WINVER="Windows Vista"
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
454else
455        return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
456fi
457
458ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
459
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
469spartlnx.run -cui -nm -w -f $FILE &
470sleep 5
471ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
472
473 
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
483spartlnx.run -cui -nm -w -f $FILE &
484sleep 5
485ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
486
487
488##Preparando instruccion        Ramdisk Options
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
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
509spartlnx.run -cui -nm -w -f $FILE &
510sleep 5
511ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
512
513
514#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
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
525
526}
527       
528
529#         ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition
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
545function ogWindowsRegisterPartition ()
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
599spartlnx.run -cui -nm -u -f $FILE &
600sleep 5
601ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
602
603}
Note: See TracBrowser for help on using the repository browser.