Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Update cfg files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Darrell
n00b
n00b


Joined: 02 Jun 2002
Posts: 1

PostPosted: Sun Jun 02, 2002 2:15 pm    Post subject: Update cfg files Reply with quote

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
View user's profile Send private message
alec
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 270
Location: Here

PostPosted: Sun Jun 02, 2002 2:57 pm    Post subject: Reply with quote

If you're looking for a polished interface that does the same thing, try emerging gentoolkit and running 'etc-update'.
Back to top
View user's profile Send private message
The Shadow Surfer
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2002
Posts: 102
Location: Denmark

PostPosted: Sun Jun 09, 2002 8:29 pm    Post subject: I get an error: Reply with quote

I get an error:

File "cfgUpdate.py", line 8
if l.lfind(backDir) != -1:
^
IndentationError: expectd an indented block
Back to top
View user's profile Send private message
alec
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 270
Location: Here

PostPosted: Mon Jun 10, 2002 2:51 am    Post subject: Reply with quote

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
View user's profile Send private message
The Shadow Surfer
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2002
Posts: 102
Location: Denmark

PostPosted: Mon Jun 10, 2002 10:29 am    Post subject: Reply with quote

I did an etc-updat, and then it worked ;-)

Thanks ;-)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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