source: client/engine/Registry.lib.testing @ 22542c6

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 22542c6 was 1b804cc, checked in by ramon <ramongomez@…>, 14 years ago

versión 1.0.2: plantillas para crear nuevas funciones para gestión del registro de Windows.

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

  • Property mode set to 100755
File size: 7.6 KB
Line 
1#!/bin/bash
2#/**
3#@file    Registry.lib
4#@brief   Librería o clase Registry
5#@class   Boot
6#@brief   Funciones para gestión del registro de Windows.
7#@version 1.0.1
8#@warning License: GNU GPLv3+
9#*/
10
11
12#/**
13#         ogAddRegistryKey path_mountpoint str_hive str_keyname
14#@brief   Añade una nueva clave al registro de Windows.
15#@version 1.0.1 - Nueva función
16#@author  Ramon Gomez, ETSII Universidad de Sevilla
17#@date    2011-05-18
18#*/ ##
19function ogAddRegistryKey ()
20{
21}
22
23#/**
24#         ogAddRegistryValue path_mountpoint str_hive str_valuename str_valuedata
25#@brief   Añade un nuevo valor (dupla nombre/valor) al registro de Windows.
26#@version 1.0.1 - Nueva función
27#@author  Ramon Gomez, ETSII Universidad de Sevilla
28#@date    2011-05-18
29#*/ ##
30function ogAddRegistryValue ()
31{
32}
33
34
35#/**
36#         ogChangeRegistryKey path_mountpoint str_hive str_keyname
37#@brief   Modifica el nombre de una clave al registro de Windows.
38#@version 1.0.1 - Nueva función
39#@author  Ramon Gomez, ETSII Universidad de Sevilla
40#@date    2011-05-18
41#*/ ##
42function ogChangeRegistryKey ()
43{
44}
45
46#/**
47#         ogChangeRegistryValue path_mountpoint str_hive str_valuename str_valuedata
48#@brief   Modifica el nombre de un valor (dupla nombre/valor) al registro de Windows.
49#@version 1.0.1 - Nueva función
50#@author  Ramon Gomez, ETSII Universidad de Sevilla
51#@date    2011-05-18
52#*/ ##
53function ogChangeRegistryValue ()
54{
55}
56
57
58#/**
59#         ogDeleteRegistryKey path_mountpoint str_hive str_keyname
60#@brief   Elimina una clave del registro de Windows con todo su contenido.
61#@version 1.0.1 - Nueva función
62#@author  Ramon Gomez, ETSII Universidad de Sevilla
63#@date    2011-05-20
64#*/ ##
65function ogDeleteRegistryKey ()
66{
67}
68
69#/**
70#         ogDeleteRegistryValue path_mountpoint str_hive str_valuename str_valuedata
71#@brief   Elimina un valor del registro de Windows.
72#@version 1.0.1 - Nueva función
73#@author  Ramon Gomez, ETSII Universidad de Sevilla
74#@date    2011-05-20
75#*/ ##
76function ogDeleteRegistryValue ()
77{
78}
79
80
81#/**
82#         ogGetHivePath path_mountpoint str_hive
83#@brief   Función básica que devuelve el camino del fichero con una sección del registro.
84#@param   path_mountpoint  directorio donde está montado el sistema Windows
85#@param   str_hive         sección del registro
86#@return  str_path - camino del fichero de registro
87#@exception OG_ERR_FORMAT    Formato incorrecto.
88#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositivo.
89#@note    hive = { default, sam, security, software, system, components }
90#@warning El sistema de archivos de Windows debe estar montada previamente.
91#@version 1.0.1 - Nueva función
92#@author  Ramon Gomez, ETSII Universidad de Sevilla
93#@date    2011-05-18
94#*/ ##
95function ogGetHivePath ()
96{
97# Variables locales.
98local FILE FILENT FILEXP
99
100# Si se solicita, mostrar ayuda.
101if [ "$*" == "help" ]; then
102    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive"
103    return
104fi
105# Error si no se reciben 2 parámetros.
106[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
107
108# Camino del fichero de registro en NT/2000 o XP/Vista/7.
109FILENT=$(ogGetPath "/$1/winnt/system32/config/$2")
110[ -f $FILENT ] && FILE="$FILENT"
111FILEXP=$(ogGetPath "/$1/windows/system32/config/$2")
112[ -f $FLEHXP ] && FILE="$FILEXP"
113[ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $?
114
115echo "$FILE"
116}
117
118
119#/**
120#         ogGetRegistryValue path_mountpoint str_hive str_valuename
121#@brief   Devuelve el dato de un valor del registro de Windows.
122#@param   path_mountpoint  directorio donde está montado el sistema Windows
123#@param   str_hive         sección del registro
124#@param   str_valuename    nombre del valor
125#@return  str_valuedata - datos del valor.
126#@exception OG_ERR_FORMAT    Formato incorrecto.
127#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositivo.
128#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
129#@note    hive = { default, sam, security, software, system, components }
130#@warning Requisitos: chntpw, awk
131#@warning La partición de Windows debe estar montada previamente.
132#@version 0.9 - Adaptación para OpenGNSys.
133#@author  Ramon Gomez, ETSII Universidad de Sevilla
134#@date    2009-09-11
135#*/ ##
136function ogGetRegistryValue ()
137{
138# Variables locales.
139local FILE
140
141# Si se solicita, mostrar ayuda.
142if [ "$*" == "help" ]; then
143    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename"
144    return
145fi
146# Error si no se reciben 3 parámetros.
147[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
148
149# Camino del fichero de registro.
150FILE=$(ogGetHivePath "$1" "$2") || return $?
151
152# Devolver el dato del valor de registro.
153# /* (comentario Doxygen)
154chntpw $FILE << FIN 2>/dev/null | awk '/> Value/ {getline;print $0;}'
155cd ${3%\\*}
156cat ${3##*\\}
157q
158FIN
159# (comentario Doxygen) */
160}
161
162
163#/**
164#         ogListRegistryKey path_mountpoint str_hive str_key
165#@brief   Lista los nombres de claves de una determinada clave del registro de Windows.
166#@param   path_mountpoint  directorio donde está montado el sistema Windows
167#@param   str_hive         sección del registro
168#@param   str_key          clave de registro
169#@return  str_subkey ... - lista de subclaves
170#@exception OG_ERR_FORMAT    Formato incorrecto.
171#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
172#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
173#@note    hive = { default, sam, security, software, system, components }
174#@warning Requisitos: chntpw, awk
175#@warning La partición de Windows debe estar montada previamente.
176#@version 0.9 - Adaptación para OpenGNSys.
177#@author  Ramon Gomez, ETSII Universidad de Sevilla
178#@date    2009-09-23
179#@version 1.0.1 - Renombrada de ogListRegistryKeys
180#@author  Ramon Gomez, ETSII Universidad de Sevilla
181#@date    2011-05-18
182#*/ ##
183function ogListRegistryKey ()
184{
185# Variables locales.
186local FILE
187
188# Si se solicita, mostrar ayuda.
189if [ "$*" == "help" ]; then
190    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key"
191    return
192fi
193# Error si no se reciben 3 parámetros.
194[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
195
196# Camino del fichero de registro.
197FILE=$(ogGetHivePath "$1" "$2") || return $?
198
199# Devolver la lista de claves de registro.
200chntpw $FILE << FIN 2>/dev/null | awk 'BEGIN {FS="[<>]"} $1~/^  $/ {print $2}'
201ls $3
202q
203FIN
204}
205
206
207#/**
208#         ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
209#@brief   Establece el dato asociado a un valor del registro de Windows.
210#@param   path_mountpoint  directorio donde está montado el sistema Windows
211#@param   str_hive         tipo de registro
212#@param   str_valuename    nombre del valor de registro
213#@param   str_valuedata    dato del valor de registro
214#@return  (nada)
215#@exception OG_ERR_FORMAT    Formato incorrecto.
216#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositivo.
217#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
218#@note    hive = { default, sam, security, software, system, components }
219#@warning Requisitos: chntpw, awk
220#@warning La partición de Windows debe estar montada previamente.
221#@version 0.9 - Adaptación para OpenGNSys.
222#@author  Ramon Gomez, ETSII Universidad de Sevilla
223#@date    2009-09-24
224#*/ ##
225function ogSetRegistryValue ()
226{
227# Variables locales.
228local FILE
229
230# Si se solicita, mostrar ayuda.
231if [ "$*" == "help" ]; then
232    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data"
233    return
234fi
235# Error si no se reciben 4 parámetros.
236[ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $?
237
238# Camino del fichero de registro.
239FILE=$(ogGetHivePath "$1" "$2") || return $?
240
241# Cambiar el dato del valor de registro.
242chntpw $FILE << FIN &>/dev/null
243ed $3
244$4
245q
246y
247FIN
248}
249
Note: See TracBrowser for help on using the repository browser.