I'm trying to set up a System-V init script on my Raspbian, just to send an HTTP POST request to a public web server (99,9% uptime), reporting that the Raspbian has just been started up (or rebooted). So far, I've done the following:
Edited /etc/init.d/notify-startup (initial test T0) (showing only relevant lines):
... # Required-Start: $remote_fs $syslog $time # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ... case "$1" in start) logger -i "Starting Notify-Startup" || true /opt/notify-startup/bin/notify-startup.sh & ...
#!/bin/sh # First. curl --insecure --include --request POST \ --url https://example.com/notify-startup.php \ --header "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "id=0" \ --data-urlencode "count=1" \ --data-urlencode "message=Starting up (1)" > /dev/null 2>&1 sleep 180 # Second. curl --insecure --include --request POST \ --url https://example.com/notify-startup.php \ --header "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "id=0" \ --data-urlencode "count=2" \ --data-urlencode "message=Starting up (2)" > /dev/null 2>&1 exit 0
Run update-rc.d to create System-V style links under /etc/rc?.d:
$ sudo update-rc.d notify-startup defaults # Command [C1]
After this execution, my symlinks under /etc/rc?.d are the following:
/etc/rc0.d/K01notify-startup /etc/rc1.d/K01notify-startup /etc/rc2.d/S02notify-startup /etc/rc3.d/S02notify-startup /etc/rc4.d/S02notify-startup /etc/rc5.d/S02notify-startup /etc/rc6.d/K01notify-startup
Then I reboot my Raspbian.
Result is that the first HTTP POST request does not reach the public web server but the second one actually does, and I'd like both of them would do.
It's important to say that Ethernet interface and DNS resolver must be operative so that my HTTP POST request could reach the public web server. So I've tried the following combinations of LSB facility names  on my script with no success until now:
# Required-Start: $network $remote_fs $syslog $time
# Required-Start: $named $remote_fs $syslog $time
I also have noticed that, after re-running update-rc.d [C1], the symlinks under /etc/rc?.d are not re-numbered in order to satisfy the dependencies on facility names configured on tests [T1] and [T2].
My question is: Is there any way to ensure that my startup script gets run just after DNS resolution is available to my Raspbian system, by using facility name dependencies or by any other programmatic way (I would prefer the former)? Am I doing something wrong with command [C1] so that my startup script execution order does not get updated and does not ensure DNS resolution and network availability?
PS: I already know that this simple task could be achieved well by using just a @reboot crontab job, but I need it to be a System-V startup script as I would be upgrading it to add more and more functionality over time.