Skip to content

Commit

Permalink
default target wants and chown
Browse files Browse the repository at this point in the history
  • Loading branch information
cryi committed Jul 15, 2024
1 parent 8c6fcc1 commit 3c7c1b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/systemctl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.2.5
9 changes: 7 additions & 2 deletions src/systemctl/systemctl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,18 @@ function systemctl.install_service(sourceFile, serviceName, options)
if type(container) == "string" and container ~= "root" then
-- get home directory from passwd file
local _home = get_user_home(container)
local _ok, _uid = fs.safe_getuid(container)
ami_assert(_ok, "Failed to get " .. container .. "uid - " .. (_uid or ""))

local unitStorePath = _home .. "/.config/systemd/user/"
local unitStorePath = _home .. "/.config/systemd/user/default.target.wants"
local _ok, _error = fs.safe_mkdirp(unitStorePath)
assert(_ok, "failed to create user unit store directory - " .. (_error or ""))
-- // TODO: chown

local _ok, _error = fs.safe_copy_file(sourceFile, unitStorePath .. serviceName .. "." .. options.kind)
assert(_ok, "failed to install " .. serviceName .. "." ..options.kind .. " - " .. (_error or ""))

local _ok, _error = fs.chown(unitStorePath, _uid, _uid, { recurse = true })
ami_assert(_ok, "Failed to chown reports - " .. (_error or ""))
else
local _ok, _error = fs.safe_copy_file(sourceFile, "/etc/systemd/system/" .. serviceName .. "." .. options.kind)
assert(_ok, "failed to install " .. serviceName .. "." ..options.kind .. " - " .. (_error or ""))
Expand Down

0 comments on commit 3c7c1b9

Please sign in to comment.