#!/bin/sh # wifiset SSID PASSWD st=`cat /etc/wpa_supplicant/wpa_supplicant.conf | grep -n "##BEGIN_AUTOGENERATED"|sed -e "s/:/ /"|awk '{print $1}'` ed=`cat /etc/wpa_supplicant/wpa_supplicant.conf | grep -n "##END_AUTOGENERATED"|sed -e "s/:/ /"|awk '{print $1}'` #echo ${st},${ed} sed -n ${st},${ed}p /etc/wpa_supplicant/wpa_supplicant.conf sed -i ${st},${ed}d /etc/wpa_supplicant/wpa_supplicant.conf echo "##BEGIN_AUTOGENERATED" >> /etc/wpa_supplicant/wpa_supplicant.conf echo "network={" >> /etc/wpa_supplicant/wpa_supplicant.conf echo " ssid=\"$1\"">> /etc/wpa_supplicant/wpa_supplicant.conf echo " psk=\"$2\"" >> /etc/wpa_supplicant/wpa_supplicant.conf echo " key_mgmt=WPA-PSK" >> /etc/wpa_supplicant/wpa_supplicant.conf echo " eap=TTLS PEAP TLS" >> /etc/wpa_supplicant/wpa_supplicant.conf echo " }" >> /etc/wpa_supplicant/wpa_supplicant.conf echo "##END_AUTOGENERATED" >> /etc/wpa_supplicant/wpa_supplicant.conf /usr/bin/sudo /bin/systemctl disable hostapd /usr/bin/sudo /bin/systemctl enable wpa_supplicant /usr/bin/sudo /sbin/reboot