Feature: Add scripts for on the fly client mode

Closes: #171
This commit is contained in:
Matthias Strubel 2017-03-17 22:39:32 +01:00
parent 86cd3719ad
commit b6ec9f041f
4 changed files with 50 additions and 3 deletions

View File

@ -0,0 +1,14 @@
#!/bin/sh
# Wrapper script for the steps to enable wifi client
systemctl stop piratebox
if /opt/piratebox/rpi/run_client.sh ; then
echo "Started Wifi client sucessfully!"
exit 0
else
echo "Error while starting wifi client, restarting piratebox"
systemctl start piratebox
exit 1
fi
exit 1

View File

@ -0,0 +1,27 @@
#!/bin/bash
# Runs with wpa_supplicant & wifi device from boot folder.
## Default
WIFI_DEVICE="wlan0"
WIFI_CONFIG_PATH="/boot/wifi_card.conf"
WPA_SUPPLICANT="/boot/wpa_supplicant.conf"
# Try to get wifi device
if test -e "${WIFI_CONFIG_PATH}" ; then
echo "Found wifi card config"
WIFI_DEVICE=$( head -n 1 "${WIFI_CONFIG_PATH}" | tr -d '\n' )
fi
# Try to connect to Wifi if wpa_supplicant.conf is available.
if [ -f "${WPA_SUPPLICANT}" ]; then
echo "Found wpa_supplicant conf, trying to connect..."
wpa_supplicant -i"${WIFI_DEVICE}" -c "${WPA_SUPPLICANT}" -B -D wext
dhcpcd "${WIFI_DEVICE}"
exit 0
else
echo "Wifi configuration not found"
exit 1
fi
exit 1

View File

@ -0,0 +1,6 @@
#!/bin/sh
# User friendly way to switch to client
# Adds "nohup" option...
nohup /opt/piratebox/rpi/bin/do_switch_client.sh

View File

@ -74,9 +74,9 @@ echo "Could not find an AP enabled WiFi card..."
# Try to connect to Wifi if wpa_supplicant.conf is available.
if [ -f /boot/wpa_supplicant.conf ]; then
echo "Found wpa_supplicant conf, trying to connect..."
wpa_supplicant -i"${WIFI_DEVICE}" -c /boot/wpa_supplicant.conf -B -D wext
dhcpcd "${WIFI_DEVICE}"
/opt/piratebox/rpi/bin/run_client.sh
exit 1
# Exit =! 0 will result in not starting piratebox service
fi
exit 1