I have a fairly complicated routing configuration, and I’m wondering the best place to put the script for the right thing to happen. (aside: doing some low level routing magic to balance traffic across different ISPs, without any kind of routing table feed)
So I want this script to run after bringing the network up, or it being reconfigured, etc.
I dug around and found /etc/sysconfig/network/if-up.d/; this is out as they run per-interface.
SuSEfirewall2 seems a likely candidate, but the only customization hook there is FW_CUSTOMRULES - but rather then an arbitrary script, it take some kind of special iptables configuration.
/etc/init.d/network does have a special case call to /etc/sysconfig/network/if-up.d/SuSEfirewall2 with net-reconfig-done, at what looks like the right time for my custom magic. But there isn’t a hook there for custom code.
I can just hack up init.d/network, but if there is a right way, I’d like to know.
So: Am I missing a hook somewhere? Is adding a hook worth an entry in openfate?
I would not change any of the provided scripts (as you are allready reluctant do do) because this can be overwritten on updates.
You should either make a a new /etc/init.d script taking* /etc/init.d/skeleton* as starter, or you could use one of the .local sripts to add your statements.
Now we had allready boot.local*, but this is executed right after boot and before the other scripts (including the network setup) are run. But since 11.2 there is a new one:* after.local*.
Contrary to* boot.local* it is not allready in* /etc/init.d*, thus you have to create it yourself (which is not a big problem, should just contain your statements). You can see how this is called in /etc/init.d/rc and below is the relevant part of it:
#
# Start the user defined resource control script which
# should be executed _after_ runlevel is reached.
#
if test -f /etc/init.d/after.local ; then
echo -n "Master Resource Control: "
echo "Running /etc/init.d/after.local"
/bin/sh /etc/init.d/after.local
rc_status -v1 -r
splashtrigger "after.local"
fi
On 08/04/2010 09:36 AM, ken yap wrote:
>
> You could create your own init script that states in the dependencies
> that it requires network. Then it will be sequenced after network.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
I do not know what you mean with “network reconfiguration”.
The solution of making an extra /etc/int.d script (mentioned by me and supported by ken_yap and ab@novell) will run thescript after network initialisation (if the lines between
### BEGIN INIT INFO
### END INIT INFO
are used properly.
The solution using after.local will run them after the last script run to reach the required runlevel. Which in any case after network initialisation (when going to runlevel 3 or 5).
How can you catch every “network reconfiguration”? E.g. when I edit /etc/resolv.conf, I see no way to trigger automaticaly some script right after I use the* :w* command in* vi*.