Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set up a Minecraft server System 10.8

Here’s a recipe for setting up Minecraft server on OS X. Since I don’t fully trust the server not to have some security hole, I want it to run as user nobody so it doesn’t have a lot of permissions. And I also want it to restart automatically when I reboot the computer. Finally I show how to backup the worlds you create.

There’s three parts to this hint.

1) creating the launchDaemon that starts the minecraft server.
2) how to turn it on and off
3) maintaining backups

The first step is to download the minecraft server jar file from the Mojang website. Currently that site is https://minecraft.net/download but that might change in the future. And currently the jar filename is: minecraft_server.1.6.2.jar, but that will change too.

1) Creating a place for it. When you run the jar the first time it’s going to create a lot of files and subdirectories the in the current working directory (CWD) so we want to create a nice place to do this. It doesn’t matter where this it, but the permissions on the folder do matter. I put mine in /opt

sudo -s -
mkdir -p /opt/minecraft_server/state

Now if your user name is bob then move the minecraft jar into place:

mv /User/bob/Downloads/minecraft_server.1.6.2.jar /opt/minecraft

and make sure the top level folder and executable are owned by root. This will assure that no one can change the jar file without root access. Since the system is going to invoke this file automatically you don’t want it changing with simple user level permissions.

chown -R root:wheel /opt/minecraft<em>server
chmod -R a+xr  /opt/minecraft</em>server

Minecraft is going to run as user nobody, and it will need permission to modify the state folder contents.

chown nobody /opt/state
chmod 755 /opt/state

2) Creating the launch daemon:

As root, create the file

/Library/LaunchDaemons/net.minecraft.plist

The file name is not important, but it’s tradition to name the Daemon for website that it came from. You need to create this as root or otherwise assure it’s owned by root:wheel and can be read. It’s not an executable.


<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
           <string>net.minecraft</string>
        <key>RunAtLoad</key>
           <true/>
        <key>WorkingDirectory</key>
           <string>/opt/minecraft_server/state</string></p>

<pre><code>     &lt;key&gt;UserName&lt;/key&gt;
        &lt;string&gt;nobody&lt;/string&gt;

    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
            &lt;string&gt;/usr/bin/java&lt;/string&gt;
            &lt;string&gt;-Xmx1024M&lt;/string&gt;
    &lt;string&gt;-Xms1024M&lt;/string&gt;
    &lt;string&gt;-jar&lt;/string&gt;
    &lt;string&gt;/opt/minecraft_server/minecraft_server.1.6.2.jar&lt;/string&gt;
    &lt;string&gt;nogui&lt;/string&gt;
    &lt;/array&gt;
</code></pre>

<p></dict>
</plist>
The above is plist speak to tell it that it should change into the working directory where we want it to store its data, then launch the java jar with a memory size of 1G. You can adjust the values for your system if that turns out to be too much. It also tells it to run the job as the username nobody. And it will start the server when the Daemon is loaded, which happens either at boot time or if you explicitly tell the daemon to load.

The key thing here is that the paths to the “state” folder and the executable are hardcoded. You must change these paths if you set this up in a different place.

2) testing it. first make sure you have java installed. /usr/bin/java -version if java is installed then this will reply with the java version at that path. If it’s not installed OSX will usually ask you if you want to install java and then automagically do this for you.

as root, (sudo -s -) run the following: launchctl load /Library/LaunchDaemons/net.minecraft.plist

test to see if it worked:

ps auxww | grep java | grep jar

does the output include something like this:


nobody          1405   0.5 10.8  3814720 681608   ??  Rs   Mon06PM  25:58.23 /usr/bin/java…

If so then the server jar is running and is running as nobody.

If not then you made a mistake. To help diagnose this try running the command right from the command line.


cd /opt/minecraft<em>server/state
/usr/bin/java -Xmx1024M -Xms1024M -jar /opt/minecraft</em>server/minecraft_server.1.6.2.jar 
note, at this point you are running the server as root. This is reasonably safe, assuming you trust mojang, to do for a moment just to eliminate the permission issues. If you are nervous, disconnect your ethernet cable for a moment.

You may see some java exceptions printed in the process, but if the program stays running then it’s working. Once it stops printing stuff out, type ctrl-c to kill it. List the current directory (state) and you will see a whole bunch of files and folders have been created. So now you know the program and the paths are right. You’ll need to find the error you made. Most likely a permissions issue.

2) controlling it. to load the server by hand:

sudo launchctl load /Library/LaunchDaemons/net.minecraft.plist

it will start when you load it the first time.

to stop the server temporarily

sudo launchctl stop net.minecraft

Here I used the name not the path. The name is one given in the plist file not the actual file name. Normally you want to make these the same for sanity sake. This command stops the server but it doesn’t remove the autostart Daemon—next boot it will start again.

to restart it after stopping:

sudo launchctl start net.minecraft

to unload the daemon (so it won’t autostart at boot)

sudo launchctl unload  /Library/LaunchDaemons/net.minecraft.plist

If you edit the plist file, you need to stop the server and unload the daemon then (re)load the daemon. Otherwise it will ignore your edits till next reboot.

3) backing up the state. from time to time you may want to back up the state of your minecraft world and the server configuration (banned-IP, whitelist, config…)

To do that:


sudo -s -
cd /opt/minecraft_server
find ./state | sudo cpio -dpl <code>date "+%y%m%d-%H%M-minecraft"</code>

this command will create a snapshot backup of the state of your system. This will look like a copy off the state directory tree and files. But it’s not a copy. It’s a hardlinked image. It doesn’t actually occupy any (significant) disk space unless your world is changed. The command names the new snapshot for the date and time down to the hour.

You can restore an older image to being the current state by deleting the current state folder and moving the state folder from the image folder to the minecraft working directory.

Lex adds: I haven’t tested this one.

  Post a comment  •  Comments (4)  
  • Currently 2.27 / 5
  You rated: 4 / 5 (11 votes cast)
 
[16,460 views]  View Printable Version
Find devices connected to your AirPort base station without AirPort Utility 5.6 Network

AirPort Utility 5.6 could show you all the devices connected to your AirPort base station—wired and wireless alike. AirPort Utility 6.x, however, only lists devices connected to your base station over Wi-Fi. There’s no way to use the app to list off the IP addresses and names of devices plugged directly into the base station.

You can stil grab the old version of the utility from Apple, though you need a little help to install the app on Mountain Lion, since the installer (falsely) reports that AirPort Utility 5.6 is incompatible with Mac OS X 10.8.

But while you can force AirPort Utility 5.6 to install on Mountain Lion, there’s no guarantee that the app will continue to work on OS X 10.9 Mavericks or beyond. So if you want to find the IP addresses of other devices connected directly to your base station, you might prefer another option.

There are several.

In Terminal, you can use the arp -na command, which will list out devices it finds using the address resolution protocol. You won’t necessarily see friendly names for the devices it finds, but you’ll at least get a list of all the local IP addresses in use that it discovers.

You can also turn to multiple third-party apps. One such app, iNet, is available on the Mac App Store. There are iOS apps for the same purpose, like the free Fing and the $3 LAN Scan.

Those apps will, if possible, list off friendlier device names (in addition to IP addresses) than arp -na offers.

  Post a comment  •  Comments (9)  
  • Currently 3.00 / 5
  You rated: 3 / 5 (7 votes cast)
 
[36,900 views]  View Printable Version
Unlock an iOS device with a Bluetooth keyboard iOS devices

When you lock your iPhone or iPad with a passcode, the general process for using your device is that you hit the sleep/wake button or the Home button, slide to unlock, and then tap in your passcode. But, as our old friend David Chartier pointed out at Finer Things, you can skip a step if you use an external Bluetooth keyboard.

Presuming your keyboard is already paired to the iOS device, you don't even need to touch the iPad or iPhone at all to unlock it. Press a key on your keyboard to wake the device up, and then typing in your passcode. The iOS device understands what you're trying to do, and jumps to the passcode entry screen automatically.

Once you finish typing in your code, your iOS device is unlocked and ready to go.

  Post a comment  •  Comments (4)  
  • Currently 1.89 / 5
  You rated: 1 / 5 (9 votes cast)
 
[8,456 views]  View Printable Version
Add full screen mode support to apps lacking it System 10.8
Some applications will never get full screen support. Here's a workaround.

1. Install SIMBL, http://www.culater.net/software/SIMBL/SIMBL.php.

2. Install Maximizer, http://chpwn.com/apps/maximizer.html.

3. Optional, but recommended step. Maximizer breaks full screen in some applications that already support it. To add it on a per application-basis edit SIMBLTargetApplications key from '/Library/Application Support/SIMBL/Plugins/Maximizer.bundle/Contents/Info.plist' by appending entries like explained at http://code.google.com/p/simbl/wiki/Tutorial, no. 3.

Example for TextEdit.

<key>SIMBLTargetApplications</key>
	<array>
		<dict>
			<key>BundleIdentifier</key>
			<string>com.apple.TextEdit</string>
			<key>MaxBundleVersion</key>
			<string>*</string>
			<key>MinBundleVersion</key>
			<string>*</string>
		</dict>
	</array>
Use the following applescript as a trigger with shortcut ⌃⌘F and scope per application(s) in Quicksilver (http://qsapp.com) or use a hotkey application, to enable/disable full screen mode.

tell application "System Events" to tell (first process whose frontmost is true)
	delay 0.05 -- tweak it as necessary
	if front window exists then
		tell front window
			if value of attribute "AXFullScreen" then
				set value of attribute "AXFullScreen" to false
			else
				set value of attribute "AXFullScreen" to true
			end if
		end tell
	end if
end tell
Lex adds: I haven't tested this one.
  Post a comment  •  Comments (10)  
  • Currently 1.23 / 5
  You rated: 2 / 5 (13 votes cast)
 
[8,682 views]  View Printable Version
Tell Siri who's who: "Jason Snell is my boss" iOS devices
You know all the different tasks Siri can help you accomplish with your recent iPhone, iPad, or iPod touch. But perhaps you didn't realize you can teach Siri to help you save even more time when use the assistant for certain tasks.

I frequently use Siri to place calls to, or send iMessages to, my wife. She's one of two Lauren's in my address book; specifying to my iPhone each time that I'd like it to "Call Lauren Friedman's iPhone" would quickly grow tiresome.

Instead, I taught Siri who Lauren is: I triggered Siri, and then said, "Lauren Friedman is my wife." Siri then asked me if if I wanted it to remember that fact; I unsurprisingly responded in the affirmative.

Because I've done that, I can now tell Siri "Call my wife" or "iMessage my wife that I'm on my way home."

And you can use a lot more than spousal relationships. Siri knows that Jason Snell is my boss, Dan Miller is my editor, and Dan Moren is my mentor. You can use pretty much any noun, in fact. Siri can identify my in-laws, my parents, my siblings, and even my landscaper by those nicknames. Just hold down the Home button, announce that "[Person in my contacts] is my [noun of your choosing]," and Siri gets the picture.

Fun bonus fact: Siri treats husbands and wives as interchangeable: If you set your wife with Siri, and then ask Siri to call your husband, you'll reach the same person either way.
  Post a comment  •  Comments (6)  
  • Currently 1.86 / 5
  You rated: 3 / 5 (22 votes cast)
 
[7,629 views]  View Printable Version
Hide TextEdit's ruler by default Apps

If, like me, you wish that TextEdit did not show its ruler by default, this hint is for you.

TextEdit displays the ruler by default when creating or opening rich text documents. I find the ruler visually cluttering and distracting, and I rarely ever need it.

Unfortunately, TextEdit does not offer a way to turn off the ruler by default in its Preferences window. But it can be done using the following simple steps:

  1. Quit TextEdit if it is running.
  2. Enter the following command into a Terminal window: defaults write com.apple.TextEdit ShowRuler 0
  3. Open TextEdit.
  4. Enjoy increased visual and mental tranquility.

You can always show the ruler if you need it for something by pressing ⌘R or choosing Format > Text > Show Ruler from TextEdit's menus.

To revert TextEdit to its default setting, repeat steps 1 to 3 above, but use this command in Terminal instead: defaults delete com.apple.TextEdit ShowRuler

  Post a comment  •  Comments (13)  
  • Currently 2.11 / 5
  You rated: 2 / 5 (9 votes cast)
 
[5,629 views]  View Printable Version
Access dozens of awesome high-res screen saver images on your Mac for desktop backgrounds Apps
As first pointed out by OS X Daily, Mountain Lion's built-in screen savers cycle through a couple dozen awesome photos, across several categories, with images of space, nature, and more. The images are huge—and thus make great desktop backgrounds.

To find the images, use the Go To Folder command in the Finder (from the Go menu) and navigate here:

/System/Library/Frameworks/ScreenSaver.Framework/Versions/A/Resources/Default Collections/

There, you'll find four folders full of high-resolution imagery. You can copy them elsewhere, or even access the images from right where they are. Simply fire up the Desktop & Screen Saver preference pane, click the Plus (+) icon at the left, and add the folders—or individual images—as desired.
  Post a comment  •  Comments (3)  
  • Currently 4.18 / 5
  You rated: 4 / 5 (11 votes cast)
 
[6,929 views]  View Printable Version
Split WordPress XML files for upload to servers Internet
I've been doing some work on my website, Kirkville, changing to a new theme. In order to test the theme, I set up a staging server, and wanted to import my existing posts, comments, etc. so I could fiddle with the new theme.

I'm not SQL-savvy, so it seemed the best bet was to use WordPress's export/import feature, through its wordpress-importer plugin. This requires exporting an XML file of the WordPress content from the current server, then importing it on the staging server. Unfortunately, I was hit by that problem where my hosting company has uploads limited to 8 MB, and my WordPress XML file was 10.9 MB.

When I went looking for solutions, I found a number of posts on the WordPress forum suggesting splitting the XML file. I wasn't sure how to do this safely, but found a free Mac utility called WXR Splitter. Running this tool, I split the XML file into two pieces, with a maximum of 6 MB each. I was able to upload the XML file, and get to work with my new theme.
  Post a comment  •  Comments (1)  
  • Currently 2.00 / 5
  You rated: 2 / 5 (5 votes cast)
 
[6,661 views]  View Printable Version
Open new tab in Safari on the left Web Browsers
This script opens a new Safari window if none is open, maximizes the front window if minimized, and opens a new focused tab on the left with your bookmarks, with the text caret in the address bar.

I Googled for such a script to no avail so I made it myself. Bound it to ⌘T and scope Safari in Quıcĸsıɩⅴεʀ (of course you're using Quıcĸsıɩⅴεʀ, what else?) or any other lesser hotkey application. You can still use New Tab menu item to open tabs on the right by changing the shortcut in the Keyboard Shortcuts section of System Preferences, say to ⇧⌘T.

If you open bookmarks:// you may notice a flicker when setting the focus on the first tab. It may be due to the applescript command used — if you find a better method put it in the comments. Also, I used clicking "Open Location…" instead of setting the "AXFocused" attribute because the item hierarchy changes when in full screen mode.

tell application "Safari"
	if windows is {} then
		make new document
	else
		tell first window
			if miniaturized then
				set miniaturized to false
				make new tab at beginning with properties {URL:"bookmarks://"}
				set current tab to first tab
				tell application "System Events" to tell process "Safari" to tell menu bar 1 to tell menu bar item "File" to tell menu 1 to click menu item "Open Location…"
			else
				make new tab at beginning with properties {URL:"bookmarks://"}
				set current tab to first tab
				tell application "System Events" to tell process "Safari" to tell menu bar 1 to tell menu bar item "File" to tell menu 1 to click menu item "Open Location…"
			end if
		end tell
	end if
end tell
  Post a comment  •  Comments (0)  
  • Currently 3.00 / 5
  You rated: 5 / 5 (8 votes cast)
 
[6,008 views]  View Printable Version
Make a UTC Dashboard clock widget Desktop
The OS X Dashboard doesn't include a Clock widget specifically for GMT/UTC (Universal Coordinated Time). Even if you try choosing London, which is usually GMT, it doesn't always match UTC—since London observes daylight savings time.

If you would like to have a clock that always shows the current UTC time, a good option is to use Freetown in Africa. They use UTC+00:00, and don't ever change throughout the year.
  Post a comment  •  Comments (4)  
  • Currently 2.82 / 5
  You rated: 1 / 5 (11 votes cast)
 
[10,771 views]  View Printable Version