diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-03-11 11:44:42 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-03-11 11:44:42 -0500 |
commit | b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336 (patch) | |
tree | a95e0ccf5242a2c1a52b118dd04138a64d3f7546 /hscript/user.cc | |
parent | bcff79985ebe4c2d09eda749a99a005dc65b6b52 (diff) | |
download | horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.tar.gz horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.tar.bz2 horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.tar.xz horizon-b8f4ce3bdb1f3ea76eef1c0c4fd7dd5d29259336.zip |
hscript: Make target directory configurable
This is the first step towards creating images using Horizon.
Diffstat (limited to 'hscript/user.cc')
-rw-r--r-- | hscript/user.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/hscript/user.cc b/hscript/user.cc index 82d627c..81deafd 100644 --- a/hscript/user.cc +++ b/hscript/user.cc @@ -143,17 +143,21 @@ bool RootPassphrase::execute() const { if(script->options().test(Simulate)) { std::cout << "(printf '" << root_line << "\\" << "n'; " - << "cat /target/etc/shadow | sed '1d') > /tmp/shadow" + << "cat " << script->targetDirectory() << "/etc/shadow |" + << "sed '1d') > /tmp/shadow" << std::endl - << "mv /tmp/shadow /target/etc/shadow" << std::endl - << "chown root:shadow /target/etc/shadow" << std::endl - << "chmod 640 /target/etc/shadow" << std::endl; + << "mv /tmp/shadow " << script->targetDirectory() + << "/etc/shadow" << std::endl + << "chown root:shadow " << script->targetDirectory() + << "/etc/shadow" << std::endl + << "chmod 640 " << script->targetDirectory() + << "/etc/shadow" << std::endl; return true; } #ifdef HAS_INSTALL_ENV /* This was tested on gwyn during development. */ - std::ifstream old_shadow("/target/etc/shadow"); + std::ifstream old_shadow(script->targetDirectory() + "/etc/shadow"); if(!old_shadow) { output_error("installfile:" + std::to_string(this->lineno()), "rootpw: cannot open existing shadow file"); @@ -175,7 +179,8 @@ bool RootPassphrase::execute() const { old_shadow.close(); - std::ofstream new_shadow("/target/etc/shadow", std::ios_base::trunc); + std::ofstream new_shadow(script->targetDirectory() + "/etc/shadow", + std::ios_base::trunc); if(!new_shadow) { output_error("installfile:" + std::to_string(this->lineno()), "rootpw: cannot replace target shadow file"); @@ -349,9 +354,10 @@ bool UserIcon::validate() const { } bool UserIcon::execute() const { - const std::string as_path("/target/var/lib/AccountsService/icons/" + - _username); - const std::string face_path("/target/home/" + _username + "/.face"); + const std::string as_path(script->targetDirectory() + + "/var/lib/AccountsService/icons/" + _username); + const std::string face_path(script->targetDirectory() + "/home/" + + _username + "/.face"); output_info("installfile:" + std::to_string(line), "usericon: setting avatar for " + _username); @@ -363,8 +369,10 @@ bool UserIcon::execute() const { std::cout << "curl -LO " << as_path << " " << _icon_path << std::endl; } - std::cout << "cp " << as_path << " " << face_path << ".icon" << std::endl; - std::cout << "chown $(hscript-printowner /target/home/" << _username + std::cout << "cp " << as_path << " " << face_path << ".icon" + << std::endl; + std::cout << "chown $(hscript-printowner " << script->targetDirectory() + << "/home/" << _username << ") " << face_path << ".icon" << std::endl; std::cout << "ln -s .face.icon " << face_path << std::endl; return true; |