summaryrefslogtreecommitdiff
path: root/hscript/script_e.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-08 00:09:44 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-08 00:09:44 -0600
commit7e8be6bd6f6e487d3444f70f01240c542b5f8b0b (patch)
tree048b37f9fff624cf6cb374bc0f4843a21ca0992d /hscript/script_e.cc
parent3ab436a3d897b7fc76ed9e1718198bc6f012e286 (diff)
downloadhorizon-7e8be6bd6f6e487d3444f70f01240c542b5f8b0b.tar.gz
horizon-7e8be6bd6f6e487d3444f70f01240c542b5f8b0b.tar.bz2
horizon-7e8be6bd6f6e487d3444f70f01240c542b5f8b0b.tar.xz
horizon-7e8be6bd6f6e487d3444f70f01240c542b5f8b0b.zip
hscript: Implement UserIcon::execute, add tests
Diffstat (limited to 'hscript/script_e.cc')
-rw-r--r--hscript/script_e.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/hscript/script_e.cc b/hscript/script_e.cc
index 85c43d3..f8c4ff6 100644
--- a/hscript/script_e.cc
+++ b/hscript/script_e.cc
@@ -25,6 +25,36 @@
namespace Horizon {
+static bool icon_dir_created = false;
+
+void maybe_create_icon_dir(ScriptOptions opts) {
+ if(icon_dir_created) return;
+ icon_dir_created = true;
+
+ if(opts.test(Simulate)) {
+ std::cout << "mkdir -p /target/var/lib/AccountsService/icons"
+ << std::endl
+ << "chown root:root /target/var/lib/AccountsService/icons"
+ << std::endl
+ << "chmod 775 /target/var/lib/AccountsService/icons"
+ << std::endl;
+ return;
+ }
+#ifdef HAS_INSTALL_ENV
+ else {
+ error_code ec;
+ if(!fs::exists("/target/var/lib/AccountsService/icons", ec)) {
+ fs::create_directories("/target/var/lib/AccountsService/icons",
+ ec);
+ if(ec) {
+ output_error("internal", "couldn't create icon dir",
+ ec.message());
+ }
+ }
+ }
+#endif /* HAS_INSTALL_ENV */
+}
+
bool Script::execute() const {
bool success;
error_code ec;
@@ -497,6 +527,7 @@ bool Script::execute() const {
}
}
if(acct.second->icon) {
+ maybe_create_icon_dir(opts);
EXECUTE_OR_FAIL("usericon", acct.second->icon)
}
}