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