public
Description: Big Brother Bot B3 is a complete and total server administration package for online games. B3 is designed primarily to keep your server free from the derelicts of online gaming, but offers more, much more.
Home | Edit | New

Remote Installation

B3 Remote Installation

Requirements

  • big brother bot 1.1.x (source install is better)
  • ftptail (which requires perl)
  • a remote mysql database
  • a gameserver with ftp access
  • the scripts provided

Instructions

Scripts

B3 Control Script (b3-control-srv1)


#!/bin/bash

  1. SETTINGS ############
  1. the user that must be used to run the bot
    USER=foo
  1. the big brother bot main config file
    B3_CONFIGFILE=“/usr/local/b3/b3-server1.xml”
  1. where b3_run_obj.py is located
    B3_BIN=“/usr/bin/b3_run”
  1. where the python binary is located
    PYTHON_BIN=/usr/bin/python
  1. SETTINGS END ############

set e
DEBUG=off
B3_OPTS="
-config $B3_CONFIGFILE"
B3_PID_FILE=“${HOME}/.b3-$(echo $B3_CONFIGFILE | tr ‘/’ ‘_’).pid”

if [ ! -f “$B3_CONFIGFILE” ]; then
echo “ERROR: config file not found ($B3_CONFIGFILE)”
exit 1
fi

if [ ! -f “$B3_BIN” ]; then
echo “ERROR: file not found : ‘$B3_BIN’”
exit 1
fi
if [ ! -x “$B3_BIN” ]; then
echo “ERROR: cannot execute ‘$B3_BIN’”
exit 1
fi
if [ ! -f “$PYTHON_BIN” ]; then
echo “ERROR: file not found : ‘$PYTHON_BIN’”
exit 1
fi
if [ ! -x “$PYTHON_BIN” ]; then
echo “ERROR: cannot execute ‘$PYTHON_BIN’”
exit 1
fi

if [ “$(whoami)” != “$USER” ]; then
echo “ERROR: you have to run that script as $USER
exit 1
fi

function debug() {
if [ “$DEBUG” = “on” ]; then
echo DEBUG: $@
fi
}

function do_start {
cd $(dirname $B3_BIN)
$PYTHON_BIN $B3_BIN $B3_OPTS &
echo $! > $B3_PID_FILE
}

function do_stop {
NB_PROCESS=`ps ax | grep b3_run | grep “$B3_CONFIGFILE” | grep -v grep | wc -l`
if [ $NB_PROCESS -gt 1 ]; then
echo “ERROR: multiple b3 processes found, you’d better kill thoses processes by hand.”
elif [ $NB_PROCESS -eq 1 ]; then
if [ -f $B3_PID_FILE ]; then
PID=$(cat $B3_PID_FILE)
NB_PROCESS=`ps hax $PID | grep b3_run | grep “$B3_CONFIGFILE” | grep -v grep | wc -l`
if [ $NB_PROCESS -eq 1 ]; then
kill -15 $PID
else
echo “ERROR: process N° $PID does not seem to be b3”
echo “kill b3 by hand”
fi
fi
else
echo “WARNING: are you sure b3 is running ?”
fi
}

kill_programme() {
PID=`ps hax | grep “b3_run” | grep “$B3_CONFIGFILE” | grep -v grep | cut -d’ ’ -f1 | head -n1`
echo “killing process [$PID]”
kill -9 $PID
}

case “$1” in
start)
echo “Starting Big Brother Bot”
NB_PROCESS=`ps ax | grep b3_run | grep “$B3_CONFIGFILE” | grep -v grep | wc -l`
if [ $NB_PROCESS -eq 0 ]; then
do_start
else
echo “ERROR: b3 is already running”
fi
;;
stop)
echo -n “Stopping Big Brother Bot”
do_stop
echo “.”
;;

restart) echo -n “Restarting Big Brother Bot”

do_stop
sleep 1
do_start
;;

status)
debug “status:”
NB_PROCESS=`ps ax | grep b3_run | grep “$B3_CONFIGFILE” | grep -v grep | wc -l`
debug “NB_PROCESS: $NB_PROCESS”
if [ $NB_PROCESS -gt 1 ]; then
echo “WARNING: multiple b3 processes found !”
elif [ $NB_PROCESS -eq 1 ]; then
echo “running :)”
else
echo “not running :(”
fi
;;
pstatus)
debug “status:”
NB_PROCESS=`ps ax | grep b3_run | grep “$B3_CONFIGFILE” | grep -v grep | wc -l`
debug “NB_PROCESS: $NB_PROCESS”
if [ $NB_PROCESS -gt 1 ]; then
echo “WARNING: multiple b3 processes found !”
elif [ $NB_PROCESS -eq 1 ]; then
echo “1”
else
echo “0”
fi
;;

kill)

kill_programme
;;
*)
PROG_NAME=`basename $0`
echo “Usage: $PROG_NAME {start|stop|restart|status}”
exit 1
esac

exit 0

Server Control Script (server-1-control)


#!/bin/bash
echo “Starting FTPTail”
echo ""
cd /usr/local/b3/
./log-control-srv1 restart
sleep 5
echo “Starting B3Bot”
echo ""
cd /usr/local/b3
./b3-control-srv1 restart
while true
do
echo “Checksum test for logfile 1”
chksum1=`md5sum /usr/local/b3/srv-1-log.txt`
echo “MD5Sum for logfile 1 = $chksum1”
sleep 60
echo “Checksum test for logfile 2”
chksum2=`md5sum /usr/local/b3/srv-1-log.txt`
echo “MD5Sum for logfile 2 = $chksum2”
if [ “$chksum1” = “$chksum2” ]
then
echo “Logfiles are identical, restarting bot”
cd /usr/local/b3
./log-control-srv1 restart
sleep 10
cd /usr/local/b3
./b3-control-srv1 restart
fi
b3status=`./b3-control-srv1 pstatus`
if [ “$b3status” = “0” ]
then
./b3-control-srv1 start
fi
done

Last edited by thepoopsmith, Fri Jun 05 07:51:22 -0700 2009
Home | Edit | New
Versions: