Help - Search - Members - Calendar
Full Version: Modifying Config Files... Dynamically..
Linuxhelp > Support > Technical Support
thaigrrrrl
I am currently on a project where I have to edit the following files via Perl/ HTML/ Web interface.

resolv.conf
main.cf
transport.cf
ifcfg-eth0
and
network

I was asked to do this, I am not a sysadmin, i'm a Perl programmer.

What will happen if I edit these files while the system is up and running? Will they go into effect immediately?

will I need to restart?

will the whole system crash and crumble beneath my feet?

please tell me your wisdom !

thanks

TG
Jim
They wont go into effect untill they are re-loaded. You can either do that be restarting the programs using them, or with a full system restart.

And your system will not crumble benieth your feet unless you typo or screw something up. So here are a few tricks. '
1) Always Copy the file first
cp file file.old
2) Double check before saving
3) Save before editing
4) Double check before saving

You should be fine. The only problem your going to have is since your doing this remotely if you reboot the system and it doesn't boot your screwed. I would recomend restarting each individual process one by one, if it doesn't work you can just replace the file with the one you backed up.
cp file.old file

I don't kno what processes use all of those files, so maybe someone else can help you out with the restart commands, it might not even be possible with out a fool reboot.
petterg
If you're changing networksettings remotely you should probably schedule a restore job (cp file.old file && reboot) to start 15 minutes after you restart the network service. In case you screw up the system will restore it self after 15 minutes, and you'll be able to try again. In case you do not screw up you'll have 15 minutes to cancel the scheduled job.
Corey
QUOTE (petterg @ May 6 2004, 05:56 AM)
If you're changing networksettings remotely you should probably schedule a restore job (cp file.old file && reboot) to start 15 minutes after you restart the network service. In case you screw up the system will restore it self after 15 minutes, and you'll be able to try again. In case you do not screw up you'll have 15 minutes to cancel the scheduled job.

That's a great idea, perhaps you would be willing to write out a step-by-step process of this and posting it into our Tips & Tricks forum, i'm sure other people would find this information useful.

Another idea would perhaps be to make a wrapper-script for editing network config files, that would automatically setup this 15 revert unless stopped by the admin. Could save a lot of headaches for people.
hughesjr
You would have to restart the services effected .... or restart the computer (which I don't like to do).

looks like network and postfix would need to be the only things restarted ....

Usually, this would require only:

/etc/init.d/network restart

and

/etc/init.d/postfix restart

(unless postfix is being started by another program ... like mailscanner)
---------------------
Like petterg said though, making changes to the network and ifcfg-eth0 remotely is dangerous ... what if the services don't restart?

It might be very good indeed to schedule a program in cron to check the connectivity after restarting the services ... and if it broken, restore the old files and restart the network service.
--------------------
Restarting services (or rebooting the computer) via a web interface itself is pretty tricky ... since the apache user is the user who would run things .... and allowing the apache user to start and stop system services (or reboot the server) is not good.
thaigrrrrl
Thanks so much guys, I really appreciate the advice. I don't need to worry about the restart remotely.

Get this: the reason why they want this interface is because they are windows network admins trying to administrate a linux box, they don't know the commands to move freely in linux or how to find files.

Since they are going to be installing boxes at their clients, they wanted an easy set up interface dry.gif dumbasses...

:-D but thanks for your help ... linux gurus are the best smile.gif
Jim
Ok, one linux isn't that hard. Two, why are they so afraid of learning a little bit here and there? Whats wrong with people. Some people are so hopelessly dependent on the system (windows) they will fight to protect it. What people need to do is free thier minds (and your computers) and embrace linux.
Termina
Ah, Matrix quote. Nifty. XP

If you're intrested, I can show you my PHP code that I use to remote edit/change config files, as well as a script that will allow you to restart services.

I get home in a few hours, I'll be sure to post back them.
hughesjr
Termina ... I'm inerested in your scripts!
petterg
Webmin is great for remote sysadmin. Think it would work great in your case. Webmin also got a buildt in system to void locking yourself out. (Once I tried to set iptables -P INPUT DROP without opening the port webmin was running on, and it refuesed to apply changes.)

About the cron-script. Basically all it needs to do is:
cp -a /path/to/old/config/file.old /path/to/config
/etc/init.d/service_name restart
Corey
I notice that in my experiences, system admins that were trained at private colleges that use Windows only become very afraid of things they're not used to. With my last job, they told me I couldn't have an email address because of licensing costs, etc. I tried to convince them to move the web server and email server over to a linux server (they were using basic pop3/smtp without exchange) to save on costs, but they wouldn't go for it. Shouldn't it be the job of a systems administrator to seek out information that could lead to a more stable, secure and cost-efficient infrastructure rather then wasting time and money on dealing with licensing costs, constant virus and worm infections, etc.? Maybe I wasn't forcefull enough, maybe I should have gone straight to the VP of Operations and presented some sort of analysis. However, it would have taken a lot of my own time to convince them, and I would not have received anything for it.
hughesjr
I agree that webmin is a great remote management tool.

http://webmin.com/download.html
hughesjr
QUOTE
Shouldn't it be the job of a systems administrator to seek out information that could lead to a more stable, secure and cost-efficient infrastructure rather then wasting time and money on dealing with licensing costs, constant virus and worm infections, etc.?

YES

QUOTE
Maybe I wasn't forcefull enough, maybe I should have gone straight to the VP of Operations and presented some sort of analysis.

Well, it has been my experience that with time at a location, trust from the management is built. So if you are farily new at a job (or in a fairly low admin position), go with what they have and put together plans about what would be best (but go slowly). As your skills are recognized by the management, their belief in your opinion grows. When they (and everyone else in the orginization) realizes that you are the best admin they have ... then you can get all the changes made that you think are right. At least, that has been my experience.
thaigrrrrl
THanks for the tips, I'm checking out webmin.

I wish I saw this before I wrote everything!!! grr. hehe that's okay I billed extra hours for it happy.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.