[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 | #/** |
---|
[0b85cc93] | 264 | # ogBootMbrXP int_ndisk |
---|
[9f577259] | 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 | |
---|
[0b85cc93] | 275 | function ogBootMbrXP () |
---|
[9f577259] | 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 | |
---|
[0b85cc93] | 295 | #/** |
---|
| 296 | # ogBootMbrGeneric int_ndisk |
---|
| 297 | #@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux. |
---|
| 298 | #@param int_ndisk nº de orden del disco |
---|
| 299 | #@return salida del programa my-sys |
---|
| 300 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 301 | #@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar. |
---|
| 302 | #@version 0.9 - Adaptación a OpenGNSys. |
---|
| 303 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 304 | #@date 2009-09-24 |
---|
| 305 | #*/ ## |
---|
| 306 | |
---|
| 307 | function ogBootMbrGeneric () |
---|
| 308 | { |
---|
| 309 | # Variables locales. |
---|
| 310 | local PART |
---|
| 311 | |
---|
| 312 | # Si se solicita, mostrar ayuda. |
---|
| 313 | if [ "$*" == "help" ]; then |
---|
| 314 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \ |
---|
| 315 | "$FUNCNAME 1 " |
---|
| 316 | return |
---|
| 317 | fi |
---|
| 318 | # Error si no se reciben 1 parámetros. |
---|
| 319 | [ $# == 1 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
---|
| 320 | |
---|
| 321 | PART="$(ogDiskToDev $1)" || return $(ogRaiseError $OG_ERR_NOTFOUND; echo $?) |
---|
| 322 | ms-sys -z -f $PART |
---|
| 323 | ms-sys -s -f $PART |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | |
---|
[1b804cc] | 327 | #/** |
---|
| 328 | # ogFixBootSector int_ndisk int_parition |
---|
| 329 | #@brief Corrige el boot sector de una particion activa para MS windows/dos -fat-ntfs |
---|
| 330 | #@param int_ndisk nº de orden del disco |
---|
| 331 | #@param int_partition nº de particion |
---|
| 332 | #@return |
---|
| 333 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 334 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 335 | #@version 0.9 - Adaptación a OpenGNSys. |
---|
| 336 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 337 | #@date 2009-09-24 |
---|
| 338 | #*/ ## |
---|
| 339 | |
---|
| 340 | function ogFixBootSector () |
---|
| 341 | { |
---|
| 342 | # Variables locales. |
---|
| 343 | local PART DISK FILE |
---|
| 344 | |
---|
| 345 | # Si se solicita, mostrar ayuda. |
---|
| 346 | if [ "$*" == "help" ]; then |
---|
| 347 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \ |
---|
| 348 | "$FUNCNAME 1 1 " |
---|
| 349 | return |
---|
| 350 | fi |
---|
| 351 | |
---|
| 352 | # Error si no se reciben 2 parámetros. |
---|
| 353 | [ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
---|
| 354 | |
---|
| 355 | #TODO, solo si la particion existe |
---|
| 356 | #TODO, solo si es ntfs o fat |
---|
| 357 | PARTYPE=$(ogGetPartitionId $1 $2) |
---|
| 358 | case $PARTYPE in |
---|
| 359 | 1|4|6|7|b|c|e|f) |
---|
| 360 | ;; |
---|
| 361 | *) |
---|
| 362 | return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
---|
| 363 | ;; |
---|
| 364 | esac |
---|
| 365 | |
---|
| 366 | ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
---|
| 367 | |
---|
| 368 | #Preparando instruccion |
---|
| 369 | let DISK=$1-1 |
---|
| 370 | PART=$2 |
---|
| 371 | FILE=/tmp/temporal |
---|
| 372 | cat > $FILE <<EOF |
---|
| 373 | disk=$DISK |
---|
| 374 | main_part=$PART |
---|
| 375 | fix_first_sector=yes |
---|
| 376 | EOF |
---|
| 377 | |
---|
| 378 | spartlnx.run -cui -nm -a -f $FILE |
---|
| 379 | |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | |
---|
| 383 | #/** |
---|
| 384 | # ogWindowsBootParameters int_ndisk int_parition |
---|
| 385 | #@brief Configura el gestor de arranque de windows 7 / vista |
---|
| 386 | #@param int_ndisk nº de orden del disco |
---|
| 387 | #@param int_partition nº de particion |
---|
| 388 | #@return |
---|
| 389 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 390 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 391 | #@version 0.9 - Adaptación a OpenGNSys. |
---|
| 392 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 393 | #@date 2009-09-24 |
---|
| 394 | #*/ ## |
---|
| 395 | |
---|
| 396 | |
---|
| 397 | function ogWindowsBootParameters () |
---|
| 398 | { |
---|
| 399 | # Variables locales. |
---|
| 400 | local PART DISK FILE |
---|
| 401 | |
---|
| 402 | # Si se solicita, mostrar ayuda. |
---|
| 403 | if [ "$*" == "help" ]; then |
---|
| 404 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition " \ |
---|
| 405 | "$FUNCNAME 1 1 " |
---|
| 406 | return |
---|
| 407 | fi |
---|
| 408 | |
---|
| 409 | # Error si no se reciben 2 parámetros. |
---|
| 410 | [ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
---|
| 411 | |
---|
| 412 | ogDiskToDev $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
---|
| 413 | |
---|
| 414 | VERSION=$(ogGetOsVersion $1 $2) |
---|
| 415 | |
---|
| 416 | if echo $VERSION | grep "Windows 7" |
---|
| 417 | then |
---|
| 418 | WINVER="Windows 7" |
---|
| 419 | elif echo $VERSION | grep "Windows Seven" |
---|
| 420 | then |
---|
| 421 | WINVER="Windows Vista" |
---|
| 422 | else |
---|
| 423 | return $(ogRaiseError $OG_ERR_NOTOS; echo $?) |
---|
| 424 | fi |
---|
| 425 | |
---|
| 426 | ogUnmount $1 $2 || return $(ogRaiseError $OG_ERR_PARTITION; echo $?) |
---|
| 427 | #Preparando instruccion |
---|
| 428 | let DISK=$1-1 |
---|
| 429 | PART=$2 |
---|
| 430 | FILE=/tmp/temporal |
---|
| 431 | |
---|
| 432 | #Preparando instruccion Windows Resume Application |
---|
| 433 | cat > $FILE <<EOF |
---|
| 434 | boot_disk=$DISK |
---|
| 435 | boot_main_part=$PART |
---|
| 436 | disk=$DISK |
---|
| 437 | main_part=$PART |
---|
| 438 | boot_entry=Windows Resume Application |
---|
| 439 | EOF |
---|
| 440 | spartlnx.run -cui -nm -w -f $FILE |
---|
| 441 | |
---|
| 442 | #Preparando instruccion tipo windows |
---|
| 443 | cat > $FILE <<EOF |
---|
| 444 | boot_disk=$DISK |
---|
| 445 | boot_main_part=$PART |
---|
| 446 | disk=$DISK |
---|
| 447 | main_part=$PART |
---|
| 448 | boot_entry=$WINVER |
---|
| 449 | EOF |
---|
| 450 | spartlnx.run -cui -nm -w -f $FILE |
---|
| 451 | |
---|
| 452 | #Preparando instruccion Ramdisk Options |
---|
| 453 | cat > $FILE <<EOF |
---|
| 454 | boot_disk=$DISK |
---|
| 455 | boot_main_part=$PART |
---|
| 456 | disk=$DISK |
---|
| 457 | main_part=$PART |
---|
| 458 | boot_entry=Ramdisk Options |
---|
| 459 | EOF |
---|
| 460 | spartlnx.run -cui -nm -w -f $FILE |
---|
| 461 | |
---|
| 462 | #Preparando instruccion Windows Boot Manager |
---|
| 463 | cat > $FILE <<EOF |
---|
| 464 | boot_disk=$DISK |
---|
| 465 | boot_main_part=$PART |
---|
| 466 | disk=$DISK |
---|
| 467 | main_part=$PART |
---|
| 468 | boot_entry=Windows Boot Manager |
---|
| 469 | EOF |
---|
| 470 | spartlnx.run -cui -nm -w -f $FILE |
---|
| 471 | |
---|
| 472 | #Preparando instruccion Herramienta de diagnóstico de memoria de Windows |
---|
| 473 | #cat > $FILE <<EOF |
---|
| 474 | #boot_disk=$DISK |
---|
| 475 | #boot_main_part=$PART |
---|
| 476 | #disk=$DISK |
---|
| 477 | #main_part=$PART |
---|
| 478 | #boot_entry=Herramienta de diagnóstico de memoria de Windows |
---|
| 479 | #EOF |
---|
| 480 | #spartlnx.run -cui -nm -w -f $FILE |
---|
| 481 | |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | |
---|
[0b85cc93] | 485 | # ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition |
---|
[1b804cc] | 486 | #@brief Registra una partición en windows con un determinado volumen. |
---|
| 487 | #@param int_ndisk nº de orden del disco a registrar |
---|
| 488 | #@param int_partition nº de particion a registrar |
---|
| 489 | #@param str_volumen volumen a resgistar |
---|
| 490 | #@param int_ndisk_windows nº de orden del disco donde esta windows |
---|
| 491 | #@param int_partition_windows nº de particion donde esta windows |
---|
| 492 | #@return |
---|
| 493 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 494 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 495 | #@version 0.9 - Adaptación a OpenGNSys. |
---|
| 496 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 497 | #@date 2009-09-24 |
---|
| 498 | #*/ ## |
---|
| 499 | |
---|
| 500 | |
---|
[0b85cc93] | 501 | function ogWindowsRegisterPartition () |
---|
[1b804cc] | 502 | { |
---|
| 503 | # Variables locales. |
---|
| 504 | local PART DISK FILE |
---|
| 505 | |
---|
| 506 | # Si se solicita, mostrar ayuda. |
---|
| 507 | if [ "$*" == "help" ]; then |
---|
| 508 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk_TO_registre int_partition_TO_registre str_NewVolume int_disk int_parition " \ |
---|
| 509 | "$FUNCNAME 1 1 c: 1 1" |
---|
| 510 | return |
---|
| 511 | fi |
---|
| 512 | |
---|
| 513 | # Error si no se reciben 5 parámetros. |
---|
| 514 | [ $# == 5 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) |
---|
| 515 | |
---|
| 516 | REGISTREDDISK=$1 |
---|
| 517 | REGISTREDPART=$2 |
---|
| 518 | REGISTREDVOL=$(echo $3 | cut -c1 | tr '[:lower:]' '[:upper:]') |
---|
| 519 | DISK=$4 |
---|
| 520 | PART=$5 |
---|
| 521 | FILE=/tmp/temporal |
---|
| 522 | |
---|
| 523 | ogDiskToDev $REGISTREDDISK $REGISTREDPART || return $(ogRaiseError $OG_ERR_PARTITION "particion a registrar "; echo $?) |
---|
| 524 | ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows"; echo $?) |
---|
| 525 | |
---|
| 526 | ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?) |
---|
| 527 | |
---|
| 528 | VERSION=$(ogGetOsVersion $DISK $PART) |
---|
| 529 | |
---|
| 530 | #Systemroot |
---|
| 531 | |
---|
| 532 | if ogGetPath $DISK $PART WINDOWS |
---|
| 533 | then |
---|
| 534 | SYSTEMROOT="Windows" |
---|
| 535 | elif ogGetPath $DISK $PART WINNT |
---|
| 536 | then |
---|
| 537 | SYSTEMROOT="winnt" |
---|
| 538 | else |
---|
| 539 | return $(ogRaiseError $OG_ERR_NOTOS; echo $?) |
---|
| 540 | fi |
---|
| 541 | |
---|
| 542 | ogUnmount $DISK $PART |
---|
| 543 | let DISK=$DISK-1 |
---|
| 544 | let REGISTREDDISK=$REGISTREDDISK-1 |
---|
| 545 | #Preparando instruccion Windows Boot Manager |
---|
| 546 | cat > $FILE <<EOF |
---|
| 547 | windows_disk=$DISK |
---|
| 548 | windows_main_part=$PART |
---|
| 549 | windows_dir=$SYSTEMROOT |
---|
| 550 | disk=$REGISTREDDISK |
---|
| 551 | main_part=$REGISTREDPART |
---|
| 552 | ;ext_part |
---|
| 553 | part_letter=$REGISTREDVOL |
---|
| 554 | EOF |
---|
| 555 | spartlnx.run -cui -nm -u -f $FILE |
---|
| 556 | } |
---|