top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Run one-time startup script in Linux

+1 vote
113 views

I have to change IP numbers across a number of virtual and physical machines because of network center move. This has to be done before network startup, of course. I'm thinking about the best method to do this.
Where should I include/init this script? Or would it rather make more sense to do this on the last shutdown?

Changes largely involve removing old files and putting new files in place (resolv.conf, hosts, sysconfig/network + network-scripts, firewall, postfix, httpd etc.). The only other change besides replacing files would be changing the IP address in a webcontrol interface in a MySQL table, so this part has to be done after MySQL startup.

Could be run-once or have to disable manually after successful startup.

posted Sep 20, 2013 by Majula Joshi

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

4 Answers

+1 vote

If I needed to do this, I would start by making a tarball of all files that need to changed. Then I would edit the files as needed and make a tarball of the new version.

Next I would write two scripts, one to enable the new settings and one to restore the old settings. At the end of each script restart network services. Then create an at job to enable the new settings at now+2min and another to restore the former settings at now+7min.

In two minutes you should be able to ssh to the host and cancel the second at job. If anything goes wrong, just wait 5 minutes and old network settings are back.

answer Sep 20, 2013 by Sheetal Chauhan
+1 vote

I noticed that this is a one-time occurrence after the move to a new network. In this case there is no need to schedule the at job. Just make a backup of files you are changing, then make the changes. They will not take effect immediately unless you restart any of the services. (So don't restart an services or reboot the server prior to the move.)

Plan a time to make the changes prior to shutting down at the old data center. They should come up correctly in the new environment.

answer Sep 20, 2013 by Luv Kumar
+1 vote

There are several possibilities (this *is* *Nix, after all), but several questions first: aren't you using dhcp to give them IPs? Won't the dhcp client rewrite resolv.conf?

For the other stuff, if it needs to run once, why not have the script looking for a lock file, and if it's not there run, ending by creating the lock file. Then, after everything's up and wonderfully correct, you can run a script everywhere that, if it finds the lockfile, deletes both that, and the script?

answer Sep 20, 2013 by Naveena Garg
I'd probably do it as a search/replace script trying to make it so the search targets will only match once (the old values) so it doesn't matter if it runs again or not. And I'd probably copy the script in and run it as part of the final shutdown steps.
0 votes

reconfigure the servers to use dhcp and configure the hosts via reservations on the dhcp servers. new location on a new subnet would have require reservations, reboot and voila!

DNS should be taking care of any application stuff (when the servers are moved, their entries are updated on the DNS servers)

answer Sep 20, 2013 by Seema Siddique
Similar Questions
0 votes

There are many hurdle in a startup i.e. finance, skill, strength of idea, hiring key people. But want to know the opinion about which is the biggest hurdle in the start-up proceeding.

0 votes

There are many ways to value a firm I.e. EBDITA multiple, DCF, sales multiple. But in all the above cases company requires revenue which is not there in a start-up company. Want to know opinion of people about valuation method of valueing a startup firm.

+3 votes

Probably is simple and silly question, I should have googled but still want to ask.
I want to run a script at the login to the Linux system, what is the best way to achieve this.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...