I'm using Ubuntu 18.04 in our embedded device. I followed https://netplan.io/faq by creating "/etc/networkd-dispatcher/routable.d/50-ifup-hooks":
#!/bin/sh
echo "Interface up"
# Do something
exit 0
When the network cable is plugged in the router, the script is called. The problem is, this script got called every 5 seconds after the cable connected. I'd like just "Do something" once the network cabled is plugged in the router but not running "Do something" every 5 seconds after the cable already connected. Is there a way to make sure the script is only got called once the network cable is plugged in the router but not executed when the cable is already connected to the router?
Thanks!
Edit:
Here is the ll command in /etc/networkd-dispatcher folder:
root@machine:/etc/networkd-dispatcher# ll
total 28
drwxr-xr-x 7 root root 4096 Sep 20 16:04 ./
drwxr-xr-x 77 root root 4096 Sep 16 18:03 ../
drwxr-xr-x 2 root root 4096 Sep 20 16:05 carrier.d/
drwxr-xr-x 2 root root 4096 Oct 15 2018 dormant.d/
drwxr-xr-x 2 root root 4096 Oct 15 2018 no-carrier.d/
drwxr-xr-x 2 root root 4096 Sep 20 07:12 off.d/
drwxr-xr-x 2 root root 4096 Sep 20 16:04 routable.d/
Here is the ll command for carrier.d folder:
root@machine:/etc/networkd-dispatcher# ll carrier.d/
total 12
drwxr-xr-x 2 root root 4096 Sep 20 16:05 ./
drwxr-xr-x 7 root root 4096 Sep 20 16:04 ../
-rwxr-xr-x 1 root root 209 Sep 20 16:05 50-ifup-hooks*