rc.d/wg: Match wg ifnames on wg_start
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Wed, 27 Mar 2024 13:30:57 +0000 (14:30 +0100)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Wed, 27 Mar 2024 14:41:54 +0000 (15:41 +0100)
commit212e48ceabe0c8b9237715a45859367fbc0df8ad
tree7a9facbe87a3e0275176c79b458d44859783b051
parent7485684fa5c3fadb6c7a1da0d8bb6ea5da4e0f2f
rc.d/wg: Match wg ifnames on wg_start

  Specifying wg_interfaces="wg0" in /etc/rc.conf causes:

    ifconfig: ioctl SIOCSIFNAME (set name): File exists

  The interface name matching in the wg script is not matching the
  'wg' interfaces thus trying to set a custom interface name.

  Apparently expr does not interpret '+' from regex:

    $ expr 'wg0' : 'wg[0-9]+$' && echo matched
    0

  Workaround it by using already working expr usage:
    $ expr 'wg0' : 'wg[0-9][0-9]*$' && echo matched
    3
    matched

  There is no need to anchor the beginning of line with ^ since
  expr already does that.
etc/rc.d/wg