mirror of
https://github.com/PirateBox-Dev/PirateBoxScripts_Webserver.git
synced 2023-12-14 07:22:58 +01:00
parent
86cd3719ad
commit
b6ec9f041f
4 changed files with 50 additions and 3 deletions
14
piratebox/piratebox/rpi/bin/do_switch_client.sh
Executable file
14
piratebox/piratebox/rpi/bin/do_switch_client.sh
Executable 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
|
27
piratebox/piratebox/rpi/bin/run_client.sh
Executable file
27
piratebox/piratebox/rpi/bin/run_client.sh
Executable 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
|
6
piratebox/piratebox/rpi/bin/switch_to_client.sh
Executable file
6
piratebox/piratebox/rpi/bin/switch_to_client.sh
Executable 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
|
|
@ -74,9 +74,9 @@ echo "Could not find an AP enabled WiFi card..."
|
||||||
|
|
||||||
# Try to connect to Wifi if wpa_supplicant.conf is available.
|
# Try to connect to Wifi if wpa_supplicant.conf is available.
|
||||||
if [ -f /boot/wpa_supplicant.conf ]; then
|
if [ -f /boot/wpa_supplicant.conf ]; then
|
||||||
echo "Found wpa_supplicant conf, trying to connect..."
|
/opt/piratebox/rpi/bin/run_client.sh
|
||||||
wpa_supplicant -i"${WIFI_DEVICE}" -c /boot/wpa_supplicant.conf -B -D wext
|
exit 1
|
||||||
dhcpcd "${WIFI_DEVICE}"
|
# Exit =! 0 will result in not starting piratebox service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue