* [gentoo-dev] A script to help in updating configuration files
@ 2001-09-06 4:40 Einar Karttunen
2001-09-06 8:42 ` Daniel Robbins
0 siblings, 1 reply; 4+ messages in thread
From: Einar Karttunen @ 2001-09-06 4:40 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
Hello
The script is very simple, but I hope it
will help someone...
- Einar Karttunen
[-- Attachment #2: etc-update --]
[-- Type: text/plain, Size: 902 bytes --]
#!/usr/bin/env spython
# Einar Karttunen 9.6.2001 <ekarttun@cs.helsinki.fi>
# this file must be distributed under GNU GPL
import os
import sys
if os.getuid()!=0:
print "!!! etc-update must be run by root"
sys.exit(1)
import commands
import portage
import string
import re
if not portage.settings["CONFIG_PROTECT"]:
print "no CONFIG_PROTECTed directories"
sys.exit(2)
req = re.compile('\._cfg\d\d\d\d_')
for d in string.split(portage.settings["CONFIG_PROTECT"]):
if os.path.isdir(d):
r = commands.getstatusoutput("find "+d+" -iname '._cfg????_*'")
if r[0] == 0:
for file in string.split(r[1]):
path, bare = re.split(req,file)
bare = path + bare
print "new: "+file+" orig: "+bare
os.system("diff -Bbs "+file+" "+bare)
r = raw_input("overwrite old "+bare+" with new? [yN] ")
if r == 'y':
os.system('mv -fv '+file+' '+bare)
else:
print "error in 'find'"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] A script to help in updating configuration files
2001-09-06 4:40 [gentoo-dev] A script to help in updating configuration files Einar Karttunen
@ 2001-09-06 8:42 ` Daniel Robbins
2001-09-06 9:45 ` Einar Karttunen
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Robbins @ 2001-09-06 8:42 UTC (permalink / raw
To: gentoo-dev
On Thu, Sep 06, 2001 at 01:39:11PM +0300, Einar Karttunen wrote:
> Hello
>
> The script is very simple, but I hope it
> will help someone...
>
> - Einar Karttunen
Neat! I'll try it out and probably use it as a base for our config
management update system. Thank you very much and please continue
working on it and posting updates when you have made significant
improvements to the previous version.
Best Regards,
--
Daniel Robbins <drobbins@gentoo.org>
Chief Architect/President http://www.gentoo.org
Gentoo Technologies, Inc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] A script to help in updating configuration files
2001-09-06 8:42 ` Daniel Robbins
@ 2001-09-06 9:45 ` Einar Karttunen
2001-09-06 10:00 ` Daniel Robbins
0 siblings, 1 reply; 4+ messages in thread
From: Einar Karttunen @ 2001-09-06 9:45 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
On Thu, Sep 06, 2001 at 08:41:49AM -0600, Daniel Robbins wrote:
> On Thu, Sep 06, 2001 at 01:39:11PM +0300, Einar Karttunen wrote:
> > Hello
> >
> > The script is very simple, but I hope it
> > will help someone...
> >
> > - Einar Karttunen
>
> Neat! I'll try it out and probably use it as a base for our config
> management update system. Thank you very much and please continue
> working on it and posting updates when you have made significant
> improvements to the previous version.
I added some more functionality to it so it can be used
better. It even has a minimal help :-)
- Einar Karttunen
[-- Attachment #2: etc-update --]
[-- Type: text/plain, Size: 1345 bytes --]
#!/usr/bin/env spython
# Einar Karttunen 9.6.2001 <ekarttun@cs.helsinki.fi>
# this file must be distributed under GNU GPL
# version 0.02
import os
import sys
if os.getuid()!=0:
print "!!! etc-update must be run by root"
sys.exit(1)
import commands
import portage
import string
import re
if not portage.settings["CONFIG_PROTECT"]:
print "no CONFIG_PROTECTed directories"
sys.exit(2)
def diff(old, new):
print "new: "+new+" old: "+old
os.system("diff -Bbs "+new+" "+old)
req = re.compile('\._cfg\d\d\d\d_')
for d in string.split(portage.settings["CONFIG_PROTECT"]):
if os.path.isdir(d):
r = commands.getstatusoutput("find "+d+" -iname '._cfg????_*'")
if r[0] == 0:
for file in string.split(r[1]):
path, bare = re.split(req,file)
bare = path + bare
diff(file, bare)
while 1:
r = raw_input("overwrite old "+bare+" with new? [?drNy] ").lower()
if r == 'y':
os.system('mv -fv '+file+' '+bare)
elif r== 'd':
os.remove(file)
elif r== 'r':
diff(file, bare)
continue
elif r== '?':
print """
? display this help
d delete the NEW file
r print the diff another time
N do nothing (the deault)
y replace old with new
remember you can use CTRL-Z to suspend and inspect the situation more closely
"""
continue
break
else:
print "error in 'find'"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] A script to help in updating configuration files
2001-09-06 9:45 ` Einar Karttunen
@ 2001-09-06 10:00 ` Daniel Robbins
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Robbins @ 2001-09-06 10:00 UTC (permalink / raw
To: gentoo-dev
On Thu, Sep 06, 2001 at 06:44:34PM +0300, Einar Karttunen wrote:
> I added some more functionality to it so it can be used
> better. It even has a minimal help :-)
>
> - Einar Karttunen
OK; I'm in the process of adding some additional functionality too.
I tweaked the version you sent over so that it has colorized diffs.
I'll merge in your new additions and post the result sometime tomorrow.
Please continue to enhance your script as you have time.
Best Regards,
--
Daniel Robbins <drobbins@gentoo.org>
Chief Architect/President http://www.gentoo.org
Gentoo Technologies, Inc.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-09-06 15:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-06 4:40 [gentoo-dev] A script to help in updating configuration files Einar Karttunen
2001-09-06 8:42 ` Daniel Robbins
2001-09-06 9:45 ` Einar Karttunen
2001-09-06 10:00 ` Daniel Robbins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox