I am trying to run a very small python script AFTER internet has been established. I am currently editing /etc/network/if-up.d/upstart by adding the following code directly under all_interfaces_up():
all_interfaces_up() {
python /path/to/script.py
# return true if all interfaces listed in /etc/network/interfaces as 'auto'
# are up. if no interfaces are found there, then "all [given] were up"
local prefix="$1" iface=""
for iface in $(get_auto_interfaces); do
# if cur interface does is not up, then all have not been brought up
[ -f "${prefix}${iface}" ] || return 1
done
return 0
}
I know that the program "script.py" works, because I have tested it numerous times. I just need it to run AFTER internet connection has been established.
I have tried the above code with and without the "python" preceding the path to script.
I have also made sure that #!path/to/python was at the top of my .py file.
Furthermore, I did chmod + x to make it executable.
What am I missing? I have rebooted my Pi everytime I have tried something new and have run the code service networking restart to make sure the networking is restarted. Why isn't my script running after Internet connection has been established?