[obsolete] net-auto-wireless@.service on arch linux

EDIT: Fixed in netctl (dropin replacement for netcfg)

When I enabled net-auto-wireless.service via systemctl

# systemctl enable net-auto-wireless.service

the wlan was never started on boot. Although I did every documented steps of https://wiki.archlinux.org/index.php/Netcfg . Unfortunately journalctl always showed me that wlan0 is not available:

Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: Could not read interface wlan0 flags: No such device

Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: nl80211: Could not configure driver to use managed mode
Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: Could not read interface wlan0 flags: No such device
Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: Could not read interface wlan0 flags: No such device
Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: Could not read interface wlan0 flags: No such device
Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: WEXT: Could not set interface 'wlan0' UP
Jan 29 22:10:32 frigg netcfg-wpa_actiond[160]: wlan0: Failed to initialize driver interface

After a few hours of searching the web, I found the solution. Also described on https://wiki.archlinux.org/index.php/Netcfg_Troubleshooting . Search for "wlan0 does not exist".

So the solution is to provide a net-auto-wireless@.service, using the correct interface and waiting for it to be available:

# cat /etc/systemd/system/net-auto-wireless\@.service

[Unit]
Description=Provides automatic netcfg wireless connection
Before=network.target
Wants=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device



[Service]
EnvironmentFile=/etc/conf.d/netcfg
ExecStart=/usr/bin/netcfg-wpa_actiond %i
ExecStop=/usr/bin/netcfg-wpa_actiond stop %i
RemainAfterExit=yes
Type=forking

[Install]
WantedBy=multi-user.target

Special thanks to brian0 https://bbs.archlinux.org/viewtopic.php?pid=1186188#p1186188

Since EnvironmentFile= is not available in [Unit], I was not able to use $WIRELESS_INTERFACE in this section.

After that, I disabled the net-auto-wireless.service and enabled the net-auto-wireless@.service

# systemctl disable net-auto-wireless.service

# systemctl enable net-auto-wireless@wlan0.service

UPDATE:

I opened a ticket for this stuff. Hoping to see it in the next version of netcfg.