]> git.ipfire.org Git - people/jschlag/network.git/commitdiff
wireless-ap: Add hotplug support.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 May 2012 12:12:53 +0000 (12:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 27 May 2012 12:12:53 +0000 (12:12 +0000)
This patch will help wireless APs to automatically
start up when an USB wireless device is plugged in.

hooks/ports/wireless-ap

index b98e3e70d450380f29e4dc576c93ce59ad9d82cc..5897c3df8f1bb52c299df898c48fb30ad7a227b1 100755 (executable)
@@ -157,17 +157,17 @@ function _up() {
 
 function _down() {
        local port=${1}
-
        assert isset port
 
        config_read $(port_file ${port})
 
-       if ! device_exists ${port}; then
-               exit ${EXIT_OK}
-       fi
-
+       # Stop the hostapd daemon.
        hostapd_stop ${port}
-       wireless_remove ${port}
+
+       # Remove the device if it is still present.
+       if device_exists ${port}; then
+               wireless_remove ${port}
+       fi
 
        exit ${EXIT_OK}
 }
@@ -196,4 +196,27 @@ config_read $(zone_dir ${zone})/${port}
        exit ${EXIT_OK}
 }
 
+function _hotplug() {
+       local port=${1}
+       local phy=${2}
+
+       assert isset port
+       assert isset phy
+       assert port_exists ${port}
+
+       # Read configuration of port.
+       config_read $(port_file ${port})
+
+       # Get the address of the phy.
+       local phy_address=$(phy_get_address ${phy})
+
+       # Check if the phy is the same we have
+       # read from the configuration file.
+       if [ "${PHY}" = "${phy_address}" ]; then
+               wireless_create ${port} ${PHY} __ap ${ADDRESS}
+       fi
+
+       exit ${EXIT_OK}
+}
+
 run $@