summaryrefslogtreecommitdiff
path: root/hscript/network.cc
diff options
context:
space:
mode:
Diffstat (limited to 'hscript/network.cc')
-rw-r--r--hscript/network.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/hscript/network.cc b/hscript/network.cc
index 14e33b4..e375385 100644
--- a/hscript/network.cc
+++ b/hscript/network.cc
@@ -13,6 +13,7 @@
#include <algorithm>
#include <arpa/inet.h> /* inet_pton */
#include <cstring> /* memcpy */
+#include <fstream> /* ofstream for Net write */
#ifdef HAS_INSTALL_ENV
# include <linux/wireless.h> /* struct iwreq */
# include <string.h> /* strerror */
@@ -395,5 +396,22 @@ bool NetSSID::validate(ScriptOptions options) const {
}
bool NetSSID::execute(ScriptOptions) const {
- return false;
+ std::ofstream conf("/tmp/horizon/wpa_supplicant.conf",
+ std::ios_base::app);
+ if(!conf) {
+ output_error("installfile:" + std::to_string(this->lineno()),
+ "netssid: failed to write configuration");
+ return false;
+ }
+
+ conf << std::endl;
+ conf << "network={" << std::endl;
+ conf << "\tssid=\"" << this->ssid() << "\"" << std::endl;
+ if(this->type() != SecurityType::None) {
+ conf << "\tpsk=\"" << this->passphrase() << "\"" << std::endl;
+ }
+ conf << "\tpriority=5" << std::endl;
+ conf << "}" << std::endl;
+
+ return !conf.fail();
}