commit d339a20c4d38e8bac4cbe3dbcb2e9baf0858771b Author: Sheppy Date: Mon Sep 3 18:44:07 2018 +0200 Initial diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..45482a8 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +This work does not have the required threshold of originality to be considered for copyright it should therefore be considered to be in the Public Domain. diff --git a/README b/README new file mode 100644 index 0000000..1333ed7 --- /dev/null +++ b/README @@ -0,0 +1 @@ +TODO diff --git a/example-check-stop.sh b/example-check-stop.sh new file mode 100644 index 0000000..3b8a01e --- /dev/null +++ b/example-check-stop.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# if condition + systemctl stop example.sevice diff --git a/example-deactivate-check.service b/example-deactivate-check.service new file mode 100644 index 0000000..4a96cfa --- /dev/null +++ b/example-deactivate-check.service @@ -0,0 +1,6 @@ +[Unit] +Description=Check if unit example.service should be stopped. + +[Service] +Type=oneshot +ExecStart=/absolute/path/to/example-check-stop.sh diff --git a/example-deactivate-check.timer b/example-deactivate-check.timer new file mode 100644 index 0000000..f530624 --- /dev/null +++ b/example-deactivate-check.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Continiously check if example.service should be stopped +After=example.service +PartOf=example.service + +[Timer] +OnUnitActiveSec=15min +OnActiveSec=14min +Persistent=false +Unit=sheppy-minecraft-autodeactivate.service diff --git a/example-socket-proxy.service b/example-socket-proxy.service new file mode 100644 index 0000000..fdb1dab --- /dev/null +++ b/example-socket-proxy.service @@ -0,0 +1,10 @@ +[Unit] +Description=socket proxy example.service +After=example.service +Requires=example.service + +[Service] +ExecStart=/lib/systemd/systemd-socket-proxyd 127.0.0.1:PORT_NUMBER_HERE + +[Install] +WantedBy=multi-user.target diff --git a/example.service b/example.service new file mode 100644 index 0000000..4276bc1 --- /dev/null +++ b/example.service @@ -0,0 +1,32 @@ +[Unit] +Description=minecraft server +After=network.target +Requires=sheppy-minecraft-autodeactivate.timer + +[Service] +Type=simple +User=minecraft +WorkingDirectory=/home/minecraft/server/ +Nice=2 +CPUAffinity=0,3 + +## exit status of mcrcon on success, 143 ist SIGTERM in java, the default for mc +SuccessExitStatus=2 3 143 255 + +ExecStart=/absolute/path/to/example.sh +ExecStop=pkill example.sh + +TimeoutStopSec=30 +Restart=always +RestartSec=60 + +## RES CONTROL ## +MemoryLow=2G +MemoryHigh=4G +## Java VM Limit is 4GB so this should never happen ## +MemoryMax=6G +CPUQuota=100% + + +[Install] +WantedBy=multi-user.target diff --git a/example.sh b/example.sh new file mode 100644 index 0000000..7839f74 --- /dev/null +++ b/example.sh @@ -0,0 +1,2 @@ +#!/bin/sh +sleep 600 diff --git a/example.socket b/example.socket new file mode 100644 index 0000000..ac0b81e --- /dev/null +++ b/example.socket @@ -0,0 +1,11 @@ +[Unit] +Description=Socket Activator for example.service +PartOf=example-proxy.service + +[Socket] +ListenStream=PORT_NUMBER_HERE +BindIPv6Only=both +Accept=false + +[Install] +WantedBy=multi-user.target