Last active
June 17, 2022 08:27
-
-
Save mansouryaacoubi/d44ad218d87f941a58491b6e05b81dba to your computer and use it in GitHub Desktop.
Adds wifi to the wpa_supplicant file and reconfigures wpa_cli (Raspberry Pi Wifi)
This file contains hidden or 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
#!/bin/bash | |
# @author Mansour Yaacoubi | |
# @filename addwifi.sh | |
# @usage sudo ./addwifi.sh "SSID" "WPA-Key" | |
# @task adds wifi to the wpa_supplicant file and reconfigures wpa_cli | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root" | |
exit 1 | |
else | |
clear | |
echo | |
echo "Script is running with higher privileges as: $SUDO_USER -> $(whoami)" | |
echo | |
fi | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "Missing operands" | |
echo "First arg: SSID; Second arg: Password" | |
exit | |
fi | |
wpa_passphrase "$1" "$2" >> /etc/wpa_supplicant/wpa_supplicant.conf | |
wpa_cli reconfigure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment