home · contact · privacy
Fix keyboard config bug, add rump for new networking script.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 10 Sep 2017 18:36:09 +0000 (20:36 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 10 Sep 2017 18:36:09 +0000 (20:36 +0200)
ansible/files/console/___etc___default___keyboard
bin/network.sh [new file with mode: 0755]

index 25a46b76c7be0fa17a1663c8a076cc788e10fdae..7f08e307cbd908fd936481854ddee0f8905ade58 100644 (file)
@@ -1,2 +1,4 @@
-XKBMODEL="pc105"  # questionable, but works fine as default
+# setting XKBMODEL to the questionable default seems to be necessary and works nicely
+# curiously, putting a comment on the same line as a variable setting seems to break things
+XKBMODEL="pc105"
 XKBLAYOUT="de"
diff --git a/bin/network.sh b/bin/network.sh
new file mode 100755 (executable)
index 0000000..cfaf39f
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+eth_interface=enp0s25
+wifi_interface=wls1
+
+ensure_wifi_on() {
+  if [ ! "$(wifi)" = "wifi      = on" ]; then
+    wifi on
+    ip link set "$wifi_interface" up
+  fi
+}
+
+print_usage() {
+  echo 'Available commands:'
+  echo '  eth_connect'
+  echo '  eth_disconnect'
+  echo '  wifi_scan'
+  echo '  wifi_connect_open SSID'
+  echo '  wifi_set_wpa SSID KEY'
+  echo '  wifi_connect_wep_ascii SSID KEY'
+  echo '  wifi_connect_wep_hex SSID KEY'
+  echo '  wifi_connect_wpa SSID KEY'
+  echo '  wifi_disconnect'
+}
+
+if ! echo "${1}"; then
+  echo 'No command given.'
+  print_usage
+  exit 1
+elif [ "${1}" = 'eth_connect' ]; then
+  ip link set "$eth_interface" up 
+  dhclient "$eth_interface"
+
+elif [ "${1}" = 'eth_disconnect' ]; then
+  ip link set "$eth_interface" down
+
+elif [ "${1}" = 'wifi_scan' ]; then
+  ensure_wifi_on
+  ip link set "$wifi_interface" up
+  iw dev "$wifi_interface" scan | grep SSID
+
+elif [ "${1}" = 'wifi_connect_open' ]; then
+  ensure_wifi_on
+  iw dev "$wifi_interface" connect "${2}"
+  #dhclient "$wifi_interface" 
+
+elif [ "${1}" = 'wifi_connect_wep_ascii' ]; then
+  ensure_wifi_on
+  iw dev "$wifi_interface" connect "${2}" key 0:"${3}"
+  #dhclient "$wifi_interface" 
+
+elif [ "${1}" = 'wifi_connect_wep_hex' ]; then
+  ensure_wifi_on
+  iw dev "$wifi_interface" connect "${2}" key d:0:"${3}"
+  #dhclient "$wifi_interface" 
+
+elif [ "${1}" = 'wifi_connect_wpa' ]; then
+  ensure_wifi_on
+  wpa_passphrase "${2}" "${3}" > /tmp/wpa_supplicant.conf
+  wpa_supplicant -B -i "$wifi_interface" -c /tmp/wpa_supplicant.conf
+  dhclient "$wifi_interface" 
+
+elif [ "${1}" = 'wifi_disconnect' ]; then
+  ip link set "$wifi_interface" down
+
+else
+  echo 'Unknown command.'
+  print_usage
+  exit 1
+fi