[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: (hopefully perl) API to /etc/network/interfaces?



On 05/30/11 at 09:24pm, Mike Mestnik wrote:
> On 05/26/11 18:13, William Hopkins wrote:
> > On 05/26/11 at 05:16pm, Mike Mestnik wrote:
> >> In-Reply-To: <20080412023656.GR14599@yi.org>
> >>
> >> Hello,
> >>   This is an old thread, but I find myself in a similar situation.  I'd
> >> like to edit a 4in6 tunnel endpoint and reconfigure the interface. 
> >> While I can handle the Apache/sudo parts of this I'm stuck with... OK
> >> now how and I going to change this one value out of this whole file?
> >>
> >> My current plan is to convert the file to XML storing away comments and
> >> partial white space as well as the settings.  Then I should be able to
> >> edit the setting a write the file back out.
> >>
> >> Any better ideas?  For this project Perl seams to be the ideal language.
> >>
> >> I may contact the ifupdown maintainer to include this in his package, so
> >> I'm looking to get it done right.
> > Generally, there's no desire for added abstractions to configuration files. 
> > If you need to have network things done automatically which can't be handled by the file itself, add post-ups and write some scripts. Or write scripts which parse current network info from ifconfig/ip. /etc/network/interfaces is a file used by the debian networking scripts to set up your default interfaces, not the be-all end-all of networking configuration. 
> >
> I hadn't though of that.  I was merely trying to automate/script a task
> that was being performed manually.  The task included changing this
> configuration file.  The solution may be to abstract parts of this
> configuration file that would then be updated by scripts/users doing
> things manually.

Oh, I didn't ascribe any evil intentions to what you were doing. Just trying to point out why there might not be a lot of community response to your offer. However, as always I represent no-one but myself (:
 
> I believe you have slightly misunderstood me.  I need(would like to) to
> alter network settings based on CGI scripts from Apache.  Can these
> variables be abstracted?  I don't see how a pre-up script can
> effect/alter configuration settings.  As an example the address or
> gateway settings for a static method.  In my experience I'm specifically
> trying to alter the "endpoint" setting for a "v4tunnel" method.

I don't use IPv6 tunneling myself, so I am unsure. But, for example, you would alter /etc/network/interfaces if you wanted to change a variable permanently. Think of it as a list of saved settings for the interfaces. It's read by the networking scripts, which then run various commands such as ifconfig based on the data there. And for anything the networking scripts can't handle directly, there's the pre/post commands to call external scripts. 
If you only wish to change something once, you would simply run the commands directly (ifconfig, for example).

> I'm just as confused trying to accomplish this as I was when I started. 
> It's something a user can do simple with an editor, but trying to do it
> programing and correctly is my stumbling block.  "IF" I could store the
> value of this setting in a file that would solve my issue, I can replace
> the contents of the file and then proceed as usual.

If you're sure you want to change the permanent setting of something which is currently set in /etc/network/interfaces for setting at boot-time, simply have your script change it. There are a lot of ways to edit text data in linux -- sed is a good option, as are cut, awk, grep, etc. 
 

-- 
Liam

Attachment: signature.asc
Description: Digital signature


Reply to: