#!/bin/sh
# That there is an interpeter line, tells the OS what program to use to run this script.
#
# `$#' is the number of arguments passed to the script. The actual script name counts as one.
# If the script was invoked as just "game.sh" with no additional arguments, then "game.sh" is the
# first argument.
if [ $# == 1 ]; then
echo "Please select a game to play as an argument.";
echo "Examples are \"starcraft\" and \"wow\".";
exit 1;
# No game specified, so exit.
fi
# $1 is the second argument, or what comes immedatly after "game.sh" on the commandline.
# $0 is the "game.sh" argument, or program name argument.
if [ $1 == "starcraft" ]; then
# 'ntfs-3g' is the FUSE driver for read-write NTFS support.
if mount /dev/hdb1 /mnt/winc -t ntfs-3g -o rw; then
# If the mount failed, this wouldn't run.
cd /mnt/winc/StarCraft/;
wine starcraft.exe;
exit 0;
# The game ran, so exit with sucess (0)
else
echo "Mount failed!";
exit 1;
fi
fi
# 'fi' is how you end an 'if' block.
if [ $1 == "wow" ]; then
if mount /dev/hdb1 /mnt/winc -t ntfs-3g -o rw; then
# If the mount failed, this wouldn't run.
cd /mnt/winc/Program\ Files/Blizzard/World\ of\ Warcraft/;
wine WoW.exe -opengl;
exit 0;
# The game ran, so exit with sucess (0)
else
echo "Mount failed!";
exit 1;
fi
fi
# If the argument weasn't a valid game name, the code would reach this point.
# Also, you can encompass variable names in {}, but you still need the $ in front.
echo "Invalid game name: ${1}";
exit 1;