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