summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-12-20 14:59:15 +0100
committerxengineering <me@xengineering.eu>2025-12-20 14:59:15 +0100
commitb1bd87926098e03ffd983666d0746055122854fd (patch)
tree7fa825d503cfb5410db7b8bbd402e51c9d8debb1
parent5f3cd750b2867854a1e05f66312062426024f676 (diff)
downloadsia-server-b1bd87926098e03ffd983666d0746055122854fd.tar
sia-server-b1bd87926098e03ffd983666d0746055122854fd.tar.zst
sia-server-b1bd87926098e03ffd983666d0746055122854fd.zip
systemd: Add service and sysusers configuration files
This makes it possible to run the Sia server executable on systemd-based Linux distributions with systemd making system administration easier. Maintaining these files in the source instead of packaging repository was decided since systemd is the dominant init system across Linux distributions and thus not every distribution-specific packaging repo needs to re-invent the wheel.
-rw-r--r--meson.build3
-rw-r--r--systemd/meson.build4
-rw-r--r--systemd/sia-server-sysuser.conf1
-rw-r--r--systemd/sia-server.service12
4 files changed, 20 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index a2654de..b37da0b 100644
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,7 @@ project(
)
subdir('configs')
+subdir('systemd')
go = find_program('go', required : true)
tar = find_program('tar', required : true)
@@ -31,6 +32,8 @@ sia_server_linux_amd64 = custom_target(
artifacts = [
sia_server_linux_amd64,
default_config,
+ systemd_service,
+ sysuser_config,
]
archive = custom_target(
diff --git a/systemd/meson.build b/systemd/meson.build
new file mode 100644
index 0000000..5296400
--- /dev/null
+++ b/systemd/meson.build
@@ -0,0 +1,4 @@
+fs = import('fs')
+
+systemd_service = fs.copyfile(meson.current_source_dir() / 'sia-server.service')
+sysuser_config = fs.copyfile(meson.current_source_dir() / 'sia-server-sysuser.conf')
diff --git a/systemd/sia-server-sysuser.conf b/systemd/sia-server-sysuser.conf
new file mode 100644
index 0000000..14fc0ec
--- /dev/null
+++ b/systemd/sia-server-sysuser.conf
@@ -0,0 +1 @@
+u sia-server - "Sia server system user" -
diff --git a/systemd/sia-server.service b/systemd/sia-server.service
new file mode 100644
index 0000000..3738d9a
--- /dev/null
+++ b/systemd/sia-server.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Sia IoT server
+After=network.target mosquitto.service
+Wants=network.target mosquitto.service
+
+[Service]
+User=sia-server
+Group=sia-server
+ExecStart=/usr/bin/sia-server -config /etc/sia-server/config.json
+
+[Install]
+WantedBy=multi-user.target