diff --git a/minecraft/vshojocraft.service b/minecraft/vshojocraft.service new file mode 100644 index 0000000..42edace --- /dev/null +++ b/minecraft/vshojocraft.service @@ -0,0 +1,21 @@ +[Unit] +Description=VshojoCraft +After=local-fs.target network.target + +[Service] +WorkingDirectory=/home/akanealw/minecraft/servers/vshojocraft-backup/ +User=akanealw +Group=akanealw +Type=forking +# Run it as a non-root user in a specific directory + +ExecStart=/usr/bin/tmux new-session -d -s vsjcraft; tmux send-keys 'cd /home/akanealw/minecraft/servers/vshojocraft' C-m; tmux send-keys './start.sh' C-m +# I like to keep my commandline to launch it in a separate file +# because sometimes I want to change it or launch it manually +# If it's in the WorkingDirectory, then we can use a relative path + +# Send "stop" to the Minecraft server console +ExecStop=/usr/bin/tmux attach -t vsjcraft; tmux send-keys 'stop' C-m + +[Install] +WantedBy=multi-user.target