From 53bcb39a23c88724bf00fb1b48eb4b3aa75667b8 Mon Sep 17 00:00:00 2001 From: Lane Shaw Date: Sun, 27 Jun 2021 18:40:58 -0400 Subject: [PATCH] Added mscs@.service template for starting individual servers as systemd units. --- Makefile | 4 +++- mscs@.service | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 mscs@.service diff --git a/Makefile b/Makefile index e29cfb0..6422f0a 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ MSCTL := /usr/local/bin/msctl MSCS := /usr/local/bin/mscs MSCS_INIT_D := /etc/init.d/mscs MSCS_SERVICE := /etc/systemd/system/mscs.service +MSCS_SERVICE_TEMPLATE := /etc/systemd/system/mscs@.service MSCS_COMPLETION := /etc/bash_completion.d/mscs UPDATE_D := $(wildcard update.d/*) @@ -28,6 +29,7 @@ update: install -m 0644 mscs.completion $(MSCS_COMPLETION) if which systemctl; then \ install -m 0644 mscs.service $(MSCS_SERVICE); \ + install -m 0644 mscs@.service $(MSCS_SERVICE_TEMPLATE); \ fi @for script in $(UPDATE_D); do \ sh $$script; \ @@ -36,7 +38,7 @@ update: clean: if which systemctl; then \ systemctl -f disable mscs.service; \ - rm -f $(MSCS_SERVICE); \ + rm -f $(MSCS_SERVICE) $(MSCS_SERVICE_TEMPLATE); \ else \ update-rc.d mscs remove; \ rm -f $(MSCS_INIT_D); \ diff --git a/mscs@.service b/mscs@.service new file mode 100644 index 0000000..a4c53bc --- /dev/null +++ b/mscs@.service @@ -0,0 +1,18 @@ +[Unit] +Description=Minecraft Server Control Script for server %i +Documentation=https://github.com/MinecraftServerControl/mscs +Requires=network.target +After=network.target + +[Service] +User=minecraft +Group=minecraft +Environment="PATH=/usr/local/bin:/usr/bin:/bin" +ExecStart=/usr/local/bin/mscs start %i +ExecStop=/usr/local/bin/mscs stop %i +ExecReload=/usr/local/bin/mscs restart %i +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target