Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # Take your world directory name as an argument
- world=$1
- # Set homedir (in case you run your server from somewhere else)
- homedir="/home/minecraft"
- # If no world name passed, then set to default "world"
- if [ -z "$world" ];then
- world="world"
- fi
- # Does the world directory even exist?
- if [ -e "$homedir/$world" ]
- then
- # Swap the "level-name=" value with the pased name
- cat "$homedir"/server.properties | sed 's\level-name=.*$\level-name='$world'\g'> /tmp/serverprops.temp
- # Write to a temp file, then swap it to the main file (to avoid read/write clashes; I read that somewhere...
- mv /tmp/serverprops.temp "$homedir"/server.properties
- # Start the server so we don't have to type in the cryptic command line every.damn.time
- java -jar -Xms1024M -Xmx1024M /usr/lib/minecraft/minecraft_server.1.8.1-pre5.jar nogui
- # ..and if the world DOESN'T exist... complain
- else
- printf "Error - world \"$world\" not found\n"
- exit 1
- fi
- # All done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement