diff --git a/README.md b/README.md index d3d0c93..6c60c3c 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,11 @@ service file. Since these paths are specific to a machine, it's not recommended to check the service files into your respository. -You can generate and install the service file to the system with the following +You can generate and link the service file to the system with the following command: ```bash -$ lapis systemd service development --install +$ lapis systemd service development --link ``` You can then start your service: @@ -106,4 +106,3 @@ You can access the systemd journal with the `lapis.systemd.journal` module: journal = require("lapis.systemd.journal") journal.log("hello world!", {priority = 5}) ``` - diff --git a/lapis/cmd/actions/systemd.lua b/lapis/cmd/actions/systemd.lua index 8aa072d..51dec59 100644 --- a/lapis/cmd/actions/systemd.lua +++ b/lapis/cmd/actions/systemd.lua @@ -4,7 +4,7 @@ local parse_flags parse_flags = require("lapis.cmd.util").parse_flags return { name = "systemd", - usage = "systemd service [environment] [--install]", + usage = "systemd service [environment] [--link]", help = "create systemd service files", function(self, flags, command, environment) environment = environment or default_environment() @@ -15,10 +15,9 @@ return { render_service_file = require("lapis.systemd.service").render_service_file local contents, file, dir = render_service_file(config) path.write_file(file, contents) - if flags.install then + if flags.link then local src = path.shell_escape(tostring(dir) .. "/" .. tostring(file)) - local dest = path.shell_escape("/usr/lib/systemd/system/" .. tostring(file)) - path.exec("sudo cp '" .. tostring(src) .. "' '" .. tostring(dest) .. "'") + path.exec("sudo systemctl link '" .. tostring(src) .. "'") return path.exec("sudo systemctl daemon-reload") end end diff --git a/lapis/cmd/actions/systemd.moon b/lapis/cmd/actions/systemd.moon index 2ffe4c4..31435f2 100644 --- a/lapis/cmd/actions/systemd.moon +++ b/lapis/cmd/actions/systemd.moon @@ -3,7 +3,7 @@ import parse_flags from require "lapis.cmd.util" { name: "systemd" - usage: "systemd service [environment] [--install]" + usage: "systemd service [environment] [--link]" help: "create systemd service files" (flags, command, environment) => @@ -20,10 +20,9 @@ import parse_flags from require "lapis.cmd.util" path.write_file file, contents - if flags.install + if flags.link src = path.shell_escape "#{dir}/#{file}" - dest = path.shell_escape "/usr/lib/systemd/system/#{file}" - path.exec "sudo cp '#{src}' '#{dest}'" + path.exec "sudo systemctl link '#{src}'" path.exec "sudo systemctl daemon-reload" }