I have written a program that transparently logs in to captive portals. As such, I'd like to run this any time that any wireless connection comes up using netcfg. It is possible to do this per-connection in the configuration file by using POST_UP, but this would require adding it to every connection that currently exists, and any connection that may be created in future, which is not feasible in my situation. I also do not wish to poll for network connections as a daemon. I don't see any information about doing this in man netcfg-profiles.

How should I approach this? Does netcfg have any built-in configuration that allows a POST_UP to apply to multiple connections?

It is acceptable for it to also apply to all connections (including wired), but if possible I'd like to avoid it.


Interface-specific {PRE,POST}_{UP,DOWN} commands can be defined in /etc/network.d/interfaces/$DEVICE, where $DEVICE is your network device name. So, although you need a hook per interface (which is actually what you indicate that you want), you do not need one per connection.

For example, my interfaces folder has the following files:


notify() {
/usr/local/sbin/xuserrun /usr/local/sbin/network_notification "$dev" "$state"
return 0

/etc/network.d/interfaces/{wlan0,eth0} (both with same contents):

source /etc/network.d/interfaces/_functions
POST_UP="notify ${INTERFACE} up"
PRE_DOWN="notify ${INTERFACE} down"

This runs a script to send a pop-up notification telling me when a connection has been made/lost. Note that these hooks run as the root user. The xuserrun command is available on github and determines the current X username and switches to that user before running the subsequent command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.