Every repository with this icon (
Every repository with this icon (
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
- SETTINGS ############
- the user that must be used to run the bot
USER=foo
- the big brother bot main config file
B3_CONFIGFILE=“/usr/local/b3/b3-server1.xml”
- where b3_run_obj.py is located
B3_BIN=“/usr/bin/b3_run”
- where the python binary is located
PYTHON_BIN=/usr/bin/python
- SETTINGS END ############
set
e-config $B3_CONFIGFILE"
DEBUG=off
B3_OPTS="
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
fiif [ ! -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
fiif [ “$(whoami)” != “$USER” ]; then
echo “ERROR: you have to run that script as $USER”
exit 1
fifunction 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
restart) echo -n “Restarting Big Brother Bot”
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 “.”
;;do_stop
sleep 1
do_start
;;status)
kill)
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_programme
;;
*)
PROG_NAME=`basename $0`
echo “Usage: $PROG_NAME {start|stop|restart|status}”
exit 1
esacexit 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






