diff --git a/systemd_units/minecraft-server.service b/systemd_units/minecraft-server.service new file mode 100644 index 0000000..965520c --- /dev/null +++ b/systemd_units/minecraft-server.service @@ -0,0 +1,31 @@ +[Unit] +Description=Private Minecraft server +After=network.target + +[Service] +Restart=on-abort +Type=simple +User=minecraft +WorkingDirectory=/opt/minecraft/server +ExecStartPre=/usr/bin/env bash update.sh +ExecStart=/usr/bin/env bash start.sh +ExecStop=/usr/bin/env bash stop.sh +KillMode=mixed +KillSignal=SIGQUIT +TimeoutStopSec=10s + +# Security +PrivateTmp=true +ProtectSystem=full +NoNewPrivileges=true +ProtectControlGroups=true +ProtectKernelModules=true +ProtectKernelTunables=true +PrivateDevices=true +RestrictAddressFamilies=AF_INET +RestrictNamespaces=true +RestrictRealtime=true +SystemCallArchitectures=native + +[Install] +WantedBy=multi-user.target diff --git a/systemd_units/update.sh b/systemd_units/update.sh index 1efa33f..da99e7b 100755 --- a/systemd_units/update.sh +++ b/systemd_units/update.sh @@ -8,7 +8,7 @@ function prettyPrint() { } # Grab all service names -declare -a services=('mirror-bot' 'uno-bot') +declare -a services=('minecraft-server' 'mirror-bot' 'uno-bot') # Now loop through each service and install it for service in "${services[@]}"; do