summaryrefslogtreecommitdiff
path: root/roles/ws/minet/templates/openwifi-connection.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ws/minet/templates/openwifi-connection.j2')
-rwxr-xr-xroles/ws/minet/templates/openwifi-connection.j227
1 files changed, 27 insertions, 0 deletions
diff --git a/roles/ws/minet/templates/openwifi-connection.j2 b/roles/ws/minet/templates/openwifi-connection.j2
new file mode 100755
index 00000000..a14b8e70
--- /dev/null
+++ b/roles/ws/minet/templates/openwifi-connection.j2
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+SHORT_NAME="{{ item.key | lower }}"
+DESC_NAME="{{ item.value.description }}"
+INTERFACE="{{ ws_minet_wireless_interface_name }}"
+MODULE_NAME="{{ ws_minet_wireless_interface_module }}"
+SSID="{{ item.value.ssid }}"
+
+. /usr/local/lib/minet/minet_helpers.sh
+
+case "$1" in
+ start|"")
+ echo "Connecting with $DESC_NAME"
+ activate_interface $INTERFACE $MODULE_NAME
+ iw dev $INTERFACE connect "$SSID"
+ dhclient $INTERFACE -v -pf /var/run/dhclient.$SHORT_NAME.pid
+ ;;
+ stop)
+ echo "Disconnecting from $DESC_NAME"
+ kill `cat /var/run/dhclient.$SHORT_NAME.pid`
+ rm /var/run/dhclient.$SHORT_NAME.pid
+ deactivate_interface $INTERFACE $MODULE_NAME
+ ;;
+ *)
+ exit 1
+ ;;
+esac