From 4396b9eca410f389fbe9639c1ebabc6936a3f099 Mon Sep 17 00:00:00 2001 From: finga Date: Sun, 24 Apr 2022 17:33:09 +0200 Subject: [PATCH] Use `cargo-deb` to build a Debian package This ships also a systemd service unit and a config file for `/etc/default` --- Cargo.toml | 11 +++++++++++ debian/default | 10 ++++++++++ debian/service | 11 +++++++++++ 3 files changed, 32 insertions(+) create mode 100644 debian/default create mode 100644 debian/service diff --git a/Cargo.toml b/Cargo.toml index d539411..ad3d347 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,14 @@ env_logger = "0.9" tokio = { version = "1.17", features = ["rt-multi-thread", "macros"] } axum = "0.5" clap = { version = "3.1", features = ["derive"] } + +[package.metadata.deb] +extended-description = "Prometheus exporter for the MightyOhm Geiger Counter." +section = "utility" +maintainer-scripts = "debian/" +systemd-units = { enable = true } +assets = [ + ["target/release/mightyohm-gc-exporter", "usr/bin/", "755"], + ["README.md", "usr/share/doc/mightyohm-gc-exporter/README", "644"], + ["debian/default", "etc/default/mightyohm-gc-exporter", "644"], +] diff --git a/debian/default b/debian/default new file mode 100644 index 0000000..e19cecb --- /dev/null +++ b/debian/default @@ -0,0 +1,10 @@ +ARGS="" + +# mightyohm-gc-exporter supports the following options: +# -a, --address
The IPv4 or IPv6 address where the metrics are served +# [default: 127.0.0.1] +# -b, --baud-rate The baudrate of the serial connection [default: 9600] +# -p, --port The port where the metrics are served [default: 9111] +# -s, --serial-port The port of the serial device, usually in '/dev/...' +# [default: /dev/serial0] +# -t, --timeout Timeout of the serial connection in ms [default: 1000] diff --git a/debian/service b/debian/service new file mode 100644 index 0000000..cf71344 --- /dev/null +++ b/debian/service @@ -0,0 +1,11 @@ +[Unit] +Description=MightyOhm Geiger Counter exporter + +[Service] +Group=dialout +Restart=always +EnvironmentFile=/etc/default/mightyohm-gc-exporter +ExecStart=/usr/bin/mightyohm-gc-exporter $ARGS + +[Install] +WantedBy=multi-user.target