In previous versions of Ubuntu I have been using this script to automatically bring up an network interface for a USB to CAN bridge device, whenever the device is plugged in:
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
allow-hotplug can0
iface can0 can static
bitrate 250000
up /sbin/ip link set $IFACE down
up /sbin/ifconfig $IFACE txqueuelen 20000
up /sbin/ip link set $IFACE type can bitrate 250000 restart-ms 10
up /sbin/ip link set $IFACE up
This script does not work any more because Ubuntu 17.10 is not using ifupdown and consequently /etc/network/interfaces file is no longer used. My question is, how do I rewrite this script using the new netplan configuration system?
In particular, what is critical for functioning of my script above is the line allow-hotplug can0 which detects when the can0 interface becomes available (shortly after plugging the device into USB port). Can I do this using the new configuration system?