Change wifi - mysteriousHerb/WaterScope-note GitHub Wiki
Change wifi hotspot name and password
Change content of file by shell command http://stackoverflow.com/questions/14643531/changing-contents-of-a-file-through-shell-script
Allow user input by shell http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script
sed explained: http://www.grymoire.com/Unix/Sed.html
#! /bin/sh
#variables to input
file=/etc/hostapd/hostapd.conf
read -e -p "Enter the SSID: " ssid
echo "You entered: $ssid"
read -e -p "Enter the password: " wpa_passphrase
echo "You entered: $wpa_passphrase"
#modify the value
sed -i '' 's/ssid=.*/ssid='$ssid'/' $file
sed -i '' 's/wpa_passphrase=.*/wpa_passphrase='$wpa_passphrase'/' $file
#recover the lines that have been changed accidently
sed -i '' 's/ignore_broadcast_ssid=.*/ignore_broadcast_ssid=0/' $file
Change eduroam password and account
#! /bin/sh
#variables to input
file=/etc/wpa_supplicant/wpa_supplicant.conf
read -e -p "Enter the eduroam account: " identity
echo "You entered: $identity"
read -e -p "Enter the password: " password
echo "You entered: $password"
#modify the value
sed -i '' 's/identity=.*/identity="'$identity'"/' $file
sed -i '' 's/password=.*/password="'$password'"/' $file