source: client/engine/Boot.lib @ ec8b743

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 ec8b743 was e538e62, checked in by ramon <ramongomez@…>, 12 years ago

#555: Función ogSetWindowsName controla que no se sobrepase el tamaño máximo de nombre Netbios.
Se recupera el error OG_ERR_OUTOFLIMIT para valores fuera de rango.
Se corrige una errata en el arranque para cargar, si existe, teclado del idioma.

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

  • Property mode set to 100755
File size: 32.5 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.
[e538e62]7#@version 1.0.5
[b094c59]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
[3915005]23#@version 0.1 - Integración para OpenGnSys. - EAC: HDboot; BootLinuxEX en Boot.lib 
[985bef0]24#@author  Antonio J. Doblas Viso, Universidad de Malaga
[e05993a]25#@date    2008-10-27
[3915005]26#@version 0.9 - Adaptación para OpenGnSys.
[b094c59]27#@author  Ramon Gomez, ETSII Universidad de Sevilla
28#@date    2009-09-11
[40ad2e8d]29#@version 1.0.4 - Soporta modo de arranque Windows (parámetro de inicio "winboot").
30#@author  Ramon Gomez, ETSII Universidad de Sevilla
31#@date    2012-04-12
[1e7eaab]32#*/ ##
[42669ebf]33function ogBoot ()
34{
[b094c59]35# Variables locales.
[40ad2e8d]36local PART TYPE MNTDIR PARAMS KERNEL INITRD APPEND FILE LOADER f
[b094c59]37
[1e7eaab]38# Si se solicita, mostrar ayuda.
[b094c59]39if [ "$*" == "help" ]; then
40    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
41           "$FUNCNAME 1 1"
42    return
43fi
[1e7eaab]44# Error si no se reciben 2 parámetros.
[b094c59]45[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
46
[1e7eaab]47# Detectar tipo de sistema de archivos y montarlo.
[049eadbe]48PART=$(ogDiskToDev $1 $2) || return $?
[b094c59]49TYPE=$(ogGetFsType $1 $2) || return $?
[f5432db7]50MNTDIR=$(ogMount $1 $2) 2>/dev/null
51[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[b094c59]52
53case "$TYPE" in
[049eadbe]54    EXT[234]|REISERFS|REISER4|JFS|XFS)
[1e7eaab]55        # Obtiene los parámetros de arranque para Linux.
[f5432db7]56        PARAMS=$(ogLinuxBootParameters $1 $2) || return $?
57        read -e KERNEL INITRD APPEND <<<"$PARAMS"
[1e7eaab]58        # Si no hay kernel, no hay sistema operativo.
[f5432db7]59        [ -z "$KERNEL" ] && ogRaiseError $OG_ERR_NOTOS && return $?
[1e7eaab]60        # Arrancar de partición distinta a la original.
[049eadbe]61        [ -e "$MNTDIR/etc" ] && APPEND=$(echo $APPEND | awk -v P="$PART " '{sub (/root=[-+=_/a-zA-Z0-9]* /,"root="P);print}')
[f5432db7]62        # Configurar kernel Linux con los parámetros leídos de su GRUB.
[049eadbe]63        kexec -l "${MNTDIR}${KERNEL}" --append="$APPEND" --initrd="${MNTDIR}${INITRD}"
[40ad2e8d]64        kexec -e &
[f5432db7]65        ;;
66    NTFS|HNTFS|FAT32|HFAT32)
[1e7eaab]67        # Compruebar si hay un cargador de Windows.
[f5432db7]68        for f in io.sys ntldr bootmgr; do
69            FILE="$(ogGetPath $1 $2 $f 2>/dev/null)"
[d10549b]70            [ -n "$FILE" ] && LOADER="$f"
[f5432db7]71        done
72        [ -z "$LOADER" ] && ogRaiseError $OG_ERR_NOTOS && return $?
[256dee7]73        # Activar la partición.
[f5432db7]74        ogSetPartitionActive $1 $2
[40ad2e8d]75        ogSetRegistryValue $MNTDIR SYSTEM '\ControlSet001\services\Cliente Opengnsys\Start' '2'
76        ogSetRegistryValue $MNTDIR SYSTEM '\ControlSet002\services\Cliente Opengnsys\Start' '2'
77        ogSetRegistryValue $MNTDIR SYSTEM '\ControlSet003\services\Cliente Opengnsys\Start' '2'
78        if [ "$winboot" == "kexec" ]; then
79            # Modo de arranque en caliente (con kexec).
80            cp $OGLIB/grub4dos/* $MNTDIR    # */ (Comentario Doxygen)
81            kexec -l $MNTDIR/grub.exe --append=--config-file="root (hd$[$1-1],$[$2-1]); chainloader (hd$[$1-1],$[$2-1])/$LOADER; tpm --init"
82            kexec -e &
83        else
84            # Modo de arranque por reinicio (con reboot).
[75a296b]85            dd if=/dev/zero of=${MNTDIR}/ogboot.me bs=1024 count=3
86            dd if=/dev/zero of=${MNTDIR}/ogboot.firstboot bs=1024 count=3
87            dd if=/dev/zero of=${MNTDIR}/ogboot.secondboot bs=1024 count=3
88            ogLoadHiveWindows $1 $2
89            ogHiveNTRunMachine "cmd /c del c:\ogboot.*" ogcleanboot
90            ogUpdateHiveWindows
91            reboot
92        fi
[f5432db7]93        ;;
94    *)  ogRaiseError $OG_ERR_PARTITION "$1, $2"
[326cec3]95        return $?
[f5432db7]96        ;;
[b094c59]97esac
98
[40ad2e8d]99# Parar Browser para evitar cuelgues.
[0b9c763]100pkill browser
[b094c59]101}
102
103
104#/**
[3e1561d]105#         ogGetWindowsName int_ndisk int_npartition
106#@brief   Muestra el nombre del equipo en el registro de Windows.
[42669ebf]107#@param   int_ndisk      nº de orden del disco
108#@param   int_npartition nº de orden de la partición
[3e1561d]109#@return  str_name - nombre del equipo
110#@exception OG_ERR_FORMAT    Formato incorrecto.
111#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
112#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[3915005]113#@version 0.9 - Adaptación para OpenGnSys.
[3e1561d]114#@author  Ramon Gomez, ETSII Universidad de Sevilla
115#@date    2009-09-23
[1e7eaab]116#*/ ##
[42669ebf]117function ogGetWindowsName ()
118{
[3e1561d]119# Variables locales.
120local PART MNTDIR
121
[1e7eaab]122# Si se solicita, mostrar ayuda.
[3e1561d]123if [ "$*" == "help" ]; then
124    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
125           "$FUNCNAME 1 1  ==>  PRACTICA-PC"
126    return
127fi
[1e7eaab]128# Error si no se reciben 2 parámetros.
[3e1561d]129[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
130
[1e7eaab]131# Montar el sistema de archivos.
[f5432db7]132MNTDIR=$(ogMount $1 $2) 2>/dev/null
133[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[3e1561d]134
[1e7eaab]135# Obtener dato del valor de registro.
[3e1561d]136ogGetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName'
137}
138
139
140#/**
[4c63eb9]141#         ogLinuxBootParameters int_ndisk int_npartition
[b094c59]142#@brief   Muestra los parámetros de arranque de un sistema de archivos Linux.
[42669ebf]143#@param   int_ndisk      nº de orden del disco
144#@param   int_npartition nº de orden de la partición
145#@return  str_kernel str_initrd str_parameters ...
[b094c59]146#@exception OG_ERR_FORMAT    Formato incorrecto.
147#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
148#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[055adcf]149#@warning Función básica usada por \c ogBoot
[3915005]150#@version 0.9 - Primera adaptación para OpenGnSys.
[b094c59]151#@author  Ramon Gomez, ETSII Universidad de Sevilla
152#@date    2009-09-11
[199bdf3]153#@version 0.9.2 - Soporta partición /boot independiente.
154#@author  Ramon Gomez, ETSII Universidad de Sevilla
155#@date    2010-07-20
[1e7eaab]156#*/ ##
[42669ebf]157function ogLinuxBootParameters ()
158{
[b094c59]159# Variables locales.
[199bdf3]160local MNTDIR CONFDIR CONFFILE
[b094c59]161
[1e7eaab]162# Si se solicita, mostrar ayuda.
[b094c59]163if [ "$*" == "help" ]; then
164    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
165           "$FUNCNAME 1 2  ==>  ..."
166    return
167fi
[1e7eaab]168# Error si no se reciben 2 parámetros.
[b094c59]169[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
170
[1e7eaab]171# Detectar id. de tipo de partición y codificar al mnemonico.
[f5432db7]172MNTDIR=$(ogMount $1 $2) 2>/dev/null
173[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
[b094c59]174
175# Fichero de configuración de GRUB.
[199bdf3]176CONFDIR=$MNTDIR                               # Partición de arranque /boot.
177[ -d $MNTDIR/boot ] && CONFDIR=$MNTDIR/boot   # Partición raíz con directorio boot.
[210a4ffc]178CONFFILE="$CONFDIR/grubPARTITION/boot/grub/grub.cfg"
179[ ! -e $CONFFILE ] && CONFFILE="$CONFDIR/grub/menu.lst"
[199bdf3]180[ ! -e $CONFFILE ] && CONFFILE="$CONFDIR/grub/grub.cfg"
181[ ! -e $CONFFILE ] && ogRaiseError $OG_ERR_NOTFOUND "grub.cfg" && return $?
[b094c59]182
[1e7eaab]183# Toma del fichero de configuracion los valores del kernel, initrd
[ee4a96e]184#       y parámetros de arranque usando las cláusulas por defecto
185#       ("default" en GRUB1, "set default" en GRUB2)
186#       y los formatea para que sean compatibles con \c kexec .  */
[1e7eaab]187# /* (comentario Doxygen)
[b094c59]188awk 'BEGIN {cont=-1;}
189     $1~/^default/      {sub(/=/," "); def=$2;}
[18f4bc2]190     $1~/^set/ && $2~/^default/ {gsub(/[="]/," "); def=$3;}
[ee4a96e]191     $1~/^title|^menuentry/ {cont++}
192     $1~/^kernel|^linux/ {if (def==cont) {
[b094c59]193                            kern=$2;
[1e7eaab]194                            sub($1,"");sub($1,"");sub(/^[ \t]*/,"");app=$0}  # /* (comentario Doxygen)
[b094c59]195                        }
196     $1~/^initrd/       {if (def==cont) init=$2}
197     END {if (kern!="") printf("%s %s %s", kern,init,app)}
[199bdf3]198    ' $CONFFILE
[1e7eaab]199# */ (comentario Doxygen)
[b094c59]200}
201
[3e1561d]202
203#/**
[e538e62]204#         ogSetWindowsName int_ndisk int_nfilesys str_name
[3e1561d]205#@brief   Establece el nombre del equipo en el registro de Windows.
[42669ebf]206#@param   int_ndisk      nº de orden del disco
[e538e62]207#@param   int_nfilesys   nº de orden del sistema de archivos
[42669ebf]208#@param   str_name       nombre asignado
[3e1561d]209#@return  (nada)
[e538e62]210#@exception OG_ERR_FORMAT     Formato incorrecto.
211#@exception OG_ERR_NOTFOUND   Disco o particion no corresponden con un dispositivo.
212#@exception OG_ERR_PARTITION  Tipo de partición desconocido o no se puede montar.
213#@exception OG_ERR_OUTOFLIMIT Nombre Netbios con más de 15 caracteres.
[3915005]214#@version 0.9 - Adaptación a OpenGnSys.
[3e1561d]215#@author  Ramon Gomez, ETSII Universidad de Sevilla
216#@date    2009-09-24
[e538e62]217#@version 1.0.5 - Establecer restricción de tamaño de nombre Netbios.
218#@author  Ramon Gomez, ETSII Universidad de Sevilla
219#@date    2013-03-20
[1e7eaab]220#*/ ##
[42669ebf]221function ogSetWindowsName ()
222{
[3e1561d]223# Variables locales.
224local PART MNTDIR NAME
225
[1e7eaab]226# Si se solicita, mostrar ayuda.
[3e1561d]227if [ "$*" == "help" ]; then
[e538e62]228    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys str_name" \
[3e1561d]229           "$FUNCNAME 1 1 PRACTICA-PC"
230    return
231fi
[1e7eaab]232# Error si no se reciben 3 parámetros.
[3e1561d]233[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
[e538e62]234# Error si el nombre supera los 15 caracteres.
235[ ${#3} -le 15 ] || ogRaiseError $OG_ERR_OUTOFLIMIT "\"${3:0:15}...\"" || return $?
[3e1561d]236
[42669ebf]237# Montar el sistema de archivos.
[f5432db7]238MNTDIR=$(ogMount $1 $2) 2>/dev/null
[e538e62]239[ -n "$MNTDIR" ] || ogRaiseError OG_ERR_PARTITION "$1, $2" || return $?
[3e1561d]240NAME="$3"
241
[1e7eaab]242# Modificar datos de los valores de registro.
[4b9cdda]243ogSetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName' "$NAME" 2>/dev/null
244ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\Hostname' "$NAME" 2>/dev/null
245ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\Hostname' "$NAME" 2>/dev/null
246ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\NV Hostname' "$NAME" 2>/dev/null
247ogSetRegistryValue $MNTDIR system '\ControlSet001\services\Tcpip\Parameters\NV Hostname' "$NAME" 2>/dev/null
[3e1561d]248}
249
[f5432db7]250
[4b9cdda]251#/**
252#         ogSetWinlogonUser int_ndisk int_npartition str_username
253#@brief   Establece el nombre de usuario por defecto en la entrada de Windows.
254#@param   int_ndisk      nº de orden del disco
255#@param   int_npartition nº de orden de la partición
256#@param   str_username   nombre de usuario por defecto
257#@return  (nada)
258#@exception OG_ERR_FORMAT    Formato incorrecto.
259#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
260#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[3915005]261#@version 0.9.2 - Adaptación a OpenGnSys.
[4b9cdda]262#@author  Ramon Gomez, ETSII Universidad de Sevilla
263#@date    2010-07-20
264#*/ ##
265function ogSetWinlogonUser ()
266{
267# Variables locales.
268local PART MNTDIR NAME
269
270# Si se solicita, mostrar ayuda.
271if [ "$*" == "help" ]; then
272    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_username" \
273           "$FUNCNAME 1 1 USUARIO"
274    return
275fi
276# Error si no se reciben 3 parámetros.
277[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
278
279# Montar el sistema de archivos.
280MNTDIR=$(ogMount $1 $2) 2>/dev/null
281[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
282NAME="$3"
283
284# Modificar datos en el registro.
285ogSetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName' "$3"
286}
287
[38231e9]288
289#/**
[9e8773c]290#         ogBootMbrXP int_ndisk
[38231e9]291#@brief   Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows
[42669ebf]292#@param   int_ndisk      nº de orden del disco
[945b003]293#@return  salida del programa my-sys
[38231e9]294#@exception OG_ERR_FORMAT    Formato incorrecto.
295#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[3915005]296#@version 0.9 - Adaptación a OpenGnSys.
[38231e9]297#@author  Antonio J. Doblas Viso. Universidad de Málaga
298#@date    2009-09-24
299#*/ ##
300
[9e8773c]301function ogBootMbrXP ()
[e05993a]302{
[38231e9]303# Variables locales.
304local PART
305
306# Si se solicita, mostrar ayuda.
307if [ "$*" == "help" ]; then
308    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \
309           "$FUNCNAME 1 "
310    return
[945b003]311fi
[38231e9]312# Error si no se reciben 1 parámetros.
313[ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $?
314
[6e139c9]315PART="$(ogDiskToDev $1)" || return $?
[38231e9]316ms-sys -z -f $PART
317ms-sys -m -f $PART
[945b003]318}
[42669ebf]319
[fdad5a6]320
[9e8773c]321#/**
322#         ogBootMbrGeneric int_ndisk
323#@brief   Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
324#@param   int_ndisk      nº de orden del disco
325#@return  salida del programa my-sys
326#@exception OG_ERR_FORMAT    Formato incorrecto.
327#@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar.
[3915005]328#@version 0.9 - Adaptación a OpenGnSys.
[9e8773c]329#@author  Antonio J. Doblas Viso. Universidad de Málaga
330#@date    2009-09-24
331#*/ ##
332
333function ogBootMbrGeneric ()
334{
335# Variables locales.
336local PART
337
338# Si se solicita, mostrar ayuda.
339if [ "$*" == "help" ]; then
340    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \
341           "$FUNCNAME 1 "
342    return
343fi
344# Error si no se reciben 1 parámetros.
345[ $# == 1 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
346
347PART="$(ogDiskToDev $1)" || return $(ogRaiseError $OG_ERR_NOTFOUND; echo $?)
348ms-sys -z -f $PART
349ms-sys -s -f $PART
350}
351
352
353
[fdad5a6]354
355#/**
356#         ogFixBootSector int_ndisk int_parition
357#@brief   Corrige el boot sector de una particion activa para MS windows/dos -fat-ntfs
358#@param   int_ndisk      nº de orden del disco
359#@param   int_partition     nº de particion
360#@return 
361#@exception OG_ERR_FORMAT    Formato incorrecto.
362#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[3915005]363#@version 0.9 - Adaptación a OpenGnSys.
[fdad5a6]364#@author  Antonio J. Doblas Viso. Universidad de Málaga
365#@date    2009-09-24
366#*/ ##
367
368function ogFixBootSector ()
369{
370# Variables locales.
[1cd64e6]371local PARTYPE DISK PART FILE
[fdad5a6]372
373# Si se solicita, mostrar ayuda.
374if [ "$*" == "help" ]; then
375    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \
376           "$FUNCNAME 1 1 "
377    return
378fi
379
380# Error si no se reciben 2 parámetros.
381[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
382
383#TODO, solo si la particion existe
384#TODO, solo si es ntfs o fat
385PARTYPE=$(ogGetPartitionId $1 $2)
[3915005]386case "$PARTYPE" in
[fdad5a6]387        1|4|6|7|b|c|e|f)
388        ;;
389        *)
390        return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
391        ;;
392esac
393
394ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
395
396#Preparando instruccion
397let DISK=$1-1   
398PART=$2
[1cd64e6]399FILE=/tmp/temp$$
[fdad5a6]400cat > $FILE <<EOF
401disk=$DISK
402main_part=$PART
403fix_first_sector=yes
404EOF
405
[5fde4bc]406spartlnx.run -cui -nm -a -f $FILE &
407sleep 5
408ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
[1cd64e6]409rm -f $FILE
[fdad5a6]410}
411
412
413
414#/**
415#         ogWindowsBootParameters int_ndisk int_parition
[78b5dfe7]416#@brief   Configura el gestor de arranque de windows 7 / vista / XP / 2000
[fdad5a6]417#@param   int_ndisk      nº de orden del disco
418#@param   int_partition     nº de particion
419#@return 
420#@exception OG_ERR_FORMAT    Formato incorrecto.
421#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[3915005]422#@version 0.9 - Integración desde EAC para OpenGnSys.
[fdad5a6]423#@author  Antonio J. Doblas Viso. Universidad de Málaga
424#@date    2009-09-24
[78b5dfe7]425#@version 1.0.1 - Adapatacion para OpenGnsys.
426#@author  Antonio J. Doblas Viso. Universidad de Málaga
427#@date    2011-05-20
[fdad5a6]428#*/ ##
429
430
431function ogWindowsBootParameters ()
432{
433# Variables locales.
[3915005]434local PART DISK FILE VERSION WINVER MOUNT
[78b5dfe7]435#Preparando variables adaptadas a sintaxis windows.
436let DISK=$1-1
437PART=$2
[3915005]438FILE=/tmp/temp$$
[fdad5a6]439
440# Si se solicita, mostrar ayuda.
441if [ "$*" == "help" ]; then
442    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \
443           "$FUNCNAME 1 1 "
444    return
445fi
446
447# Error si no se reciben 2 parámetros.
448[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
449
450ogDiskToDev $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
451
452VERSION=$(ogGetOsVersion $1 $2)
453
[78b5dfe7]454if echo "$VERSION" | grep "Windows 7"
[fdad5a6]455then
456        WINVER="Windows 7"
[78b5dfe7]457elif echo "$VERSION" | grep "Windows Seven"
[fdad5a6]458then
459        WINVER="Windows Vista"
[78b5dfe7]460elif echo "$VERSION" | grep "XP"
461then
462        MOUNT=$(ogMount $1 $2)
463        [ -f ${MOUNT}/boot.ini ] || return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
464        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
465        return 0
[fdad5a6]466else
467        return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
468fi
469
470ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?)
[78b5dfe7]471
[fdad5a6]472
473#Preparando instruccion Windows Resume Application
474cat > $FILE <<EOF
475boot_disk=$DISK
476boot_main_part=$PART
477disk=$DISK
478main_part=$PART
479boot_entry=Windows Resume Application
480EOF
[5fde4bc]481spartlnx.run -cui -nm -w -f $FILE &
482sleep 5
483ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
484
485 
[fdad5a6]486
487#Preparando instruccion tipo windows
488cat > $FILE <<EOF
489boot_disk=$DISK
490boot_main_part=$PART
491disk=$DISK
492main_part=$PART
493boot_entry=$WINVER
494EOF
[5fde4bc]495spartlnx.run -cui -nm -w -f $FILE &
496sleep 5
497ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
498
[fdad5a6]499
[250742d]500##Preparando instruccion        Ramdisk Options
[5fde4bc]501cat > $FILE <<EOF
502boot_disk=$DISK
503boot_main_part=$PART
504disk=$DISK
505main_part=$PART
506boot_entry=Ramdisk Options
507EOF
508spartlnx.run -cui -nm -w -f $FILE &
509sleep 5
510ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
511
[fdad5a6]512
513#Preparando instruccion Windows Boot Manager
514cat > $FILE <<EOF
515boot_disk=$DISK
516boot_main_part=$PART
517disk=$DISK
518main_part=$PART
519boot_entry=Windows Boot Manager
520EOF
[5fde4bc]521spartlnx.run -cui -nm -w -f $FILE &
522sleep 5
523ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
524
[fdad5a6]525
526#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
[5fde4bc]527cat > $FILE <<EOF
528boot_disk=$DISK
529boot_main_part=$PART
530disk=$DISK
531main_part=$PART
532boot_entry=Herramienta de diagnóstico de memoria de Windows
533EOF
534spartlnx.run -cui -nm -w -f $FILE &
535sleep 5
536ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
[fdad5a6]537
538}
[3915005]539
[fdad5a6]540
[78b5dfe7]541#         ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition
[fdad5a6]542#@brief   Registra una partición en windows con un determinado volumen.
543#@param   int_ndisk      nº de orden del disco a registrar
544#@param   int_partition     nº de particion a registrar
545#@param   str_volumen      volumen a resgistar
546#@param   int_ndisk_windows      nº de orden del disco donde esta windows
547#@param   int_partition_windows     nº de particion donde esta windows
548#@return 
549#@exception OG_ERR_FORMAT    Formato incorrecto.
550#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
[3915005]551#@version 0.9 - Adaptación a OpenGnSys.
[fdad5a6]552#@author  Antonio J. Doblas Viso. Universidad de Málaga
553#@date    2009-09-24
554#*/ ##
[78b5dfe7]555function ogWindowsRegisterPartition ()
[3915005]556{
[fdad5a6]557# Variables locales.
[3915005]558local PART DISK FILE REGISTREDDISK REGISTREDPART REGISTREDVOL VERSION SYSTEMROOT
[fdad5a6]559
560# Si se solicita, mostrar ayuda.
561if [ "$*" == "help" ]; then
562    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk_TO_registre int_partition_TO_registre str_NewVolume int_disk int_parition " \
563           "$FUNCNAME 1 1 c: 1 1"
564    return
565fi
566
567# Error si no se reciben 5 parámetros.
568[ $# == 5 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
569
570REGISTREDDISK=$1
571REGISTREDPART=$2
572REGISTREDVOL=$(echo $3 | cut -c1 | tr '[:lower:]' '[:upper:]')
573DISK=$4
574PART=$5
[3915005]575FILE=/tmp/temp$$
[fdad5a6]576
577ogDiskToDev $REGISTREDDISK $REGISTREDPART || return $(ogRaiseError $OG_ERR_PARTITION "particion a registrar "; echo $?)
578ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows"; echo $?)
579
580ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?)
581
582VERSION=$(ogGetOsVersion $DISK $PART)
583
584#Systemroot
585
586if ogGetPath $DISK $PART WINDOWS
587then
588        SYSTEMROOT="Windows"
589elif ogGetPath $DISK $PART WINNT
590then
591        SYSTEMROOT="winnt"
592else
593        return $(ogRaiseError $OG_ERR_NOTOS; echo $?)
594fi
595
596ogUnmount $DISK $PART
597let DISK=$DISK-1
598let REGISTREDDISK=$REGISTREDDISK-1
599#Preparando instruccion Windows Boot Manager
600cat > $FILE <<EOF
601windows_disk=$DISK
602windows_main_part=$PART
603windows_dir=$SYSTEMROOT
604disk=$REGISTREDDISK
605main_part=$REGISTREDPART
606;ext_part
607part_letter=$REGISTREDVOL
608EOF
[5fde4bc]609spartlnx.run -cui -nm -u -f $FILE &
610sleep 5
611ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
612
[e0c0d93]613}
[ab82469]614
615
[9c535e0]616#         ogGrubInstallMbr  int_disk_GRUBCFG  int_partition_GRUBCFG #@param   bolean_Check_Os_installed_and_Configure_2ndStage   true | false[default]
[a4b1e2a]617#@brief   Instala y actualiza el gestor grub el el MBR del disco duro donde se encuentra el fichero grub.cfg. Admite sistemas Windows.
[9c535e0]618#@param   int_disk_SecondStage     
619#@param   int_part_SecondStage     
620#@param   bolean_Check_Os_installed_and_Configure_2ndStage   true | false[default]
[ab82469]621#@return 
622#@exception OG_ERR_FORMAT    Formato incorrecto.
623#@version 1.0.2 - Primeras pruebas.
624#@author  Antonio J. Doblas Viso.   Universidad de Malaga.
625#@date    2011-10-29
[9c535e0]626#@version 1.0.3 - Soporte para linux de 32 y 64 bits
627#@author  Antonio J. Doblas Viso.   Universidad de Malaga.
628#@date    2012-03-13
629#@version 1.0.3 - Ficheros de configuracion independientes segun ubicación de la primera etapa
630#@author  Antonio J. Doblas Viso.   Universidad de Malaga.
631#@date    2012-03-13
[ab82469]632#*/ ##
633
[9c535e0]634function ogGrubInstallMbr {
[ab82469]635
636# Variables locales.
[1c69be8]637local PART DISK VERSION FIRSTAGE SECONSTAGE CHECKOS KERNELPARAM BACKUPNAME
[ab82469]638
639# Si se solicita, mostrar ayuda.
640if [ "$*" == "help" ]; then
[9c535e0]641    ogHelp "$FUNCNAME" "$FUNCNAME  int_ndiskSecondStage int_partitionSecondStage bolean_Configure_2ndStage   \"param param \"  " \
642           "$FUNCNAME 1 1 FALSE " \
643           "$FUNCNAME 1 1 TRUE \"nomodeset irqpoll pci=noacpi quiet splash \" "
[ab82469]644    return
[9c535e0]645fi 
[ab82469]646
647# Error si no se reciben 2 parámetros.
[9c535e0]648[ $# -ge 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
[ab82469]649
650
[9c535e0]651DISK=$1; PART=$2;
652CHECKOS=${3:-"FALSE"}
653KERNELPARAM=$4
[1c69be8]654BACKUPNAME=".backup.og"
[ab82469]655
[9c535e0]656#Error si no es linux.
657#TODO: comprobar si se puede utilizar la particion windows como contenedor de grub.
[a4b1e2a]658#VERSION=$(ogGetOsVersion $DISK $PART)
659#echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
[ab82469]660
[9c535e0]661#Localizar primera etapa del grub
662FIRSTSTAGE=$(ogDiskToDev $DISK)
[ab82469]663
[9c535e0]664#localizar disco segunda etapa del grub
665SECONDSTAGE=$(ogMount $DISK $PART)
[ab82469]666
[a4b1e2a]667# prepara el directorio principal de la segunda etapa
668[ -d ${SECONDSTAGE}/boot/grub/ ]  || mkdir -p ${SECONDSTAGE}/boot/grub/
669
[9c535e0]670#Localizar directorio segunda etapa del grub   
671PREFIXSECONDSTAGE="/boot/grubMBR"
[ab82469]672
[9c535e0]673# Si Reconfigurar segunda etapa (grub.cfg) == FALSE
[1c69be8]674if [ -f ${SECONDSTAGE}/boot/grub/grub.cfg -o -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ]
[9c535e0]675then
676    if [ "$CHECKOS" == "false" -o "$CHECKOS" == "FALSE" ]
677    then
[1c69be8]678        # Si no se reconfigura se utiliza el grub.cfg orginal
679        [ -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ${SECONDSTAGE}/boot/grub/grub.cfg
680                # Si no se reconfigure se borra los ficheros previos de configuración específicos de opengnsys.
681        [ -d ${SECONDSTAGE}${PREFIXSECONDSTAGE} ] &&  rm -fr ${SECONDSTAGE}${PREFIXSECONDSTAGE}
682        # Reactivamos el grub con el grub.cfg original.
[9c535e0]683        grub-install --force --root-directory=${SECONDSTAGE} $FIRSTSTAGE
684        return $?
685    fi
686fi
687
688# SI Reconfigurar segunda etapa (grub.cfg) == TRUE
689#Configur la sintaxis grub para evitar menus de "recovery" en el OGLive
690echo "GRUB_DISABLE_RECOVERY=\"true\"" >> /etc/default/grub
691echo "GRUB_DISABLE_LINUX_UUID=\"true\"" >> /etc/default/grub
[ab82469]692
[9c535e0]693#Evitar detectar modo recovery - mover grub.cfg original a grub.cfg.backup
[1c69be8]694[ -f ${SECONDSTAGE}/boot/grub/grub.cfg ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME
[9c535e0]695
696#Preparar configuración segunda etapa: crear ubicacion
697mkdir -p ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/
698#Preparar configuración segunda etapa: crear cabecera del fichero
699/etc/grub.d/00_header > ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg
700#Preparar configuración segunda etapa: crear entrada del sistema operativo
701grubSyntax "$KERNELPARAM" >> ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg
702
703#Instalar el grub
704grub-install --force --root-directory=${SECONDSTAGE}${PREFIXSECONDSTAGE} $FIRSTSTAGE
705}
[ab82469]706
707
708
[9c535e0]709#         ogGrubInstallPartition int_disk_SECONDSTAGE  int_partition_SECONDSTAGE bolean_Check_Os_installed_and_Configure_2ndStage
710#@brief   Instala y actualiza el gestor grub en el bootsector de la particion indicada
711#@param   int_disk_SecondStage     
712#@param   int_part_SecondStage     
713#@param   bolean_Check_Os_installed_and_Configure_2ndStage   true | false[default]
714#@param   str "kernel param "   
715#@return 
716#@exception OG_ERR_FORMAT    Formato incorrecto.
717#@version 1.0.2 - Primeras pruebas.
718#@author  Antonio J. Doblas Viso.   Universidad de Malaga.
719#@date    2011-10-29
720#@version 1.0.3 - Soporte para linux de 32 y 64 bits
721#@author  Antonio J. Doblas Viso.   Universidad de Malaga.
722#@date    2012-03-13
723#@version 1.0.3 - Ficheros de configuracion independientes segun ubicación de la priemra etapa
724#@author  Antonio J. Doblas Viso.   Universidad de Malaga.
725#@date    2012-03-13
726#*/ ##
[ab82469]727
[9c535e0]728function ogGrubInstallPartition {
[ab82469]729
[9c535e0]730# Variables locales.
[1c69be8]731local PART DISK VERSION FIRSTAGE SECONSTAGE CHECKOS KERNELPARAM BACKUPNAME
[9c535e0]732
733# Si se solicita, mostrar ayuda.
734if [ "$*" == "help" ]; then
735    ogHelp "$FUNCNAME" "$FUNCNAME int_ndiskSecondStage int_partitionSecondStage bolean_Configure_2ndStage   \"param param \" " \
736           "$FUNCNAME 1 1 FALSE " \
737           "$FUNCNAME 1 1 TRUE \"nomodeset irqpoll pci=noacpi quiet splash \" "
738    return
739fi 
740
741# Error si no se reciben 2 parámetros.
742[ $# -ge 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
743
744DISK=$1; PART=$2;
745CHECKOS=${3:-"FALSE"}
746KERNELPARAM=$4
[1c69be8]747BACKUPNAME=".backup.og"
[9c535e0]748
749#error si no es linux.
750VERSION=$(ogGetOsVersion $DISK $PART)
751echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
752
753#Localizar primera etapa del grub
754FIRSTSTAGE=$(ogDiskToDev $DISK $PART)
755
756#localizar disco segunda etapa del grub
757SECONDSTAGE=$(ogMount $DISK $PART)
758
759#Localizar directorio segunda etapa del grub   
760PREFIXSECONDSTAGE="/boot/grubPARTITION"
761
762# Si Reconfigurar segunda etapa (grub.cfg) == FALSE
[1c69be8]763if [ -f ${SECONDSTAGE}/boot/grub/grub.cfg -o -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ]
[9c535e0]764then
765    if [ "$CHECKOS" == "false" -o "$CHECKOS" == "FALSE" ]
766    then
[1c69be8]767        # Si no se reconfigura se utiliza el grub.cfg orginal
768        [ -f ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME ${SECONDSTAGE}/boot/grub/grub.cfg
769                # Si no se reconfigure se borra los ficheros previos de configuración específicos de opengnsys.
770        [ -d ${SECONDSTAGE}${PREFIXSECONDSTAGE} ] &&  rm -fr ${SECONDSTAGE}${PREFIXSECONDSTAGE}
771        # Reactivamos el grub con el grub.cfg original.
[9c535e0]772        grub-install --force --root-directory=${SECONDSTAGE} $FIRSTSTAGE
773        return $?
774    fi
775fi
776
777# SI Reconfigurar segunda etapa (grub.cfg) == TRUE
778#Configur la sintaxis grub para evitar menus de "recovery" en el OGLive
779echo "GRUB_DISABLE_RECOVERY=\"true\"" >> /etc/default/grub
780echo "GRUB_DISABLE_LINUX_UUID=\"true\"" >> /etc/default/grub
781
[1c69be8]782#Evitar detectar modo recovery - mover grub.cfg original a grub.cfg.backup.og
783[ -f ${SECONDSTAGE}/boot/grub/grub.cfg ] && mv ${SECONDSTAGE}/boot/grub/grub.cfg ${SECONDSTAGE}/boot/grub/grub.cfg$BACKUPNAME
[9c535e0]784
785#Preparar configuración segunda etapa: crear ubicacion
786mkdir -p ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/
787#Preparar configuración segunda etapa: crear cabecera del fichero
788/etc/grub.d/00_header > ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg
789#Preparar configuración segunda etapa: crear entrada del sistema operativo
790grubSyntax $DISK $PART "$KERNELPARAM" >> ${SECONDSTAGE}${PREFIXSECONDSTAGE}/boot/grub/grub.cfg
791
792#Instalar el grub
793grub-install --force --root-directory=${SECONDSTAGE}${PREFIXSECONDSTAGE} $FIRSTSTAGE
[ab82469]794}
795
[00cede9]796###
797#En pruebas
798##
799#/**
800#         ogConfigureFstab int_ndisk int_npartition str_name
801#@brief   Establece el nombre del equipo en los ficheros hostname y hosts.
802#@param   int_ndisk      nº de orden del disco
803#@param   int_npartition nº de orden de la partición
804#@return  (nada)
805#@exception OG_ERR_FORMAT    Formato incorrecto.
806#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
807#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
808#@version .
809#@author 
810#@date   
811#*/ ##
812function ogConfigureFstab {
813# Variables locales.
814local PART MNTDIR  MNTLINUX DEFROOT PARTROOT PARTSWAP
815
816# Si se solicita, mostrar ayuda.
817if [ "$*" == "help" ]; then
818    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition " \
819           "$FUNCNAME 1 1 "
820    return
821fi
822# Error si no se reciben 2 parámetros.
823[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
824
825MNTLINUX=$(ogMount $1 $2)
826
827#Test fstab . pasar a funcion tipo ogLNXfstab
828cp ${MNTLINUX}/etc/fstab ${MNTLINUX}/etc/fstab.backup
829cat ${MNTLINUX}/etc/fstab | egrep -v  " was on" > ${MNTLINUX}/etc/fstab.new
830DEFROOT=$(cat ${MNTLINUX}/etc/fstab.new | grep " / " | awk '{print $1}')
831PARTROOT=$(ogDiskToDev $1 $2)   
832#PARTROOT=LABEL=Sistema
833#configuracion de la swap
834PARTSWAP=$(fdisk -l $(ogDiskToDev $1 ) | grep swap | awk '{print $1}')
835if [ -n "$PARTSWAP" ]
836then
837    ogFormat $(ogDevToDisk $PARTSWAP)
838    #swapnew=$(fdisk -l | grep swap | awk '{print $1}')
839    echo "Existe partición swap en $PARTSWAP "
840    DEFSWAP=$(grep swap ${MNTLINUX}/etc/fstab.new | awk '{print $1}')
841    if [ -n "$DEFSWAP" ]
842    then               
843        #swapold=$(cat ${MNTLINUX}/etc/fstab.new | grep "none" | awk '{print $1}')   
844        echo "Hay definicion de swap en el fstab $DEFSWAP -> modificamos fichero con nuevo valor $DEFSWAP->$PARTSWAP"
845        sed "s|$DEFSWAP|$PARTSWAP|g ; s|$DEFROOT|$PARTROOT|g" ${MNTLINUX}/etc/fstab.new > ${MNTLINUX}/etc/fstab
846    else
847        echo "No hay definicion de swap y si hay partición swap -> moficamos fichero"
848        sed "s|$DEFROOT|$PARTROOT|g" ${MNTLINUX}/etc/fstab.renew > ${MNTLINUX}/etc/fstab
849        echo "$PARTSWAP none            swap    sw              0       0" >> ${MNTLINUX}/etc/fstab
850    fi 
851else
852    echo "No hay partición swap -> configuramos fstba"
853    cat ${MNTLINUX}/etc/fstab.new | egrep -v  "none" > ${MNTLINUX}/etc/fstab.renew
854    sed "s|$DEFROOT|$PARTROOT|g" ${MNTLINUX}/etc/fstab.renew > ${MNTLINUX}/etc/fstab
855fi
856
857}
[9c535e0]858
[764f50e]859###
860#En pruebas
861##
862#/**
863#         ogSetLinuxName int_ndisk int_npartition str_name
864#@brief   Establece el nombre del equipo en los ficheros hostname y hosts.
865#@param   int_ndisk      nº de orden del disco
866#@param   int_npartition nº de orden de la partición
867#@param   str_name       nombre asignado
868#@return  (nada)
869#@exception OG_ERR_FORMAT    Formato incorrecto.
870#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
871#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
872#@version .
873#@author 
874#@date   
875#*/ ##
876function ogSetLinuxName ()
877{
878# Variables locales.
879local PART MNTDIR NAME
880
881# Si se solicita, mostrar ayuda.
882if [ "$*" == "help" ]; then
883    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_name" \
884           "$FUNCNAME 1 1 PRACTICA-PC"
885    return
886fi
887# Error si no se reciben 3 parámetros.
888[ $# -ge 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
889
890# Montar el sistema de archivos.
891MNTDIR=$(ogMount $1 $2) 2>/dev/null
892[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
893
894[ $# == 3 ] && NAME="$3" || NAME="$(ogGetHostname)"
895NAME=${NAME:-"pc"}
896
897ETC=$(ogGetPath $1 $2 /etc)
898
899if [ -d "$ETC" ]; then
900        #cambio de nombre en hostname
901        echo "$NAME" >$ETC/hostname 2>/dev/null
902        #Opcion A para cambio de nombre en hosts
903        #sed "/127.0.1.1/ c\127.0.1.1 \t $HOSTNAME" $ETC/hosts > /tmp/hosts && cp /tmp/hosts $ETC/ && rm /tmp/hosts
904        #Opcion B para cambio de nombre en hosts
905cat > $ETC/hosts <<EOF
906127.0.0.1       localhost
907127.0.1.1       $NAME
908
909# The following lines are desirable for IPv6 capable hosts
910::1     ip6-localhost ip6-loopback
911fe00::0 ip6-localnet
912ff00::0 ip6-mcastprefix
913ff02::1 ip6-allnodes
914ff02::2 ip6-allrouters
915EOF
916       
917fi
918
919}
920
[df814dd0]921
922###
923#En pruebas
924##
925#/**
926#         ogCleanLinuxDevices int_ndisk int_npartition
927#@brief   Limpia los dispositivos del equipo de referencia. Interfaz de red ...
928#@param   int_ndisk      nº de orden del disco
929#@param   int_npartition nº de orden de la partición
930#@return  (nada)
931#@exception OG_ERR_FORMAT    Formato incorrecto.
932#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
933#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
934#@version .
935#@author 
936#@date   
937#*/ ##
938function ogCleanLinuxDevices ()
939{
940# Variables locales.
941local PART MNTDIR NAME
942
943# Si se solicita, mostrar ayuda.
944if [ "$*" == "help" ]; then
945    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition " \
946           "$FUNCNAME 1 1 "
947    return
948fi
949# Error si no se reciben 2 parámetros.
950[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
951
952# Montar el sistema de archivos.
953MNTDIR=$(ogMount $1 $2) 2>/dev/null
954[ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $?
955
956ETC=$(ogGetPath $1 $2 /etc)
957
958# Clean old network id in udev configuration
959UDEVNET="${ETC}/udev/rules.d/70-persistent-net.rules"
960[ -f  $UDEVNET ] &&  echo " " > $UDEVNET
961}
962
Note: See TracBrowser for help on using the repository browser.