jSettlers Startup Bash Script

I don't know about the rest of you, but I love to play Settlers of Catan. I downloaded a copy of jSettlers, and whipped up this quick Bash script to run it.

It's pretty simple, but it takes care of starting three computer players, as well as cleaning up after you quit. You'll need to have jSettlers and all its prerequisites installed in order for this work correctly.

Here's the code for it (some word-wrapping may occur), or you can download the script and an icon.

Source Code

              #! /bin/bash
              
              JSettlersDir="/usr/games/jsettlers-1.0.6" #Change this for your path to jSettlers.
              NUM_PLAYERS=3
              
              if ! [ -e /var/run/mysqld/mysqld.sock ]; then
                  sudo mysqld &
              fi
              
              java -jar ${JSettlersDir}/JSettlersServer.jar 8880 10 root "" &
              server_proc_id=$!
              echo "Server Process ID: $server_proc_id"
              
              sleep 5s
              
              for ((num=1; num<=NUM_PLAYERS; num++)); do
                  java -cp ${JSettlersDir}/JSettlersServer.jar soc.robot.SOCRobotClient localhost 8880 "Computer"${num} "" &
                  CATANID[$num]=$!
                  echo "Computer${num} Process ID: ${CATANID[$num]}"
              done
              
              java -jar ${JSettlersDir}/JSettlers.jar localhost 8880
              
              for ((num=1; num<=NUM_PLAYERS; num++)); do
                  echo "Cleaning up: killing ${CATANID[$num]}"
                  kill ${CATANID[$num]};
              done
              echo "Cleaning up: killing $server_proc_id"; kill $server_proc_id;
              exit 0
          

Downloads

You can download the script and an icon.

To Do:

Currently, this script uses a poor choice for authentication to the server for the computer players. Eventually, I'll add some sort of dialog boxes to prompt for that.



Tags

  • Linux
  • Settlers of Catan

Revisions

  • 8/27/2005 - Code section added, no longer limited to a download.
  • 8/25/2005 - Article published.