Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFi dialog: add script for printing marker section contents #1811

Merged
merged 21 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Set up scripts for enabling/disabling WiFi network interface
  • Loading branch information
jotaen committed Jun 13, 2024
commit 42d06e04078bd472875f10877c94dbd5942ef0c8
3 changes: 3 additions & 0 deletions debian-pkg/etc/sudoers.d/tinypilot
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/change-hostname
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/collect-debug-logs
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/configure-janus
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/disable-wifi
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/enable-wifi
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/read-update-log
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/read-update-log
tinypilot ALL=(ALL) NOPASSWD: /opt/tinypilot-privileged/scripts/update
tinypilot ALL=(ALL) NOPASSWD: /sbin/shutdown
Expand Down
17 changes: 17 additions & 0 deletions debian-pkg/opt/tinypilot-privileged/scripts/disable-wifi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Exit on first error.
set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
readonly CONFIG_FILE="/etc/wpa_supplicant/wpa_supplicant.conf"

# shellcheck source=lib/markers.sh
. "${SCRIPT_DIR}/lib/markers.sh"

# Remove any existing automated configuration.
"${SCRIPT_DIR}/strip-marker-sections" "${CONFIG_FILE}"

# Block (deactivate) WLAN, which will take effect instantly.
rfkill block wlan
30 changes: 30 additions & 0 deletions debian-pkg/opt/tinypilot-privileged/scripts/enable-wifi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Exit on first error.
set -e

# TODO parse these parameters from CLI args.
readonly WIFI_COUNTRY='DE'
readonly WIFI_SSID='my-home-network'
readonly WIFI_PSK='p4ssw0rd'

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
readonly CONFIG_FILE="/etc/wpa_supplicant/wpa_supplicant.conf"
# shellcheck source=lib/markers.sh
. "${SCRIPT_DIR}/lib/markers.sh"

# Remove any existing automated configuration.
"${SCRIPT_DIR}/strip-marker-sections" "${CONFIG_FILE}"

# Write out the new configuration.
{
echo "${MARKER_START}"
echo "country=${WIFI_COUNTRY}"
echo "$(wpa_passphrase "${WIFI_SSID}" "${WIFI_PSK}" | sed '/^\t#psk=.*/d')"
echo "${MARKER_END}"
} | sudo tee --append "${CONFIG_FILE}" > /dev/null

# Effectuate changes.
rfkill unblock wifi
wpa_cli -i wlan0 reconfigure