source: client/engine/PostConfEAC.lib @ 0e9b60a

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 0e9b60a was b1891c9, checked in by adv <adv@…>, 14 years ago

version 1.0.1 #407 ogSchrootLinux correccion errata

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

  • Property mode set to 100755
File size: 14.1 KB
Line 
1#!/bin/bash
2
3#         ogLoadHiveWindows int_ndisk int_partiton
4#@brief   Localiza los hive del registro de windows (de sistema y usuarios)
5#@param   int_ndisk      nº de orden del disco
6#@param   int_partition     nº de particion
7#@return 
8#@exception OG_ERR_FORMAT    Formato incorrecto.
9#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
10#@version 0.9 - Adaptación a OpenGNSys.
11#@author  Antonio J. Doblas Viso. Universidad de Málaga
12#@date    2009-09-24
13#*/ ##
14
15
16function ogLoadHiveWindows () {
17# Variables locales.
18local PART DISK
19
20# Si se solicita, mostrar ayuda.
21if [ "$*" == "help" ]; then
22    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \
23           "$FUNCNAME 1 1 "
24    return
25fi     
26
27# Error si no se reciben 2 parámetros.
28[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
29
30DISK=$1; PART=$2;
31
32#Comprobaciones redundantes: borrar"
33#ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows no detectada"; echo $?)
34#ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?)
35#VERSION=$(ogGetOsVersion $DISK $PART)
36#Fin Comprobaciones redundantes: borrar"
37
38if ogGetPath $DISK $PART WINDOWS
39then
40        SYSTEMROOT="Windows"
41elif ogGetPath $DISK $PART WINNT
42then
43        SYSTEMROOT="winnt"
44else
45        return $(ogRaiseError $OG_ERR_NOTOS "version windows no detectada"; echo $?)
46fi
47
48hiveSAM=$(ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/SAM) && export hiveSAM || return $(ogRaiseError $OG_ERR_NOTOS " hive SAM  no detectada"; echo $?)
49hiveSYSTEM=$(ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/system) && export hiveSYSTEM || return $(ogRaiseError $OG_ERR_NOTOS "hive SYSTEM  no detectada"; echo $?)
50hiveSOFTWARE=$(ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/software) && export hiveSOFTWARE || return $(ogRaiseError $OG_ERR_NOTOS "hive SOFTWARE no detectada"; echo $?)
51export TEMPhive=/tmp/tmpregistry
52
53## borrar elementos de la primera integracion
54#export particion=`ogMount $DISK $PART`
55#mkfifo pipe 2>/dev/null
56#declare -i count
57#declare -A HivePathUser
58#count=3
59# fin borrar elementos de la primera integracion
60
61declare -i COUNT
62COUNT=3
63BASEHOMEDIR=$(ogGetPath 1 1 /"Documents and Settings")
64TMPUSERFILE="/tmp/WuserRegAndDAT.tmp"
65find "$BASEHOMEDIR/" -type f -name NTUSER.DAT > $TMPUSERFILE 
66LISTUSERS=$(drbl-chntpw -l $hiveSAM | grep RID | awk -F"<" '{print $2}' | awk -F">" '{print $1}')
67#echo "$BASEHOMEDIR" $LISTUSERS
68for user in $LISTUSERS
69do     
70        # borrar elementos de la primera integracion.
71                #if find ${particion}/ -type f -name NTUSER.DAT > pipe| cat pipe | grep $user > /tmp/path.txt.$count
72                #then
73                #echo pefil de $user encontrado, para utilizar este usuario con funciones utilizar id_hive= $count o \$usuario
74                #read camino < /tmp/path.txt.$count
75                #echo $camino | sed -e 's/ /\\ /g' > /tmp/path.txt.$count
76                #camino2=$(echo $camino | sed -e 's/ /\\ /g')
77                #echo $camino2 | sed -e 's/\\/\\\\/g' > /tmp/path.txt.$count
78                #export `echo $user=hiveUSER$count`
79                #export `echo hiveUSER$count`="$camino2"
80                #count=${count}+1
81                #fiecho $user
82    # Fin borrar elementos de la primera integracion.
83       
84        # Comprobamos que el usuario registrado tiene .DAT
85                if HOMEDIR=$(cat $TMPUSERFILE | grep -w $user) 
86                then
87                        #echo "$user exportamos los usuarios de windows como variables, y como valor hiveUSERX; donde la X es 3 4 5 6 ... X"
88                        export `echo $user=hiveUSER$COUNT`
89                        #echo "$user exportamos la variable hiveUSERX con el valor del home de la variable-usuario_windows"
90                        ##export `echo hiveUSER$COUNT`="$(echo $HOMEDIR | sed -e 's/ /\\ /'g | sed -e 's/\\/\\\\/g')"
91                        export `echo hiveUSER$COUNT`="$(echo $HOMEDIR)"
92                        #echo " estas variables \$USUARIO -> Identificador del HIVE ; \${!USUARIO} -> path del HIVE "
93                        COUNT=${COUNT}+1
94                fi
95               
96done
97COUNT=0
98}
99
100
101#         ogUpdateHiveWindows 
102#@brief   Actualiza los hive de windows.
103#@param   int_ndisk       
104#@param   int_partition     
105#@return 
106#@exception OG_ERR_FORMAT    Formato incorrecto.
107#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
108#@version 0.9 - Adaptación a OpenGNSys.
109#@author  Antonio J. Doblas Viso. Universidad de Málaga
110#@date    2009-09-24
111#*/ ##
112
113
114function ogUpdateHiveWindows (){
115# Variables locales.
116local PART DISK FILE
117
118#TODO detectar llamada a ogLoadHiveWindows
119
120# Si se solicita, mostrar ayuda.
121if [ "$*" == "help" ]; then
122    ogHelp "$FUNCNAME" "$FUNCNAME " \
123           "$FUNCNAME  "
124    return
125fi     
126
127echo drbl-chntpw -f $TEMPhive $hiveSAM $hiveSYSTEM $hiveSOFTWARE \"${hiveUSER3}\" \"${hiveUSER4}\" \"${hiveUSER5}\" \"${hiveUSER6}\" \"${hiveUSER7}\" \"${hiveUSER8}\" \"${hiveUSER9}\" > /tmp/run.sh
128cat /tmp/run.sh; sh /tmp/run.sh; rm -fr $TEMPhive; rm /tmp/run.sh
129
130unset hiveSAM hiveSYSTEM hiveSOFTWARE TEMPhive hiveUSER3 hiveUSER4 hiveUSER5 hiveUSER6 hiveUSER7 hiveUSER8 hiveUSER9
131 
132
133}
134
135
136
137function ogHiveNTRunMachine () {
138#echo sintaxis:  PathScripts idScripts
139#echo ejemplo:   c:\\\\WINDOSWS\\\\crearusuarios.bat  scripts1
140#echo IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\
141#echo "identifica 0=$hiveSAM 1=$hiveSystem 2=$hiveSoftware 3=$HiveUser3"
142
143local PART DISK FILE
144
145# Si se solicita, mostrar ayuda.
146if [ "$*" == "help" ]; then
147    ogHelp "$FUNCNAME" "$FUNCNAME PathScripts|command keyName " \
148           "$FUNCNAME c:\\\\Windows\\\\crearusuarios.cmd scripts_crearUsuarios "\
149           "$FUNCNAME "cmd /c del c:\ogboot.*" ogcleanboot "\
150           "$FUNCNAME Requiere la previa ejecución de ogLoadHive int_disk int_part"\
151           "$FUNCNAME Despues requiere el ogUpdateHive"
152    return
153fi     
154       
155
156# Error si no se reciben al menos 1 parámetros.
157[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)   
158
159
160cat >> $TEMPhive << EOF
161h 2
162cd \Microsoft\Windows\CurrentVersion\Run
163nv 1 $2
164ed $2
165$1
166EOF
167#ogGetRegistryValue /mnt/sda1 software '\Microsoft\Windows\CurrentVersion\Run\og3'
168}
169
170function ogNTPolUserOn () {
171
172# Si se solicita, mostrar ayuda.
173if [ "$*" == "help" ]; then
174    ogHelp "$FUNCNAME" "$FUNCNAME id_hive_user " \
175           "$FUNCNAME NombreUsuario"\
176           "$FUNCNAME "
177    return
178fi             
179
180# TODO: error si no se ha llamado previamente a ogLoadHiveWindows
181[ -n $hiveSAM ] || return $(ogRaiseError $OG_ERR_FORMAT "se debe utilizar primero la utilidad ogLoadHiveWindows"; echo $?)
182
183# TODO: error si el usuario no tiene cuenta en windows.
184drbl-chntpw -l $hiveSAM | grep RID | grep -w $1 || return $(ogRaiseError $OG_ERR_FORMAT "el usuario $1 no tiene cuenta en este windows: Compruebe mayusculas o minusculas"; echo $?)
185
186# TODO: error si no el usario no no tiene HIVE asociado.
187[ -n "${!1}" ] || return $(ogRaiseError $OG_ERR_FORMAT "el usuario no tiene hive creado"; echo $?)
188
189
190HIVEID=$(echo ${!1} | tr -d "hiveUSER")
191
192
193#echo "IMPORTANTE:  la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat"
194echo $HIVEID
195#cp /var/EAC/admin/utilswin/Fondo.BMP ${particion}/WINDOWS/
196
197cat >> $TEMPhive << EOF
198h $HIVEID
199cd \Control Panel\Desktop
200ed Wallpaper
201C:\\WINDOWS\\fondo.bmp
202
203cd \Software\Microsoft\Windows\CurrentVersion\Policies
204nk Explorer
205cd Explorer
206
207nv 4 NoDesktop
208ed NoDesktop
2091
210
211nv 4 NoSimpleStartMenu
212ed NoSimpleStartMenu
2131
214nv 4 NoWindowsUpdate
215ed NoWindowsUpdate
2161
217
218nv 4 NoSMConfigurePrograms
219ed NoSMConfigurePrograms
2201
221
222nv 4 NoChangeStartMenu
223ed NoChangeStartMenu
2241
225
226nv 4 Intellimenus
227ed Intellimenus
2281
229
230nv 4 NoRun
231ed NoRun
2321
233
234nv 4 NoRecentDocsHistory
235ed NoRecentDocsHistory
2361
237EOF
238}
239
240
241
242
243
244##########################################################
245##########################################################
246#####librerias de PostConfiguracion v0.1para Advanced Deploy enViorenment###########
247# Liberado bajo licencia GPL <http://www.gnu.org/licenses/gpl.html>################
248############# 2008 Antonio Jes�s Doblas Viso  adv@uma.es ##########################
249########### Universidad de Malaga (Spain)############################
250##########################################################
251
252
253
254
255
256function NTChangeName () {
257if [ $# = 0 ]
258then
259echo sintaxis: NTChangeNAME str_$var
260echo ejemplos: NTCHangeName adi${IPcuatro}-xp
261fi
262cat >> $temporal << EOF
263h 1
264ed ControlSet001\Control\ComputerName\ComputerName\ComputerName
265$1
266ed ControlSet001\Services\Tcpip\Parameters\Hostname
267$1
268ed ControlSet001\Services\Tcpip\Parameters\NV Hostname
269$1
270h 2
271cd \Microsoft\Windows NT\CurrentVersion\Winlogon
272ed DefaultDomainName
273$1
274EOF
275}
276
277
278
279function NTSetGroupName () {
280if [ $# = 0 ]
281then
282echo sintaxis: NTSetGroupName str_$var
283echo ejemplos: NTSetGroupName adi
284fi
285cat >> $temporal << EOF
286h 2
287ed \Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName
288$1
289EOF
290}
291
292
293function NTSetOwner (){
294if [ $# = 0 ]
295then
296echo sintaxis: NtSetOwner str_propietario str_organizacion
297echo ejemplos: NTSetOwner eu\ politecnica universidad\ de\ malaga
298fi
299cat >> $temporal << EOF
300h 2
301ed \Microsoft\Windows NT\CurrentVersion\RegisteredOwner
302$1
303ed \Microsoft\Windows NT\CurrentVersion\RegisteredOrganization
304$2
305EOF
306}
307
308
309function NTAutoLogon (){
310if [ $# = 0 ]
311then
312echo sintaxis: Int_Activar Int_nves str_usuario str_passwd str_equipo
313echo ejemplos: 1 2 administrador 3451 $equipo
314echo IMPORTANTE: cuando AutoLogonCount llegue a 0, activa el AutoAdminLogon a 0. Pero no borra los valores de DefaultPassword
315return 2
316fi
317echo la pass es $4
318export temporal=/tmp/tmpregistry
319cat >> $temporal << EOF
320hive 2
321cd \Microsoft\Windows NT\CurrentVersion\Winlogon
322nv 1 AutoAdminLogon
323ed AutoAdminLogon
324$1
325nv 1 AutoLogonCount
326ed AutoLogonCount
327$2
328nv 1 DefaultUserName
329ed DefaultUserName
330$3
331nv 1 DefaultDomainName
332ed DefaultDomainName
333$5
334EOF
335if [ "$4" == none ]
336then
337echo "debe aparecer done" $4
338cat >> $temporal << EOF
339dv DefaultPassword
340
341
342EOF
343else
344cat >> $temporal << EOF
345nv 1 DefaultPassword
346ed DefaultPassword
347$4
348EOF
349fi
350}
351
352function NTStatusRatonTeclado (){
353if [ $# = 0 ]
354then
355echo sintaxis: Int-StatusRaton Int-StatusTeclado
356echo ejemplos:  int=1 activo   int=4 desactivado
357return 2
358fi
359cat >> $temporal << EOF
360hive 1
361cd \ControlSet001\Services\Mouclass
362ed Start
363$1
364cd \ControlSet001\Services\Kbdclass
365ed Start
366$2
367EOF
368}
369
370function NTRunOnceMachine () {
371if [ $# = 0 ]
372then
373echo sintaxis:  PathScripts idScripts
374echo "ejemplo:   c:\\\\WINDOSWS\\\\crearusuarios.bat  scripts1"
375echo "IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\"
376return 2
377fi
378export temporal=/tmp/tmpregistry
379cat >> $temporal << EOF
380h 2
381cd \Microsoft\Windows\CurrentVersion\RunOnce
382nv 1 $2
383ed $2
384$1
385EOF
386}
387
388function NTRunMachine () {
389if [ $# = 0 ]
390then
391echo sintaxis:  PathScripts idScripts
392echo ejemplo:   c:\\\\WINDOSWS\\\\crearusuarios.bat  scripts1
393echo IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\
394return 2
395fi
396export temporal=/tmp/tmpregistry
397cat >> $temporal << EOF
398h 2
399cd \Microsoft\Windows\CurrentVersion\Run
400nv 1 $2
401ed $2
402$1
403EOF
404}
405
406function NTRunUser () {
407if [ $# = 0 ]
408then
409echo sintaxis:  str_PathWINScripts str_idScripts Int_hive||\$usuario
410echo ejemplo:   c:\\\\WINDOSWS\\\\crearusuarios.bat  scripts1 3
411echo IMPORTANTE: el pathWIN debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\
412echo IMPORTANTE: el pathLinux si lleva espacios debe escaparse con una barra \\
413echo IMPORTANTE Int_hive: 3 para el primer usuario, 4 para el segundo usuario
414echo requiere export un HiveUser3=/mnt/windows/Document\ and\ Seeting\alumnmos\NTUSER.dat
415return 2
416fi
417cat >> $temporal << EOF
418h $3
419cd \Software\Microsoft\Windows\CurrentVersion\Run
420nv 1 $2
421ed $2
422$1
423EOF
424}
425
426
427
428function NTPolUserOn () {
429if [ $# = 0 ]
430then
431Msg "requiere LoadRegistryUser str_user1 str_user2..." orange
432echo "sintaxis:  Int_hive"
433echo "ejemplo: NTPolUserOn 3"
434echo "IMPORTANTE:  la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat"
435return 2
436fi
437cp /var/EAC/admin/utilswin/Fondo.BMP ${particion}/WINDOWS/
438cat >> $temporal << EOF
439h $1
440cd \Control Panel\Desktop
441ed Wallpaper
442C:\\WINDOWS\\fondo.bmp
443
444cd \Software\Microsoft\Windows\CurrentVersion\Policies
445nk Explorer
446cd Explorer
447
448nv 4 NoDesktop
449ed NoDesktop
4501
451
452nv 4 NoSimpleStartMenu
453ed NoSimpleStartMenu
4541
455nv 4 NoWindowsUpdate
456ed NoWindowsUpdate
4571
458
459nv 4 NoSMConfigurePrograms
460ed NoSMConfigurePrograms
4611
462
463nv 4 NoChangeStartMenu
464ed NoChangeStartMenu
4651
466
467nv 4 Intellimenus
468ed Intellimenus
4691
470
471nv 4 NoRun
472ed NoRun
4731
474
475nv 4 NoRecentDocsHistory
476ed NoRecentDocsHistory
4771
478EOF
479}
480
481function NTPolUserOFF () {
482if [ $# = 0 ]
483then
484Msg "requiere LoadRegistryUser str_user1 str_user2..." orange
485echo "sintaxis:  Int_hive"
486echo "ejemplo: NTPolUserOFF 3"
487echo "IMPORTANTE:  la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat"
488return 2
489fi
490cat >> $temporal << EOF
491h $1
492cd \Control Panel\Desktop
493ed Wallpaper
494C:\\WINDOWS\\web\\wallpaper\\Felicidad.bmp
495
496cd \Software\Microsoft\Windows\CurrentVersion\
497rdel Policies
498nk Policies
4991
500EOF
501}
502
503
504function NTStatusBootChk () {
505if [ $# = 0 ]
506then
507echo sintaxis: Int-Status
508echo ejemplos:  int=0 desactivado int=1 activado
509return 2
510fi
511[ $1 = 0 ] && valor="none"
512[ $1 = 1 ] && valor="autocheck autochk *"
513cat >> $temporal << EOF
514hive 1
515cd \ControlSet001\Control\Session Manager
516ed BootExecute
517$valor
518--n
519EOF
520}
521
522
523function ogSchrootLinux () {
524
525# Variables locales.
526local PART DISK DIRCONF SCHROOTDEVICE
527
528# Si se solicita, mostrar ayuda.
529if [ "$*" == "help" ]; then
530    ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \
531           "$FUNCNAME 1 1 "
532    return
533fi     
534
535# Error si no se reciben 2 parámetros.
536[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
537
538DISK=$1; PART=$2; DIRCONF="/etc/schroot"
539
540
541VERSION=$(ogGetOsVersion $DISK $PART)
542echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
543
544ogUnmount $DISK $PART || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
545
546SCHROOTDEVICE=$(ogDiskToDev $DISK $PART)
547
548
549rm ${DIRCONF}/mount-defaults
550rm ${DIRCONF}/schroot.conf
551
552cat >> ${DIRCONF}/mount-defaults << EOF
553# <file system> <mount point>   <type>  <options>       <dump>  <pass>
554proc            /proc           proc    defaults        0       0
555/dev            /dev            none    rw,bind         0       0
556/dev/pts        /dev/pts        none    rw,bind         0       0
557/dev/shm        /dev/shm        none    rw,bind         0       0
558EOF
559
560
561cat >> ${DIRCONF}/schroot.conf << EOF
562[linux]
563description=$VERSION
564type=block-device
565device=$SCHROOTDEVICE
566EOF
567
568
569
570
571schroot -c linux
572
573schroot -end-sessiona --all-sessions
574}
575
Note: See TracBrowser for help on using the repository browser.