Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/04/2011, 14:44
SamuraiBlanco
 
Fecha de Ingreso: marzo-2010
Ubicación: Mérida, Venezula
Mensajes: 73
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: Instarlar postgresql despues de muchos errores

Gracias por contestar huesos52. Te cuento, me hice un script python para eliminar todos los archivos que contuvieran postgres o psql, y este fue el resultado:

Código Python:
Ver original
  1. #/usr/bin/env python
  2.  
  3. """
  4. Desinstalador de personalizado de postgresql por
  5. el Ingeniero Victor Teran Herrera.
  6.  
  7. GPL(V3)
  8.  
  9. This program is free software: you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation, either version 3 of the License, or
  12. (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program.  If not, see <http://www.gnu.org/licenses/>
  21. """
  22. from os import remove, system, getcwd, mkdir
  23. from time import sleep
  24. from os.path import isdir, isfile, join
  25. import subprocess
  26.  
  27.  
  28.  
  29. def makelogs(list_noexiste, list_obviados, list_eliminados):
  30.     Dictionary={'not_found':list_noexiste, 'passed':list_obviados, 'deleted':list_eliminados}
  31.     actions={'not_found':'que no existieron', 'passed':'obviados', 'deleted':'eliminados'}
  32.     for x in Dictionary.keys():
  33.         if isfile(join(getcwd(),'postgresql_delete_logs','log_'+x+'.txt'))==False:
  34.            Log=open(join(getcwd(),'postgresql_delete_logs','log_'+x+'.txt'),'w')
  35.            Log.write('Estos son los archivos $action en la ejecucion: \n'.replace("$action", actions[x]))
  36.            for archivo in Dictionary[x]:
  37.                Log.write(archivo + '\n')
  38.            Log.close()
  39.         else:
  40.            Log=open(join(getcwd(),'postgresql_delete_logs','log_'+x+'.txt'),'a')
  41.            for archivo in Dictionary[x]:
  42.                Log.write(archivo + '\n')
  43.            Log.close()
  44.     return
  45.  
  46. def Deleteall(second_list_postgres_clean, firts_list_psql_clean):
  47.     print "Removiendo paquetes obsoletos con aptitude clean"
  48.     print "\n \n \n \n"
  49.     system('aptitude clean')
  50.     print "\n \n \n \n"
  51.     print "Comienza la eliminacion... en tres segundos \n \n"
  52.     sleep(1)
  53.     print "Comienza la eliminacion... en dos segundos \n \n"    
  54.     sleep(1)
  55.     print "Comienza la eliminacion... en un segundo \n \n"
  56.     sleep(1)
  57.     nobviados=0
  58.     neliminados=0
  59.     nnoexiste=0
  60.     list_eliminados=[]
  61.     list_obviados=[]
  62.     list_noexiste=[]
  63.     for lista in (second_list_postgres_clean, firts_list_psql_clean):
  64.         for element in lista:
  65.             element=str(element)
  66.             if isdir(element) or isfile(element):
  67.                 print "Eliminando elemento " + element
  68.                 if element[0:12]=='/home/victor' or element[0:19]=='/usr/lib/pymodules/':
  69.                     print "Elemento obviado " + element
  70.                     nobviados=nobviados+1
  71.                     list_obviados.append(element)
  72.                 else:
  73.                     sleep(1)
  74.                     if isdir(element):
  75.                         system('rm -rf ' +element)
  76.                     elif isfile(element):    
  77.                         remove(element)
  78.                     print "Eliminado " + element
  79.                     neliminados=neliminados+1
  80.                     list_eliminados.append(element)
  81.             else:
  82.                 print "El elemento no existe " + element
  83.                 nnoexiste=nnoexiste+1
  84.                 list_noexiste.append(element)
  85.  
  86.     if isdir('/home/victor/.psql_history'):
  87.         print "Eliminacion forzada /home/victor/.psql_history"  
  88.         remove('/home/victor/.psql_history')
  89.         print "Eliminado"
  90.  
  91.     print "Todos los elementos fueron borrados"
  92.     print "Actualizando catalogo, espere por favor, esto puede tomar algunos minutos"
  93.     system('updatedb')
  94.     print "Elementos inexistentes " +str(nnoexiste)      
  95.     print "Elementos obviados " +str(nobviados)
  96.     print "Elementos Eliminados "+str(neliminados)
  97.     print "Puede revisar los logs en " + join(getcwd(),'postgresql_delete_logs')
  98.     if isdir(join(getcwd(),'postgresql_delete_logs'))==False:
  99.         mkdir('postgresql_delete_logs')
  100.         makelogs(list_noexiste, list_obviados, list_eliminados)
  101.     else:
  102.         makelogs(list_noexiste, list_obviados, list_eliminados)        
  103.     print "Actualizacion terminada, ejecucion terminada"
  104.  
  105. print """ \n\n\n\n\n This program is free software: you can redistribute it and/or modify
  106.    it under the terms of the GNU General Public License as published by
  107.    the Free Software Foundation, either version 3 of the License, or
  108.    (at your option) any later version.
  109.  
  110.    This program is distributed in the hope that it will be useful,
  111.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  112.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  113.    GNU General Public License for more details.
  114.  
  115.    You should have received a copy of the GNU General Public License
  116.    along with this program.  If not, see <http://www.gnu.org/licenses/>
  117.    \n\n\n\n\n
  118.    """
  119.  
  120. print "Buen dia, este es un script para eliminar una instalacion \
  121.       \n corrupta de postgresql\n\n"
  122.  
  123. control=raw_input('Introduzca 1 para continuar, cualquier otra tecla para salir: ')
  124.  
  125. if control==" ":
  126.     print "Saliendo"
  127.  
  128. control=int(control)
  129.  
  130. if control==1:
  131.     print "\n\nComienza adquisicion de datos, esto puede tardar algunos segundos..."    
  132.     elements_psql_tuple=subprocess.Popen("/usr/bin/env locate "+ 'psql', shell=True, \
  133.                     stdout=subprocess.PIPE).communicate()
  134.     string_to_clean=str(elements_psql_tuple)
  135.  
  136.     firts_list_psql_clean=string_to_clean.replace("[","").replace("'","").replace("]","").replace("(","").replace   (")","").split('\\n')
  137.  
  138.     elements_postres_tuple=subprocess.Popen("/usr/bin/env locate "+ 'postgres', shell=True, \
  139.                     stdout=subprocess.PIPE).communicate()
  140.  
  141.     string_to_clean=str(elements_postres_tuple)
  142.  
  143.     second_list_postgres_clean=string_to_clean.replace("[","").replace("'","").replace("]","").replace("(","").replace(")","").split('\\n')
  144.  
  145.     elements=second_list_postgres_clean.extend(firts_list_psql_clean)
  146.    
  147.     Deleteall(second_list_postgres_clean, firts_list_psql_clean)
  148. else:
  149.     print "Saliendo"