summaryrefslogtreecommitdiff
path: root/hscript/script.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-02 16:16:41 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-02 16:16:41 -0500
commit9f422751407f2d100080a0075f8b2293b5a080bd (patch)
tree72aad62536cdff2e726fbf34971e16e42a77686a /hscript/script.cc
parent3dbe0982a10c823a2793a3d125beba2edf75f1f7 (diff)
downloadhorizon-9f422751407f2d100080a0075f8b2293b5a080bd.tar.gz
horizon-9f422751407f2d100080a0075f8b2293b5a080bd.tar.bz2
horizon-9f422751407f2d100080a0075f8b2293b5a080bd.tar.xz
horizon-9f422751407f2d100080a0075f8b2293b5a080bd.zip
hscript: Handle creation of directories when needed
Diffstat (limited to 'hscript/script.cc')
-rw-r--r--hscript/script.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/hscript/script.cc b/hscript/script.cc
index e253dbe..841c546 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -1281,6 +1281,9 @@ bool Script::execute() const {
"cannot read wireless networking configuration");
}
} else {
+ if(!fs::exists("/target/etc/wpa_supplicant", ec)) {
+ fs::create_directory("/target/etc/wpa_supplicant", ec);
+ }
fs::copy_file("/tmp/horizon/wpa_supplicant.conf",
"/target/etc/wpa_supplicant/wpa_supplicant.conf",
fs_overwrite, ec);
@@ -1325,6 +1328,13 @@ bool Script::execute() const {
<< std::endl << conf.str() << std::endl
<< "NETCONF_EOF" << std::endl;
} else {
+ if(!fs::exists("/target/etc/conf.d")) {
+ fs::create_directory("/target/etc/conf.d", ec);
+ if(ec) {
+ output_error("internal", "could not create /etc/conf.d "
+ "directory", ec.message());
+ }
+ }
std::ofstream conf_file("/target/etc/conf.d/net",
std::ios_base::app);
if(!conf_file) {