Skip to content

Generate systemd services with a CLI, written in Rust

License

Notifications You must be signed in to change notification settings

alexandrebrg/metsysd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo


This little program will create a systemd service through a command line, only works on Linux, obviously 😉.

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing

About The Project

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.

(back to top)

Getting Started

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

Prerequisites

You only need a linux system that is running systemd to manage services.

Setup development environment

  1. Clone the repo
    git clone https://github.com/AlexandreBrg/metsysd.git
  2. Install dependencies
    cargo install --path .
  3. You are ready to rock !

(back to top)

Usage

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"

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please remember community rules, see Github Contributing for more informations.

(back to top)

About

Generate systemd services with a CLI, written in Rust

Topics

Resources

License

Stars

Watchers

Forks

Languages