summaryrefslogtreecommitdiff
path: root/hscript/network.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-04 17:27:42 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-04 17:27:42 -0600
commit7c5c18d46757416f44a0baedbe880f6634213625 (patch)
tree666ad7b7140265ef0e696974bd45e86ccca159e5 /hscript/network.cc
parent0e5d52b23ae0b86e938905a332ad5b7439011dcc (diff)
downloadhorizon-7c5c18d46757416f44a0baedbe880f6634213625.tar.gz
horizon-7c5c18d46757416f44a0baedbe880f6634213625.tar.bz2
horizon-7c5c18d46757416f44a0baedbe880f6634213625.tar.xz
horizon-7c5c18d46757416f44a0baedbe880f6634213625.zip
hscript: Implement Runner.Execute.nameserver.*
Diffstat (limited to 'hscript/network.cc')
-rw-r--r--hscript/network.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/hscript/network.cc b/hscript/network.cc
index f728aef..28e382b 100644
--- a/hscript/network.cc
+++ b/hscript/network.cc
@@ -348,8 +348,21 @@ Key *Nameserver::parseFromData(const std::string &data, int lineno,
return new Nameserver(lineno, data);
}
-bool Nameserver::execute(ScriptOptions) const {
- return false;
+bool Nameserver::execute(ScriptOptions opts) const {
+ if(opts.test(Simulate)) {
+ std::cout << "printf 'nameserver %s\\" << "n' " << _value
+ << " >>/target/etc/resolv.conf" << std::endl;
+ return true;
+ }
+
+ std::ofstream resolvconf("/target/etc/resolv.conf", std::ios_base::app);
+ if(!resolvconf) {
+ output_error("installfile:" + std::to_string(line),
+ "nameserver: couldn't write configuration to target");
+ return false;
+ }
+ resolvconf << "nameserver " << _value << std::endl;
+ return true;
}