Skip to content

Commit

Permalink
Added mscs@.service template for starting individual servers as syste…
Browse files Browse the repository at this point in the history
…md units.
  • Loading branch information
LanetheGreat committed Jun 27, 2021
1 parent ee00f9a commit 53bcb39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*)
Expand All @@ -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; \
Expand All @@ -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); \
Expand Down
18 changes: 18 additions & 0 deletions mscs@.service
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 53bcb39

Please sign in to comment.