Sunday, January 18, 2009

AutoTunnel - Persistent SSH tunnel connection for Socks Proxy

Recently, I had a need to create a persistent tunnel to a remote host to be utilized as a Socks proxy. After having been annoyed with gstm's inability to start hidden, and the lack of an option to re-establish a broken tunnel; I've whipped up a simple script to replace it. If you are connecting to the net and surfing from an internet cafe or any other location where you don't want to worry with the person sitting next to you capturing your unencrypted traffic due to a mis-configured access point, this may be the script for you.

Establishing an ssh connection as a socks proxy is pretty simple, the syntax is:

ssh -D port user@host

This is unfortunately limited to a timeout that's very high. To work around it, I added a few options to force a client side timeout. Then I tell ssh to compress, and I wrap it in a fork with simple logic to look for active interfaces and a sleep.

AutoTunnel will test the connection every 10 seconds and if it's broken, check to ensure you have an interface with a valid IP before retrying.

To run it, extract the zip package (URL) make the autotunnel script executable. Now, create a new session entry for it in GNOME with the syntax as follows: /path/to/autotunnel user@host. If you would like GUI notifications, make sure libnotify-bin is installed on your computer.

To use it, set your application to use a Socks proxy with an address of localhost and a port of 8888.

It should be packaged and available in the apt repository over the next few days.

Saturday, January 3, 2009

Packaging Simcity 3000 for Linux for installation on Ubuntu

In this article, we will package Simcity 3000 Unlimited into a re-usable debian package. Once completed, you will have a single binary that can be re-installed any time you need to re-install your operating system, and should also survive major distribution upgrades without change.

At a minimum to build .deb packages on the debian platform you'll need to install a few extra packages.

'sudo apt-get install devscripts fakeroot dh-make'

First, follow my article published last year (URL) and walk through creating a working instance of Simcity 3000 unlimited.

Next, download my Simcity 3000 debian template here: (URL)

Extract the template, and copy the following files from /usr/local/games/SC3U to simcity-3000-1.0.1/usr/share/games/SC3U. Be cautious not to overwrite the Loki_Compat directory that exists in the template.

When complete, if you change into the simcity-3000-1.0.1 directory, and issue an 'ls usr/share/games/SC3U' you should see the following files:

bacustom
buildings
hotkeys.txt
icon.xpm
Loki_Compat
README
README.dynamic
sc3bat
sc3u.dynamic
sys
barender
cities
icon.bmp
lib
plugin
README-2.0a
res
sc3bat.dynamic
sc3u.ini
snapshot.ini
uninstall

If a sc3u or sc3u.sh file exists, delete it.

Now that the files are ready for packaging, you should reverse the process you went through to install SimCity 3000, as it will conflict with files in this package. This package integrates all of the changes required to install Simcity on recent versions of Ubuntu or other Debian derivatives.

Once you have uninstalled the manual Simcity 3000 installation, change into simcity-3000-1.0.1 and build your debian package.

'debuild -us -uc'

If it completes successfully, 'cd ..' and install your new package with 'dpkg -i ./simcity-3000*deb' or double click the package name in your GUI file browser.

Click the Simcity 3000 icon in Applications -> Games, and enjoy Simcity 3000! Be sure to backup your newly created .deb package incase you need to re-install your operating system in the future.

Packaging Starcraft for installation on Ubuntu or other Debian Linux

Something I read about all the time is the difficulty in installing applications in Wine, or just general maintenance of non-packaged software. In this article I'll show you how to easily package Starcraft for installation on Ubuntu or any other debian derivative using a simple template which is linked from the article.

To package software on debian, you need the following packages installed:

'sudo apt-get install devscripts fakeroot dh-make'

To run the game, or to install the resulting package, install wine:

'sudo apt-get install wine'

Download my Starcraft debian package template here: (URL)

Alternately, download my Warcraft II template here: (URL), it is identical to the Starcraft template, except it is for Warcraft II. To apply; simply change anything that says Starcraft to Warcraft in this article.

Please do not take advantage of this template to redistribute Blizzards copy-written works, it is intended for your own use only and the requirement to install the software implies that you own a copy of the software we will be packaging today.

For best results, I recommend starting with a fresh wine directory. If you already have a .wine directory you would like to save, just move it then move it back later.

'mv .wine wine_ilike'

Install Starcraft and Broodwar (if available) using the normal installation media; then install the Starcraft no-cd patch from blizzard here: (URL). Do not launch the game before completing this process, or the package steps may not work properly. If you did run the game by mistake, delete ~/.wine and start over.

Note: The following assumes you are working in ~/starcraft-1.0.x

Once you have finished installing and patching Starcraft; change to ~/.wine/drive_c/Program\ Files then into the Blizzard directory.

Move the starcraft directory and all sub directories to ~/starcraft-1.0.x/usr/local/games/Starcraft, be careful not to overwrite the starcraft.reg file that is currently in usr/local/games/Starcraft.

In the starcraft-1.0.3 directory; The output of 'ls' should look like:

debian
readme.txt
usr

The output of 'ls ./usr/local/games/Starcraft' should look like:

battle.snp
bnupdate.log
Broodwar.mpq
License.html
maps
Readme.cnt
sc.ico
SEditESP.loc
SEditPTB.loc
StarCraft.exe
StarEdit.cnt
StarInst.log
bncache.dat
BrooDat.mpq
BwarInst.log
License.txt
Patch_rt.mpq
Readme.hlp
SEditDEU.loc
SEditFRA.loc
Smackw32.dll
StarCraft.mpq
StarEdit.exe
storm.dll
bnupdate.exe
BroodUnits.doc
EditLocal.dll
Local.dll
patch.txt
Riched20.dll
SEditENU.loc
SEditITA.loc
standard.snp
StarDat.mpq
StarEdit.hlp

Look in each file under the debian subdirectory and change the email address to your email address wherever necessary.

From the project root (starcraft-*/); build the package.

debuild -us -uc

If all is successful, you will now have an installable .deb in your ".." directory.

starcraft_1.0.3_i386.deb

Install this package by double clicking it in the GUI, or from the cli by running:

'dpkg -i starcraft_1.0.3_i386.deb'

You will get an icon in your games menu which you can click, or just run "starcraft" to execute the game. Save this package for later re-installation if you need to reinstall the OS.

If you saved a .wine directory, you can now put it back.

'rm -rf .wine; mv wine_ilike .wine'