summaryrefslogtreecommitdiff
path: root/roles/ws
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-12-29 01:53:55 +0100
committerChristian Pointner <equinox@spreadspace.org>2020-12-29 01:53:55 +0100
commit440d8ebcb031e58b0fc1be90c546958bfbaa185b (patch)
tree75a7b5c6ec9dfa05ed728e362b5aeb9be686b956 /roles/ws
parentws/minet: add more connection scripts (diff)
ws/minet: add even more connection scripts
Diffstat (limited to 'roles/ws')
-rw-r--r--roles/ws/minet/defaults/main.yml5
-rw-r--r--roles/ws/minet/tasks/main.yml10
-rwxr-xr-xroles/ws/minet/templates/openwifi-connection.j227
3 files changed, 41 insertions, 1 deletions
diff --git a/roles/ws/minet/defaults/main.yml b/roles/ws/minet/defaults/main.yml
index a665b0a5..f214bf18 100644
--- a/roles/ws/minet/defaults/main.yml
+++ b/roles/ws/minet/defaults/main.yml
@@ -9,3 +9,8 @@ ws_minet_wpa_connections: {}
# foo:
# description: foo.bar
# ssid: blub
+
+ws_minet_openwifi_connections: {}
+# foo:
+# description: foo.bar
+# ssid: blub
diff --git a/roles/ws/minet/tasks/main.yml b/roles/ws/minet/tasks/main.yml
index efda2816..bb62a5a9 100644
--- a/roles/ws/minet/tasks/main.yml
+++ b/roles/ws/minet/tasks/main.yml
@@ -33,7 +33,15 @@
- name: install custom wpa connections
loop: "{{ ws_minet_wpa_connections | dict2items }}"
loop_control:
- label: "{{ item.key }} ({{ item.value.description }})"
+ label: "{{ item.key }} - {{ item.value.description }}"
template:
src: wpa-connection.j2
dest: "/usr/local/lib/minet/{{ item.key }}"
+
+- name: install custom open-wifi connections
+ loop: "{{ ws_minet_openwifi_connections | dict2items }}"
+ loop_control:
+ label: "{{ item.key }} - {{ item.value.description }}"
+ template:
+ src: openwifi-connection.j2
+ dest: "/usr/local/lib/minet/{{ item.key }}"
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