As far as I'm concerned, the /etc/network/if-up.d/
solution did not work from me as when I added to /etc/network/interfaces
the following:
auto wlp58s0
iface wlp58s0 inet dhcp
post-up /home/augustin/Config/myscript.sh
Wifi would start after reboot.
But after some struggle, from this link, what worked was to add the script to /etc/NetworkManager/dispatcher.d/
in the form 90myscript.sh
where 90
is the priority level of the script and with the following form:
#!/bin/bash
IF=$1
STATUS=$2
if [ "$IF" == "wlp58s0" ]
then
case "$2" in
up)
# interface is up
;;
down)
# interface will be down
;;
pre-up)
# interface will be up
;;
post-down)
# interface is down
;;
*)
;;
esac
fi
#!/bin/bash
IF=$1
STATUS=$2
if [ "$IF" == "wlp58s0" ]
then
case "$2" in
up)
# interface is up
;;
down)
# interface will be down
;;
pre-up)
# interface will be up
;;
post-down)
# interface is down
;;
*)
;;
esac
fi
I guess there are issues between who controls the network config at system level and sometimes the default network
behavior is left behind the dispatcher one.
Also, for those who would like - like me - to try to have a symbolic link to the script (to store the file in a better location), unfortunately it did not work for me.
Hope this helps!