Created
November 23, 2016 20:07
-
-
Save rlingineni/3b3863c06543533eacac076071ea8074 to your computer and use it in GitHub Desktop.
Raspberry Pi Wifi Config update function
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
console.log("Updating Wifi to SSD: " + SSID); | |
var data = fs.readFileSync('/etc/wpa_supplicant/wpa_supplicant.conf', 'utf8'); | |
var result = data.replace(/ssid="(.*)"/g, 'ssid="'+ SSID + '"'); | |
var finalResult = result.replace(/psk="(.*)"/g, 'psk="'+ Password + '"'); | |
console.log("Will print: \n" + finalResult); //this prints out correctly, finalResult holds what I want it ot | |
//need to fix writing to file (only writes like a piece of it) | |
fs.writeFile('/etc/wpa_supplicant/wpa_supplicant.conf', finalResult, 'utf8', function (err) { | |
if (err) return console.log(err); | |
console.log("about to reboot network config"); | |
//rebootNetwork(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment