Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thebertster/autominecraftserver
Scripts to automatically start and stop Minecraft Server
https://github.com/thebertster/autominecraftserver
minecraft minecraft-server shell-script
Last synced: 14 days ago
JSON representation
Scripts to automatically start and stop Minecraft Server
- Host: GitHub
- URL: https://github.com/thebertster/autominecraftserver
- Owner: thebertster
- Created: 2019-07-28T22:25:46.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-09-03T20:21:01.000Z (over 4 years ago)
- Last Synced: 2024-11-06T16:00:30.528Z (2 months ago)
- Topics: minecraft, minecraft-server, shell-script
- Language: Shell
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# autominecraftserver
## Scripts to automatically start and stop Minecraft Server### Instructions for use:
`sudo apt install openjdk-8-jre-headless screen xinetd`
`sudo adduser --system --group --home /opt/minecraft minecraft`
Download Minecraft Server to */opt/minecraft* and rename server JAR as *server.jar*
Set `server-port=25555` in server.properties
Copy **start.sh** and **stop.sh** to */opt/minecraft* and make them executable
`sudo -u minecraft /usr/bin/java -Xms1024M -Xmx1536M -jar server.jar nogui`
The Minecraft server should start and then stop saying the EULA needs to be accepted.
Set `eula=true` in */opt/minecraft/eula.txt*
Copy **minecraft** to */etc/xinetd.d*
`sudo systemctl restart xinetd`
Add `*/5 * * * * /opt/minecraft/stop.sh` to crontab for user minecraft (`sudo crontab -u minecraft -e`)
### What does it do?
xinetd daemon is listening on the default Minecraft Server port (25565). When a client connects, xinetd runs */opt/minecraft/start.sh*, which, on the first connection, spawns the Minecraft Server (configured to listen on port 25555) using screen and then executes **netcat** to send/receive traffic from the client on port 25565 to the Minecraft Server on port 25555 via the loopback interface.
The **cron** job runs every five minutes, checks whether the Minecraft server is running and if so issues the `list` server command to check whether there are any active users. If not, then after waiting two minutes and checking again, the server is stopped. If there are active users, the script prints a random comedy message (this can be commented out if not needed).