#!/bin/bash## BF2 Mod SVN Update&init Script 0.1## Written by Brandon Weeks <bjweeks16@gmail.com>.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA# Set this to "ia-32" for 32 bit or "amd-64" for 64 bitMACH="ia-32" # Comment for 64 bit#MACH="amd-64" # Uncomment for 64 bitBF2_DIR=/home/bf2/bf2SRC_DIR=/home/bf2MODNAME=warlordBINARY_DIR="$BF2_DIR/bin/$MACH"export LD_LIBRARY_PATH=$BINARY_DIRcheck() {PID=$(pgrep bf2)if [ $? == 0 ]then STATUS=0else STATUS=1fi}status() {if [ $STATUS == 0 ]then echo "The BF2 server is running."else echo "The BF2 server is not running."fi}stop() {if [ $STATUS == 0 ]then echo "Stopping BF2 server..." kill $PIDelse echo "The BF2 Server is not running." exit 0fisleep 1scheckif [ $STATUS == 0 ]then echo "WARNING: The BF2 server failed to stopped." exit 1else echo "BF2 server was stopped."fi}start() {if [ $STATUS == 0 ] then echo "BF2 server is already running." exit 0elif [ $UID == 0 ] then echo "Warning: Do not start the server as root." exit 1 else echo "Starting BF2 server..." cd $BF2_DIR exec $BINARY_DIR/bf2 +modPath mods/$MODNAME &> /dev/null & echo "BF2 Server Started."fi}update() { rm -rf $BF2_DIR/mods/$MODNAME svn update $SRC_DIR/$MODNAME svn export $SRC_DIR/$MODNAME /$BF2_DIR/mods/$MODNAME cd $BF2_DIR python lowercaseDir.py mods/$MODNAME} checkcase "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; update) update ;; *) echo "{start|stop|restart|status|update}" exit 0 ;;esacexit 0