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
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!
/etc/network/*.d/you can use the variable$IFACEto know which interface is getting a connection so you can skip the procedure if it is the wired connection for example. – Carlos Campderrós Feb 20 '13 at 09:22interfaceswhen it is not there. Is itauto wlan0andiface wlan0 inet dhcpor sth else? – Cookie Mar 25 '14 at 15:40auto loiface lo inet loopbackin my/etc/network/interfacesfile. I want my script to be executed after connecting witheth0. – Exeleration-G Mar 26 '14 at 11:35/etc/network/interfacesauto wlp58s0 iface wlp58s0 inet dhcp post-up /home/augustin/Config/auto-checkin.shthe wifi doesn't start after reboot... :( – Augustin Riedinger Feb 28 '18 at 11:20