Friday, December 16, 2011

Mineserv: Automatic Start/Stop Perl Init Script

I was getting tired of having to manually start and stop my Minecraft server whenever the server rebooted and I couldn't make backups without manually disabling level saving first. I wasn't too happy with the shell script alternatives so I wrote my own version with Perl.


Because the Minecraft server does not support daemon processes you need a program called "GNU Screen" which creates a virtual terminal that can run in the background and be re-attached when needed.

To install screen, in Debian based operating systems, run:
`sudo apt-get install screen`
For other distributions check your package manager.
Source can be found here.

This script should be very easy to modify and add functionality to and would work nicely for other services that require screen to run with a little bit of modification.
Let me know if you add any functionality or re-hash the script for something else and I can post it here. Please share alike.

Download: mineserv

Installing the Script
- Install "screen" if you don't already have it
- Edit the SETTINGS variables to fit your server environment.
- Make a copy of the file in /etc/init.d/
- Make it executable: sudo chmod a+x /etc/init.d/mineserv
- Add it to the init list: sudo update-rc.d mineserv defaults

Uninstalling the Script
- Simply delete the file: sudo rm /etc/init.d/mineserv
- Remove from the init list: update-rc.d -f mineserv defaults

Using the Script
- Usage: /etc/init.d/mineserv {start|stop|restart|status|backup|cleanup [days]}
(Backup makes a .tar.gz archive of the world folder in the backup directory
(Cleanup deletes backups older than [days] given in the backup directory)

- To send a command to the server console: /etc/init.d/mineserv command "your command"
- To bring up the server console run: screen -r mineserv (Make sure run as the correct user)
-To give items to players: mineserv give [player] [item id] [amount]
This command will allow you to give more than 64 items at a time so specify any amount!

Monday, February 14, 2011

A Parser for GNUSim8085 Assembler Listings


Update: I am happy to announce that this functionality based off of my code will be added to GNUSim8085 in version 1.3.8.

I've been building an 8 bit microcomputer (still a work in progress) around the classic Intel 8085 processor. I found this excellent open source program, GNUSim8085, a "graphical simulator, assembler and debugger for the Intel 8085 microprocessor in Linux and Windows."

This program was extremely useful for writing and debugging my operating system. Unfortunately it had no ability to assemble the program to a binary in order to burn it to ROM, forcing me to hand assemble my programs in a hex editor.

To fix this, I wrote a parsing tool in C, it takes a GNUSim8085 assembler listing and strips out the hex data and OP codes to a binary file.

Download: gnuasm85.c


Update: I was able to get it to compile in GCC for windows, you can grab the compiled .exe here.
Instructions: Open up your assembly program in GNUSim85, make sure it runs. Set the "Load me at" value to the proper address offset. Then hit Ctrl + L to generate an assembler listing of your program and save it. Then run that assembler listing through gnuasm85 like so, "gnuasm85 foo.asm -o foo.bin".