Robin Mordasiewicz
2005-Nov-24 15:58 UTC
[CentOS] which script will run before and after network started
Is there a script which I can customize which will run before doing service network stop and a script which I can run after doing service network start I see that /sbin/ifup-local runs after each interface is brought up, but I cannot figure out which scripts will run after all the interfaces are brought up.
Giovanni P. Tirloni
2005-Nov-25 00:08 UTC
[CentOS] which script will run before and after network started
Robin Mordasiewicz wrote:> Is there a script which I can customize which will run before doing > service network stop > > and a script which I can run after doing > service network start > > I see that /sbin/ifup-local runs after each interface is brought up, but > I cannot figure out which scripts will run after all the interfaces are > brought up.You can create your init script and leave it in the /etc/init.d directory. It should have a line describing in what runlevels it should start and what's its start/stop priority. After that you run chkconfig to add it. The network script starts at 10 and ends at 90. So if you want to run your script after it's stared and before it ends you need to set the start priority to 11 and the stop priority to 89. See the chkconfig(8) man page for more details. # cat /etc/init.d/hello #!/bin/sh # # hello Just say hello # # chkconfig: 2345 11 89 # description: hello world init script # case "$1" in start) echo "Hello world!" ;; stop) echo "Bye world!" ;; *) echo $"Usage: $0 {start|stop}" exit 1 esac # chkconfig --add hello Good luck, -- Giovanni P. Tirloni http://blog.tirloni.org