summaryrefslogtreecommitdiff
path: root/hscript/meta.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-14 12:26:36 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-14 12:26:36 -0500
commit6847b25a62d320b6b7f050b88a2ab27e1ecd91cb (patch)
treeaa13c2c3ac9f2a0710f55600fc5508e22cf7fa27 /hscript/meta.cc
parentaacaf526065b0a138b0c65b421c92c4c6562c810 (diff)
downloadhorizon-6847b25a62d320b6b7f050b88a2ab27e1ecd91cb.tar.gz
horizon-6847b25a62d320b6b7f050b88a2ab27e1ecd91cb.tar.bz2
horizon-6847b25a62d320b6b7f050b88a2ab27e1ecd91cb.tar.xz
horizon-6847b25a62d320b6b7f050b88a2ab27e1ecd91cb.zip
hscript: Handle domain names
Diffstat (limited to 'hscript/meta.cc')
-rw-r--r--hscript/meta.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/hscript/meta.cc b/hscript/meta.cc
index 994278c..4d051f4 100644
--- a/hscript/meta.cc
+++ b/hscript/meta.cc
@@ -116,6 +116,27 @@ bool Hostname::execute(ScriptOptions opts) const {
hostname_f << actual;
}
+ /* The second condition ensures that it isn't a single dot that simply
+ * terminates the nodename. */
+ if(dot != std::string::npos && this->_value.length() > dot + 1) {
+ const std::string domain(this->_value.substr(dot + 1));
+ if(opts.test(Simulate)) {
+ output_info("installfile:" + std::to_string(this->lineno()),
+ "hostname: set domain name '" + domain + "'");
+ std::cout << "printf 'dns_domain_lo=\"" << domain
+ << "\"\\" << "n' >> /target/etc/conf.d/net" << std::endl;
+ } else {
+ std::ofstream net_conf_f("/target/etc/conf.d/net");
+ if(!net_conf_f) {
+ output_error("installfile:" + std::to_string(this->lineno()),
+ "hostname: could not open /etc/conf.d/net for "
+ "writing");
+ return false;
+ }
+ net_conf_f << "dns_domain_lo\"" << domain << "\"" << std::endl;
+ }
+ }
+
return true;
}