Post up/reconfig, firewallish hook

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

HTH.

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 SIGNED MESSAGE-----
Hash: SHA1

+1

Good luck.

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/

iQIcBAEBAgAGBQJMWYxlAAoJEF+XTK08PnB5BwwP/0Ewqd7XwaR+rvWgL0m8qPHH
byBTdRKLJcnHir0UCXkhtvhOxklNPt6yysktxip7fXt7PcgV3OjKota6T48fHfLi
mcDKuVz8JRB2Ppo2S/koLfpG1+WnDLZyn2IqGJsu3130n4U+vK3vbnvAXqkeu8rH
tuMo7gSdgII/PFdE4OMNXlTU41A+KuqQzKNNZGjHak3lq3EE2iS1ObGSNsR5GqFB
XTLjZEkvyLzCztjuHcRS3KnGqH+wdbFH1eu1sdgaVR2Vcekn8UCxSr9ACezo6dCc
NHGZmAexSG4ChtjqbsQy615PKVTg3deyUGW7hXxTaqiZ95rT577RzKt03Et/i6Ib
zXR3Qb2gKdE9xd8fMULQrwyLzLIy6NYObwpLaKlcJaOCe2uoiKbbfXyVR7c7b5tZ
XHTjjtbYaFMaQHA5hUqDKTlwRC/lwpSrWtrcIt4scgPFV4/+5hKXkRWMJHbDSpGh
yyaQnAxDfozq8Lo3Bxb46jKYepaOkP9NMuJIr23zLlvkyIhfmAyprEcMRqXbjoHu
nXB18cIgnsTM7zUDTklLAGQe1hPEOvqC/VFAFGnLcsT22QfnhS1O6slS9LkTZMq1
/WwbIkJrsm31FN1UJq95QGfFOWv3JG89IcUvUGVY2r7GMvhWKpqN9qi5mKK4REcX
+rwNMQhHBnxj3MbSoSJj
=E04a
-----END PGP SIGNATURE-----

The catch is that I want this script to run not just once on boot, at the right time, but after ever network reconfiguration.

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).

Sorry, I hit the Post button to quick.

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*.

In that case you want to use the interface up/down hook. The interface name is passed in so you can decide which ones to ignore.