How to invoke an initscript after network connection?

202 Views Asked by At

I have a initscript which I would like to execute only after network connection establishment. Becasue the init script will invoke a curl call. I beleive this is rather straightforward with systemd After=network-online.target. But, how can I do this with sysvinit? The linux is a custom built using yocto. There is no systemd available.

structure of initscript:

#!/bin/bash
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
    # code to start app comes here
    make curl call
}

stop() {
    # code to stop app comes here 
    # example: killproc program_name

}

case "$1" in 
    start)
       start
       ;;
    stop)
       stop
       ;;
    restart)
       stop
       start
       ;;
    *)
       echo "Usage: $0 {start|stop|restart}"
esac

exit 0

P.S: Please let me know if any info is missing

0

There are 0 best solutions below