From b1bd87926098e03ffd983666d0746055122854fd Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 20 Dec 2025 14:59:15 +0100 Subject: 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. --- meson.build | 3 +++ systemd/meson.build | 4 ++++ systemd/sia-server-sysuser.conf | 1 + systemd/sia-server.service | 12 ++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 systemd/meson.build create mode 100644 systemd/sia-server-sysuser.conf create mode 100644 systemd/sia-server.service 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 -- cgit v1.2.3-70-g09d2