View previous topic :: View next topic |
Author |
Message |
Darrell n00b
Joined: 02 Jun 2002 Posts: 1
|
Posted: Sun Jun 02, 2002 2:15 pm Post subject: Update cfg files |
|
|
This gives a diff for you to see then asks if you want to replace the old cfg file. In all cases the new cfg files and backups of your old ones are copied to a backup directory.
Your old ones are backedup only if you decide to change them.
Save this to a cfgUpdate.py file and type "python cfgUpdate.py"
import glob, os, sys, re
pf= os.popen("find /etc -iname '._cfg????_*'")
backDir="/etc/cfgBack/"
os.system("mkdir %s"%backDir)
for l in pf.readlines():
if l.find(backDir) != -1:
continue
l=l.strip()
base=l.split("_")[-1]
newCfg=re.findall("/(._cfg.*)", l)[0]
basePath=re.findall("(.*)/._cfg", l)[0]
cmd="diff -b %s %s/%s"%(l,basePath,base)
backUpCmd="cp %s/%s %s/%s.back"%(basePath,base, basePath, base)
acceptCmd="cp %s %s/%s"%(l, basePath, base)
print '*********************',cmd
res= os.system(cmd)
backUpNewCfg="cp %s %s%s"%(l,backDir, newCfg)
print backUpNewCfg
assert(os.system(backUpNewCfg)==0)
if res==0:
print "Skip"
else:
yn=raw_input("Accept all changes: y/n")
if yn in "Yy":
print 'Backup:', backUpCmd
print 'Do:', acceptCmd
assert(os.system(backUpCmd)==0)
assert(os.system(acceptCmd)==0)
assert(os.system("rm %s"%l)==0) |
|
Back to top |
|
|
alec Apprentice
Joined: 19 Apr 2002 Posts: 270 Location: Here
|
Posted: Sun Jun 02, 2002 2:57 pm Post subject: |
|
|
If you're looking for a polished interface that does the same thing, try emerging gentoolkit and running 'etc-update'. |
|
Back to top |
|
|
The Shadow Surfer Tux's lil' helper
Joined: 08 Jun 2002 Posts: 102 Location: Denmark
|
Posted: Sun Jun 09, 2002 8:29 pm Post subject: I get an error: |
|
|
I get an error:
File "cfgUpdate.py", line 8
if l.lfind(backDir) != -1:
^
IndentationError: expectd an indented block |
|
Back to top |
|
|
alec Apprentice
Joined: 19 Apr 2002 Posts: 270 Location: Here
|
Posted: Mon Jun 10, 2002 2:51 am Post subject: |
|
|
You might need to reemerge it. I've also noticed that some tools like etc-update and ebuild need me to source /etc/profile before they work (when using su from console). |
|
Back to top |
|
|
The Shadow Surfer Tux's lil' helper
Joined: 08 Jun 2002 Posts: 102 Location: Denmark
|
Posted: Mon Jun 10, 2002 10:29 am Post subject: |
|
|
I did an etc-updat, and then it worked
Thanks |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|