Update on the 'Craft
:: Posted in Tech by Jason Thaxter ::So a couple of interesting updates on the last.
"Verifying" the Minecraft.app dir seems to have worked on one machine. I assume it won't work if the program updates its dependencies. That's as it should be. I'm a little worried about maybe having "authorized" Java in general. That's the hard part about doing this stuff disconnected; it's hard to remember your last state. You will make mistakes. Lots of l337ers have gotten caught that way.
On another OS X foldy-slab, I have a guest account, fairly restricted. Didn't try the "verify" trick. Do get a "this application was downloaded at" warning every time. OK.
So here are sensible, safe instructions for starting Minecraft on OS X:
- Open the app.
- Click through the "this application was downloaded at" dialog, if you get it. But please read it and see if that was when you downloaded it. Possibly not for the last time.
- Get out of fullscreen mode, if you are in it.
- Go to Multiplayer.
- Approve the Application Firewall changes. Possibly not for the last time.
- Dig.
Now for the fun stuff. FreeBSD now has a minecraft port. Not necessarily up-to-date. They've had issues with ports due to a break-in last Nov-Dec. They are being appropriately paranoid. No idea if that is why the port can lag, but it could be. End result is that the minecraft_server.jar can have bad checksums. You can hack the minecraft-server/Makefile and minecraft-server/distinfo with new info, as I did, to upgrade from 1.4.6 to 1.5.1. No biggie, if you are using portstnap (of course you are), your hack should get blown away next update.
Anyway, once you have it installed once, upgrades are no biggie. And the main reason to use the port at all is to get the startup script and a semi-sane way of handling data and configs. Most data stuff is in /usr/local/share/minecraft-server. But configs are symlinked into /usr/local/etc/minecraft. Enable in /etc/rc.conf in the usual way. Now the minecraft service is started inside a tmux session, as the user mcserver.
Oh, sorry, I said the fun stuff. That stuff was good, but here's the fun part.
First, set up /usr/local/etc/sudoers.d/minecraft:
# Can do anything as mcserver
User_Alias MCADMIN = cooluser, root, mcserver
MCADMIN ALL=(mcserver) NOPASSWD:ALL
Isn't that fun. Now cooluser - presumably you - can run any command as mcserver. Not much danger there, it's a restricted user to begin with. Now cooluser can do this in a shell rc file (bash, zsh):
# Minecraft
alias mcadmin="sudo -u mcserver tmux attach -t minecraft"
alias mcbackup="/usr/local/share/minecraft-server/mcbackup.sh"
Now cooldude (hey, got any pizza?) can access the minecraft server console, and make timestamped backups (details of tarfiles as an excercise for the user). Oh, but what about that mcbackup script?
#!/bin/shMCDIR=/usr/local/share/minecraft-serversudo -u mcserver tmux send-keys -t minecraft:0 'say SERVER BACKUP STARTING. Server going readonly...' C-m
sudo -u mcserver tmux send-keys -t minecraft:0 'save-off' C-m
sudo -u mcserver tmux send-keys -t minecraft:0 'save-all' C-m
cd $MCDIR
sudo -u mcserver tar zcfv backups/world-`date "+%Y.%m.%d_%H.%M"`.tbz world
sudo -u mcserver tmux send-keys -t minecraft:0 'save-on' C-m
This alerts users what the admin is doing. Then it turns off auto-saving, so that the backup can proceed without internal changes resulting in an inconsistency (same misfortune as trying to back up a database from a filesystem backup). In other words, you don't want the minecraft server saving a chunk of the world in the middle of a world data file you are backing up. You have no way of knowing what that might do. If you don't know what I mean, look under world (or whatever you call it) and try to figure out what those files do, and what's inside them. Think chunks of space, changing while they are being copied. So let's not do that. Instead, we stop auto saving, then save everyting at once to be consistent, then back up the whole world, then put things back to normal. It would be polite to announce that we are done, I guess.
Oh, see that "backups" directory? You want to create that, and do this so mcserver user can write to it:
cd /usr/local/share/minecraft-server
mkdir backups
chown mcserver:mcserver backups
chmod 775 backups
That makes the directory to hold the backup packages, makes it owned (ch-ange own-er) by the mcserver user, and ch-anges modification rights to be "user can do all, group can do all, others can look".
That's a bit of UNIX to learn Minecraft. But if you've used the Minecraft console (the in-game one, not the admin one), you've already learned a few things: tab to complete a command with a guess, and up-arrow to scroll through the history of commands. Those are common to a Windows CMD console too.
Anyhoo. Be a geek. It's good for you. You can be one who lives in a world made by others, or be a maker.