#! /usr/bin/python # (c) 2005 Shrift # etcconfig for Frugalware # distributed under GPL License # version 0.1 import os,sys paclist=[] editorvars=['EDITOR','ETCONFIG_EDITOR'] editors=['vi','emacs','nano'] a_editors=[] def checkroot(): uid=os.geteuid() if uid == 0: print print"-- EtcUpdater --" print else: print"Sorry, you must be root to run this script." sys.exit() def checkedit(): p=0 for i in editorvars[:2]: act=os.getenv(i,1) if(act==1): print "- $%s is not accessible!" % i else: print "- $%s is accessible!" % i a_editors.append('$'+i) for i in os.walk('/usr/bin'): files=(i[2]) for s in files: if s in editors: a_editors.append(s) print "- Found %s as an alternative editor" % s else: continue if len(sys.argv) > 1: if sys.argv[1] in ('-v', '--version'): print "etcconfig 0.1 (pacman-tools)" sys.exit() elif sys.argv[1] in ('-h', '--help'): os.system("man etcconfig") sys.exit() checkroot() checkedit() if '$EDITOR' in a_editors: if '$ETCONFIG_EDITOR' in a_editors: editor='$ETCONFIG_EDITOR' else: editor='$EDITOR' elif '$ETCONFIG_EDITOR' in a_editors: editor='$ETCONFIG_EDITOR' else: editor=a_editors.pop() print "- Using <%s> as an editor -" % editor print '-'*17 print ' Searching...' print '-'*17 for i in os.walk('/etc'): files=(i[2]) for s in files: if s.endswith(".pacnew"): s=i[0]+'/'+s paclist.append(s) print "Found %s adding to list" % s else: continue print '-'*17 print 'Searching done...' print '-'*17 print choices=['y','n','d','e','i'] m=len(paclist) x=0 if len(paclist)==0: print('--> There are no new config files available for updating!') else: print('-->[(y=update) (n=delete .pacnew) (d=diff old) (e=edit) (i=ignore)]<--') while x