-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from h2r/release/v2.3
PR for merging release/v2.3 into master
- Loading branch information
Showing
9 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.2-kinetic | ||
2.3-kinetic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Purpose: Stops the device from running as a DHCP | ||
# server, then puts it on the network | ||
# specified in WPA_SUPP_CONF_FILE. | ||
# NOTE: Re-tooled from connect_to_user_wifi.py | ||
# in h2r/pidrone_pkg github repo. | ||
# Author: Nishant Kumar | ||
# Contact: [email protected] | ||
|
||
WPA_SUPP_CONF_FILE="/etc/wpa_supplicant/wpa_supplicant.conf" | ||
WIFI="user_wifi" | ||
|
||
if [[ ! -r "${WPA_SUPP_CONF_FILE}" ]]; then | ||
echo "Missing required conf file ${WPA_SUPP_CONF_FILE}. Please create it and try again." | ||
exit 1 | ||
fi | ||
|
||
# Stopping Services | ||
sudo systemctl stop hostapd | ||
sudo systemctl stop isc-dhcp-server.service | ||
sudo ifdown wlan0 | ||
|
||
# Starting wpa_supplicant | ||
sudo wpa_supplicant -B -i wlan0 -c "${WPA_SUPP_CONF_FILE}" | ||
sudo ifup wlan0="${WIFI}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# Purpose: Generates a new wpa_supplicant.conf file by | ||
# inserting user-provided network credentials | ||
# (with hashed password for security) into a | ||
# template wpa_supplicant conf file. | ||
# Author: Nishant Kumar | ||
# Contact: [email protected] | ||
|
||
WPA_CONF_TEMPLATE="wpa_supplicant.conf.template" | ||
OUTPUT_FILE="wpa_supplicant.conf" | ||
BACKUP_FILE="${OUTPUT_FILE}"".bak" | ||
TEMP_FILE_FOR_GENERATED_NETWORK="/tmp/generated_network.XXXX" | ||
|
||
function print_wpa_passphrase_error() { | ||
if [[ -n "${temp_generated}" ]]; then | ||
echo "${temp_generated}" | sed '/#.*$/d' | ||
fi | ||
} | ||
|
||
function cleanup() { | ||
echo "Cleaning up..." | ||
shred -n 50 -z -u "${TEMP_FILE_FOR_GENERATED_NETWORK}" > /dev/null 2>&1 | ||
echo Done | ||
} | ||
|
||
trap "ec=\$?; cleanup; exit \$ec" EXIT INT | ||
trap "ec=\$?; print_wpa_passphrase_error; exit \$ec" ERR | ||
|
||
read -ep "Enter network's ssid: " ssid | ||
read -esp "Enter network's password: " pass1 | ||
echo | ||
read -esp "Verify network's password: " pass2 | ||
echo | ||
|
||
if [[ "$pass1" != "$pass2" ]]; | ||
then | ||
echo "Password verification failed. Please try again." | ||
exit 1 | ||
fi | ||
|
||
if [[ -f "${OUTPUT_FILE}" ]]; | ||
then | ||
cp "${OUTPUT_FILE}" "${BACKUP_FILE}" | ||
echo Backed up current "${OUTPUT_FILE}" to "${BACKUP_FILE}" | ||
fi | ||
|
||
temp_generated="$(echo "${pass1}" | wpa_passphrase "${ssid}")" | ||
echo "${temp_generated}" | sed '/#.*$/d' > "${TEMP_FILE_FOR_GENERATED_NETWORK}" | ||
echo "Generated new network configuration" | ||
|
||
# If reached this far, ERR trap did not trigger due to wpa_passphrase error. | ||
# So if ERR trap triggers after this point, it should not print temp_generated, | ||
# since wpa_passphrase is not to blame (i.e. temp_generated does not contain | ||
# an error message). Therefore, setting temp_generated to blank so that | ||
# print_wpa_passphrase_error func does not print it. | ||
temp_generated= | ||
|
||
|
||
sed -e "/<network>/r ${TEMP_FILE_FOR_GENERATED_NETWORK}" -e '//d' < "${WPA_CONF_TEMPLATE}" > "${OUTPUT_FILE}" | ||
echo "Inserted new network configuration into template ${WPA_CONF_TEMPLATE}, then overwrote ${OUTPUT_FILE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
country=us | ||
update_config=1 | ||
ctrl_interface=/var/run/wpa_supplicant | ||
|
||
<network> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters