A small tool to help you control your Ubuntu game server.
Setup the server files on your Ubuntu machine that run scripts.
The program knows if server is already running by checking if a file called .lock
exists in the server directory.
ℹ️ You can change the lock file name by adding the
LockFile
variable in the app's server configuration file.
Example script based on the Minecraft server:
#!/bin/bash
cleanup() {
rm -rf .lock
exit 1
}
trap cleanup INT TERM SIGINT SIGTERM EXIT
# Start the server and save the PID
java -Xmx4096M -Xms4096M -jar server.jar nogui & server_pid=$!
echo $server_pid > .lock
wait $server_pid
rm -rf .lock
After the first run, the program will create a configuration file in the app folder 'config.json'.
{
"IpAddress": "Server IP Address",
"MacAddress": "Server MAC Address (for Wake-on-LAN)",
"Username": "SSH Username",
"Password": "SSH Password",
"ServerInfoFilePath": "/path/to/server/info.json",
}
Fill in the fields with your server information.
Next, on your server, create a file called info.json
in the server directory. Here's an example of the file structure:
{
"ServerApps": [
{
"Name": "Minecraft",
"Location": "/home/athlon/servers/minecraft",
"StartCommand": "./start.sh"
},
{
"Name": "Killing Floor 2",
"Location": "/home/athlon/servers/kf2",
"StartCommand": "./start.sh"
},
{
"Name": "Killing Floor 2 (Objective)",
"Location": "/home/athlon/servers/kf2",
"StartCommand": "./start_objective.sh",
"LockFile": ".lock_obj"
},
{
"Name": "Killing Floor",
"Location": "/home/athlon/servers/kf/System",
"StartCommand": "./start.sh"
}
]
}
This file contains an array of server applications. Each application has a name, location, and start command. The location is the path to the server directory, and the start command is the command to start the server. The LockFile
field is optional and is used to specify a custom lock file name (default is .lock
).
Don't expect me to work on this program, I made it for myself and I'm sharing it with you. If you want to improve it, feel free to do so.