[CentOS] Run one-time startup script

Fri Sep 20 15:27:43 UTC 2013
Les Mikesell <lesmikesell at gmail.com>

On Fri, Sep 20, 2013 at 10:13 AM,  <m.roth at 5-cent.us> wrote:
> Kai Schaetzl wrote:
>> 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.
>>
> 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?

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.

-- 
  Les Mikesell
    lesmikesell at gmail.com