This little program will create a systemd service through a command line, only works on Linux, obviously 😉.
Report Bug
·
Request Feature
Table of Contents
When we need to create a systemd service, we often forget the syntax, and we have to search on the internet. This CLI, in addition to solve the former problem, allows to be used in a shell script, instead of copy-paste big block of systemd service template.
In order to get started, you just have to download the binary from the latest release. There are builds for amd64
and
arm64
architectures. Once you got the binary, you are ready to go !
Metsysd is a simple systemd service generator, because we never remember systemd service syntax
Usage: metsysd [OPTIONS] <COMMAND>
Arguments:
<COMMAND>
The command which will be executed when running the service
Options:
-n, --name <NAME>
Name of the service you want to create
--service-type <SERVICE_TYPE>
Defines the kind of service you want to run
See https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type= for more information
[possible values: simple, forking, oneshot, idle]
--restart <RESTART>
Defines the restart policy of the service
[possible values: always, on-failure, on-success, no]
--user <USER>
Specify the user running the service (it must exist)
--group <GROUP>
Specify the group running the service (it must exist)
--is-user
Defines your service as a service from your user (rootless). The service will start when the user runs a session on the host
--install-dir <INSTALL_DIR>
Define the directory to which the service should be installed. Only use when you know what you're doing
--daemon-reload
Run daemon-reload when service has been created
-d, --dry-run
Output the generated service in the console, instead of creating it
-h, --help
Print help information (use `-h` for a summary)
-V, --version
Print version information
You only need a linux system that is running systemd to manage services.
- Clone the repo
git clone https://github.com/AlexandreBrg/metsysd.git
- Install dependencies
cargo install --path .
- You are ready to rock !
You need to be root (or privileged) in order to create system-wide services. If you are not privileged, you can create a user scoped service.
-
Create a system-wide service that runs a binary
metsysd --service-type simple --restart always \ --name "my-service" "/usr/bin/sleep 3600"
-
Create a system-wide service that runs a binary called and runs as a specific user and group
metsysd --service-type simple \ --restart always --name "my-service" \ --user "my-user" --group "my-group" \ "/usr/bin/sleep 3600"
-
Create a system-wide service that runs a binary and is a one-shot service
metsysd --service-type oneshot \ --restart no --name "my-service" \ "/usr/bin/sleep 3600"
-
Create a user scoped service that runs a binary
metsysd --service-type simple --restart always \ --name "my-service" --is-user "/usr/bin/sleep 3600"
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Please remember community rules, see Github Contributing for more informations.