[b094c59] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | #@file Boot.lib |
---|
| 4 | #@brief Librería o clase Boot |
---|
| 5 | #@class Boot |
---|
| 6 | #@brief Funciones para arranque y post-configuración de sistemas de archivos. |
---|
| 7 | #@version 0.9 |
---|
| 8 | #@warning License: GNU GPLv3+ |
---|
| 9 | #*/ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | #/** |
---|
| 13 | # ogBoot int_ndisk int_npartition |
---|
| 14 | #@brief Inicia el proceso de arranque de un sistema de archivos. |
---|
[42669ebf] | 15 | #@param int_ndisk nº de orden del disco |
---|
| 16 | #@param int_npartition nº de orden de la partición |
---|
[b094c59] | 17 | #@return (activar el sistema de archivos). |
---|
| 18 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 19 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 20 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 21 | #@exception OG_ERR_NOTOS La partición no tiene instalado un sistema operativo. |
---|
[f5432db7] | 22 | #@note En Linux, debe arrancarse la partición del directorio \c /boot |
---|
| 23 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
[b094c59] | 24 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 25 | #@date 2009-09-11 |
---|
[1e7eaab] | 26 | #*/ ## |
---|
[42669ebf] | 27 | function ogBoot () |
---|
| 28 | { |
---|
[b094c59] | 29 | # Variables locales. |
---|
[326cec3] | 30 | local PART TYPE MNTDIR PARAMS KERNEL INITRD APPEND FILE LOADER |
---|
[b094c59] | 31 | |
---|
[1e7eaab] | 32 | # Si se solicita, mostrar ayuda. |
---|
[b094c59] | 33 | if [ "$*" == "help" ]; then |
---|
| 34 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 35 | "$FUNCNAME 1 1" |
---|
| 36 | return |
---|
| 37 | fi |
---|
[1e7eaab] | 38 | # Error si no se reciben 2 parámetros. |
---|
[b094c59] | 39 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 40 | |
---|
[1e7eaab] | 41 | # Detectar tipo de sistema de archivos y montarlo. |
---|
[049eadbe] | 42 | PART=$(ogDiskToDev $1 $2) || return $? |
---|
[b094c59] | 43 | TYPE=$(ogGetFsType $1 $2) || return $? |
---|
[f5432db7] | 44 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
| 45 | [ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $? |
---|
[b094c59] | 46 | |
---|
| 47 | case "$TYPE" in |
---|
[049eadbe] | 48 | EXT[234]|REISERFS|REISER4|JFS|XFS) |
---|
[1e7eaab] | 49 | # Obtiene los parámetros de arranque para Linux. |
---|
[f5432db7] | 50 | PARAMS=$(ogLinuxBootParameters $1 $2) || return $? |
---|
| 51 | read -e KERNEL INITRD APPEND <<<"$PARAMS" |
---|
[1e7eaab] | 52 | # Si no hay kernel, no hay sistema operativo. |
---|
[f5432db7] | 53 | [ -z "$KERNEL" ] && ogRaiseError $OG_ERR_NOTOS && return $? |
---|
[1e7eaab] | 54 | # Arrancar de partición distinta a la original. |
---|
[049eadbe] | 55 | [ -e "$MNTDIR/etc" ] && APPEND=$(echo $APPEND | awk -v P="$PART " '{sub (/root=[-+=_/a-zA-Z0-9]* /,"root="P);print}') |
---|
[f5432db7] | 56 | # Configurar kernel Linux con los parámetros leídos de su GRUB. |
---|
[049eadbe] | 57 | kexec -l "${MNTDIR}${KERNEL}" --append="$APPEND" --initrd="${MNTDIR}${INITRD}" |
---|
[f5432db7] | 58 | ;; |
---|
| 59 | NTFS|HNTFS|FAT32|HFAT32) |
---|
[1e7eaab] | 60 | # Compruebar si hay un cargador de Windows. |
---|
[f5432db7] | 61 | for f in io.sys ntldr bootmgr; do |
---|
| 62 | FILE="$(ogGetPath $1 $2 $f 2>/dev/null)" |
---|
[d10549b] | 63 | [ -n "$FILE" ] && LOADER="$f" |
---|
[f5432db7] | 64 | done |
---|
| 65 | [ -z "$LOADER" ] && ogRaiseError $OG_ERR_NOTOS && return $? |
---|
| 66 | # Activar la partición y copiar Grub4DOS. |
---|
| 67 | ogSetPartitionActive $1 $2 |
---|
[1e7eaab] | 68 | cp $OGLIB/grub4dos/* $MNTDIR # */ (Comentario Doxygen) |
---|
[d10549b] | 69 | #kexec -l $MNTDIR/grub.exe --append=--config-file="find --set-root /$LOADER; chainloader /$LOADER; tpm --init" |
---|
| 70 | kexec -l $MNTDIR/grub.exe --append=--config-file="root (hd$[$1-1],$[$2-1]); chainloader (hd$[$1-1],$[$2-1])/$LOADER; tpm --init" |
---|
[f5432db7] | 71 | ;; |
---|
| 72 | *) ogRaiseError $OG_ERR_PARTITION "$1, $2" |
---|
[326cec3] | 73 | return $? |
---|
[f5432db7] | 74 | ;; |
---|
[b094c59] | 75 | esac |
---|
| 76 | |
---|
[1e7eaab] | 77 | # Arrancar. |
---|
[b094c59] | 78 | kexec -e |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | #/** |
---|
[3e1561d] | 83 | # ogGetRegistryValue path_mountpoint str_registrytype str_valuename |
---|
| 84 | #@brief Devuelve el dato de un valor del registro de Windows. |
---|
[42669ebf] | 85 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 86 | #@param str_registrytype tipo de registro a leer |
---|
| 87 | #@param str_valuename valor de registro |
---|
[3e1561d] | 88 | #@return str_valuedata - valor de la clave. |
---|
[055adcf] | 89 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[f5432db7] | 90 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
[055adcf] | 91 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 92 | #@note registrytype = { default, sam, security, software, system, components } |
---|
| 93 | #@warning Requisitos: chntpw, awk |
---|
| 94 | #@warning La partición de Windows debe estar montada previamente. |
---|
[f5432db7] | 95 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
[055adcf] | 96 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 97 | #@date 2009-09-11 |
---|
[1e7eaab] | 98 | #*/ ## |
---|
[42669ebf] | 99 | function ogGetRegistryValue () |
---|
| 100 | { |
---|
[055adcf] | 101 | # Variables locales. |
---|
[50a094c] | 102 | local FILE FILENT FILEXP |
---|
[055adcf] | 103 | |
---|
[1e7eaab] | 104 | # Si se solicita, mostrar ayuda. |
---|
[055adcf] | 105 | if [ "$*" == "help" ]; then |
---|
| 106 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_registrytype str_key" |
---|
| 107 | return |
---|
| 108 | fi |
---|
[1e7eaab] | 109 | # Error si no se reciben 3 parámetros. |
---|
[055adcf] | 110 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 111 | |
---|
[1e7eaab] | 112 | # Camino del fichero de registro en NT/2000 o XP/Vista/7. |
---|
[055adcf] | 113 | FILENT=$(ogGetPath "/$1/winnt/system32/config/$2") |
---|
[945b003] | 114 | [ -f $FILENT ] && FILE="$FILENT" |
---|
[055adcf] | 115 | FILEXP=$(ogGetPath "/$1/windows/system32/config/$2") |
---|
[945b003] | 116 | [ -f $FLEHXP ] && FILE="$FILEXP" |
---|
[055adcf] | 117 | [ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $? |
---|
| 118 | |
---|
[1e7eaab] | 119 | # Devolver el dato del valor de registro. |
---|
| 120 | # /* (comentario Doxygen) |
---|
[055adcf] | 121 | chntpw $FILE << FIN 2>/dev/null | awk '/> Value/ {getline;print $0;}' |
---|
| 122 | cd ${3%\\*} |
---|
| 123 | cat ${3##*\\} |
---|
| 124 | q |
---|
| 125 | FIN |
---|
[42669ebf] | 126 | # (comentario Doxygen) */ |
---|
[055adcf] | 127 | } |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | #/** |
---|
[3e1561d] | 131 | # ogGetWindowsName int_ndisk int_npartition |
---|
| 132 | #@brief Muestra el nombre del equipo en el registro de Windows. |
---|
[42669ebf] | 133 | #@param int_ndisk nº de orden del disco |
---|
| 134 | #@param int_npartition nº de orden de la partición |
---|
[3e1561d] | 135 | #@return str_name - nombre del equipo |
---|
| 136 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 137 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 138 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
[f5432db7] | 139 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
[3e1561d] | 140 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 141 | #@date 2009-09-23 |
---|
[1e7eaab] | 142 | #*/ ## |
---|
[42669ebf] | 143 | function ogGetWindowsName () |
---|
| 144 | { |
---|
[3e1561d] | 145 | # Variables locales. |
---|
| 146 | local PART MNTDIR |
---|
| 147 | |
---|
[1e7eaab] | 148 | # Si se solicita, mostrar ayuda. |
---|
[3e1561d] | 149 | if [ "$*" == "help" ]; then |
---|
| 150 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 151 | "$FUNCNAME 1 1 ==> PRACTICA-PC" |
---|
| 152 | return |
---|
| 153 | fi |
---|
[1e7eaab] | 154 | # Error si no se reciben 2 parámetros. |
---|
[3e1561d] | 155 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 156 | |
---|
[1e7eaab] | 157 | # Montar el sistema de archivos. |
---|
[f5432db7] | 158 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
| 159 | [ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $? |
---|
[3e1561d] | 160 | |
---|
[1e7eaab] | 161 | # Obtener dato del valor de registro. |
---|
[3e1561d] | 162 | ogGetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName' |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | #/** |
---|
[50a094c] | 167 | # ogListRegistryKeys path_mountpoint str_registrytype str_key |
---|
[3e1561d] | 168 | #@brief Lista los nombres de claves de una determinada clave del registro de Windows. |
---|
[42669ebf] | 169 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 170 | #@param str_registrytype tipo de registro a leer |
---|
| 171 | #@param str_key clave de registro |
---|
| 172 | #@return str_key ... - lista de claves de registro |
---|
[50a094c] | 173 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 174 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 175 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 176 | #@note registrytype = { default, sam, security, software, system, components } |
---|
| 177 | #@warning Requisitos: chntpw, awk |
---|
| 178 | #@warning La partición de Windows debe estar montada previamente. |
---|
[f5432db7] | 179 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
[50a094c] | 180 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 181 | #@date 2009-09-23 |
---|
[1e7eaab] | 182 | #*/ ## |
---|
[42669ebf] | 183 | function ogListRegistryKeys () |
---|
| 184 | { |
---|
[50a094c] | 185 | # Variables locales. |
---|
| 186 | local FILE FILENT FILEXP |
---|
| 187 | |
---|
[1e7eaab] | 188 | # Si se solicita, mostrar ayuda. |
---|
[50a094c] | 189 | if [ "$*" == "help" ]; then |
---|
| 190 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_registrytype str_key" |
---|
| 191 | return |
---|
| 192 | fi |
---|
[1e7eaab] | 193 | # Error si no se reciben 3 parámetros. |
---|
[50a094c] | 194 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 195 | |
---|
[1e7eaab] | 196 | # Camino del fichero de registro en NT/2000 o XP/Vista/7. |
---|
[50a094c] | 197 | FILENT=$(ogGetPath "/$1/winnt/system32/config/$2") |
---|
[945b003] | 198 | [ -f $FILENT ] && FILE="$FILENT" |
---|
[50a094c] | 199 | FILEXP=$(ogGetPath "/$1/windows/system32/config/$2") |
---|
[945b003] | 200 | [ -f $FLEHXP ] && FILE="$FILEXP" |
---|
[50a094c] | 201 | [ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $? |
---|
| 202 | |
---|
[1e7eaab] | 203 | # Devolver la lista de claves de registro. |
---|
[50a094c] | 204 | chntpw $FILE << FIN 2>/dev/null | awk 'BEGIN {FS="[<>]"} $1~/^ $/ {print $2}' |
---|
| 205 | ls $3 |
---|
| 206 | q |
---|
| 207 | FIN |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | #/** |
---|
[4c63eb9] | 212 | # ogLinuxBootParameters int_ndisk int_npartition |
---|
[b094c59] | 213 | #@brief Muestra los parámetros de arranque de un sistema de archivos Linux. |
---|
[42669ebf] | 214 | #@param int_ndisk nº de orden del disco |
---|
| 215 | #@param int_npartition nº de orden de la partición |
---|
| 216 | #@return str_kernel str_initrd str_parameters ... |
---|
[b094c59] | 217 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 218 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 219 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
[055adcf] | 220 | #@warning Función básica usada por \c ogBoot |
---|
| 221 | #@version 0.9 - Primera adaptación para OpenGNSys. |
---|
[b094c59] | 222 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 223 | #@date 2009-09-11 |
---|
[1e7eaab] | 224 | #*/ ## |
---|
[42669ebf] | 225 | function ogLinuxBootParameters () |
---|
| 226 | { |
---|
[b094c59] | 227 | # Variables locales. |
---|
[4c63eb9] | 228 | local MNTDIR CONF |
---|
[b094c59] | 229 | |
---|
[1e7eaab] | 230 | # Si se solicita, mostrar ayuda. |
---|
[b094c59] | 231 | if [ "$*" == "help" ]; then |
---|
| 232 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 233 | "$FUNCNAME 1 2 ==> ..." |
---|
| 234 | return |
---|
| 235 | fi |
---|
[1e7eaab] | 236 | # Error si no se reciben 2 parámetros. |
---|
[b094c59] | 237 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 238 | |
---|
[1e7eaab] | 239 | # Detectar id. de tipo de partición y codificar al mnemonico. |
---|
[f5432db7] | 240 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
| 241 | [ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $? |
---|
[b094c59] | 242 | |
---|
| 243 | # Fichero de configuración de GRUB. |
---|
| 244 | CONF="$MNTDIR/boot/grub/menu.lst" |
---|
[ee4a96e] | 245 | [ ! -e $CONF ] && CONF="$MNTDIR/boot/grub/grub.cfg" |
---|
| 246 | [ ! -e $CONF ] && ogRaiseError $OG_ERR_NOTFOUND "grub.cfg" && return $? |
---|
[b094c59] | 247 | |
---|
[1e7eaab] | 248 | # Toma del fichero de configuracion los valores del kernel, initrd |
---|
[ee4a96e] | 249 | # y parámetros de arranque usando las cláusulas por defecto |
---|
| 250 | # ("default" en GRUB1, "set default" en GRUB2) |
---|
| 251 | # y los formatea para que sean compatibles con \c kexec . */ |
---|
[1e7eaab] | 252 | # /* (comentario Doxygen) |
---|
[b094c59] | 253 | awk 'BEGIN {cont=-1;} |
---|
| 254 | $1~/^default/ {sub(/=/," "); def=$2;} |
---|
[18f4bc2] | 255 | $1~/^set/ && $2~/^default/ {gsub(/[="]/," "); def=$3;} |
---|
[ee4a96e] | 256 | $1~/^title|^menuentry/ {cont++} |
---|
| 257 | $1~/^kernel|^linux/ {if (def==cont) { |
---|
[b094c59] | 258 | kern=$2; |
---|
[1e7eaab] | 259 | sub($1,"");sub($1,"");sub(/^[ \t]*/,"");app=$0} # /* (comentario Doxygen) |
---|
[b094c59] | 260 | } |
---|
| 261 | $1~/^initrd/ {if (def==cont) init=$2} |
---|
| 262 | END {if (kern!="") printf("%s %s %s", kern,init,app)} |
---|
| 263 | ' $CONF |
---|
[1e7eaab] | 264 | # */ (comentario Doxygen) |
---|
[b094c59] | 265 | } |
---|
| 266 | |
---|
[3e1561d] | 267 | |
---|
| 268 | |
---|
| 269 | #/** |
---|
| 270 | # ogSetRegistryValue path_mountpoint str_registrytype str_valuename str_valuedata |
---|
| 271 | #@brief Establece el dato asociado a un valor del registro de Windows. |
---|
[42669ebf] | 272 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
| 273 | #@param str_registrytype tipo de registro |
---|
| 274 | #@param str_valuename nombre del valor de registro |
---|
| 275 | #@param str_valuedata dato del valor de registro |
---|
[3e1561d] | 276 | #@return (nada) |
---|
| 277 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
[f5432db7] | 278 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
[3e1561d] | 279 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 280 | #@note registrytype = { default, sam, security, software, system, components } |
---|
| 281 | #@warning Requisitos: chntpw, awk |
---|
| 282 | #@warning La partición de Windows debe estar montada previamente. |
---|
[f5432db7] | 283 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
[3e1561d] | 284 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 285 | #@date 2009-09-24 |
---|
[1e7eaab] | 286 | #*/ ## |
---|
[42669ebf] | 287 | function ogSetRegistryValue () |
---|
| 288 | { |
---|
[3e1561d] | 289 | # Variables locales. |
---|
| 290 | local FILE FILENT FILEXP |
---|
| 291 | |
---|
[42669ebf] | 292 | # Si se solicita, mostrar ayuda. |
---|
[3e1561d] | 293 | if [ "$*" == "help" ]; then |
---|
| 294 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_registrytype str_key" |
---|
| 295 | return |
---|
| 296 | fi |
---|
[42669ebf] | 297 | # Error si no se reciben 4 parámetros. |
---|
[3e1561d] | 298 | [ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 299 | |
---|
[42669ebf] | 300 | # Camino del fichero de registro en NT/2000 o XP/Vista/7. |
---|
[3e1561d] | 301 | FILENT=$(ogGetPath "/$1/winnt/system32/config/$2") |
---|
[945b003] | 302 | [ -f $FILENT ] && FILE="$FILENT" |
---|
[3e1561d] | 303 | FILEXP=$(ogGetPath "/$1/windows/system32/config/$2") |
---|
[945b003] | 304 | [ -f $FLEHXP ] && FILE="$FILEXP" |
---|
[3e1561d] | 305 | [ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $? |
---|
| 306 | |
---|
[42669ebf] | 307 | # Cambiar el dato del valor de registro. |
---|
[f5432db7] | 308 | chntpw $FILE << FIN &>/dev/null |
---|
[3e1561d] | 309 | ed $3 |
---|
| 310 | $4 |
---|
| 311 | q |
---|
| 312 | y |
---|
| 313 | FIN |
---|
| 314 | } |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | #/** |
---|
| 318 | # ogSetWindowsName int_ndisk int_npartition str_name |
---|
| 319 | #@brief Establece el nombre del equipo en el registro de Windows. |
---|
[42669ebf] | 320 | #@param int_ndisk nº de orden del disco |
---|
| 321 | #@param int_npartition nº de orden de la partición |
---|
| 322 | #@param str_name nombre asignado |
---|
[3e1561d] | 323 | #@return (nada) |
---|
| 324 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 325 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 326 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
[f5432db7] | 327 | #@version 0.9 - Adaptación a OpenGNSys. |
---|
[3e1561d] | 328 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
| 329 | #@date 2009-09-24 |
---|
[1e7eaab] | 330 | #*/ ## |
---|
[42669ebf] | 331 | function ogSetWindowsName () |
---|
| 332 | { |
---|
[3e1561d] | 333 | # Variables locales. |
---|
| 334 | local PART MNTDIR NAME |
---|
| 335 | |
---|
[1e7eaab] | 336 | # Si se solicita, mostrar ayuda. |
---|
[3e1561d] | 337 | if [ "$*" == "help" ]; then |
---|
| 338 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \ |
---|
| 339 | "$FUNCNAME 1 1 PRACTICA-PC" |
---|
| 340 | return |
---|
| 341 | fi |
---|
[1e7eaab] | 342 | # Error si no se reciben 3 parámetros. |
---|
[3e1561d] | 343 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 344 | |
---|
[42669ebf] | 345 | # Montar el sistema de archivos. |
---|
[f5432db7] | 346 | MNTDIR=$(ogMount $1 $2) 2>/dev/null |
---|
| 347 | [ -z "$MNTDIR" ] && ogRaiseError OG_ERR_PARTITION "$1, $2" && return $? |
---|
[3e1561d] | 348 | NAME="$3" |
---|
| 349 | |
---|
[1e7eaab] | 350 | # Modificar datos de los valores de registro. |
---|
[f5432db7] | 351 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Control\ComputerName\ComputerName\ComputerName' "$NAME" |
---|
| 352 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\Hostname' "$NAME" |
---|
| 353 | ogSetRegistryValue $MNTDIR system '\ControlSet001\Services\Tcpip\Parameters\NV Hostname' "$NAME" |
---|
[3e1561d] | 354 | } |
---|
| 355 | |
---|
[f5432db7] | 356 | |
---|
[38231e9] | 357 | |
---|
| 358 | #/** |
---|
| 359 | # ogNewMbrXP int_ndisk |
---|
| 360 | #@brief Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows |
---|
[42669ebf] | 361 | #@param int_ndisk nº de orden del disco |
---|
[945b003] | 362 | #@return salida del programa my-sys |
---|
[38231e9] | 363 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
| 364 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
| 365 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
| 366 | #@version 0.9 - Adaptación a OpenGNSys. |
---|
| 367 | #@author Antonio J. Doblas Viso. Universidad de Málaga |
---|
| 368 | #@date 2009-09-24 |
---|
| 369 | #*/ ## |
---|
| 370 | |
---|
| 371 | function ogNewMbrXP () { |
---|
| 372 | # Variables locales. |
---|
| 373 | local PART |
---|
| 374 | |
---|
| 375 | # Si se solicita, mostrar ayuda. |
---|
| 376 | if [ "$*" == "help" ]; then |
---|
| 377 | ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk " \ |
---|
| 378 | "$FUNCNAME 1 " |
---|
| 379 | return |
---|
[945b003] | 380 | fi |
---|
[38231e9] | 381 | # Error si no se reciben 1 parámetros. |
---|
| 382 | [ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
| 383 | |
---|
[6e139c9] | 384 | PART="$(ogDiskToDev $1)" || return $? |
---|
[38231e9] | 385 | ms-sys -z -f $PART |
---|
| 386 | ms-sys -m -f $PART |
---|
[945b003] | 387 | } |
---|
[42669ebf] | 388 | |
---|