documentation
download & extend
community & support
B3 hosting
May 21, 2012, 05:17:06 PM
Home
Features
Get Started
Supported Games
Forums
Help
Search
Tags
Groupware
Login
Register
Activation Mail
It appears you have not registered with our community. To register please click here ...
You are here:
Big Brother Bot Forum
Add-Ons
Configurations
(Moderator:
MordyT
)bash script to start/stop/restart b3
Pages: [
1
]
2
3
Go Down
« previous
next »
Print
Author
Topic: bash script to start/stop/restart b3 (Read 9810 times)
Courgette
Senior Dev.
OS: Linux
Type: Home user
Posts: 3483
Offline
Support Specialty:
B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
bash script to start/stop/restart b3
«
on:
July 29, 2008, 10:59:14 AM »
Hi
This is the script I use to start my b3 bot from linux.
It makes sure b3 is not already running before starting and does not kill the bot when you leave the console.
Note: I don't know is this work if you installed B3 as an egg.
Usage :
./bigbrotherbot <start|stop|restart|status>
when started, python does not give you back the console, so just hit the Enter Key to get it back. Then you can quit the console safely.
Copy/paste the following code into a file called 'bigbrotherbot' and make it executable
(chmod +x bigbrotherbot)
Code:
#!/bin/bash
########### SETTINGS ############
## the user that must be used to run the bot
USER=b3
## the big brother bot main config file
B3_CONFIGFILE="/home/urt/b3conf/b3.xml"
## where b3_run.py is located
B3_BIN="/home/urt/b3_run.py"
## where the python binary is located
PYTHON_BIN=/usr/bin/python
########### 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
;;
kill)
kill_programme
;;
*)
PROG_NAME=`basename $0`
echo "Usage: $PROG_NAME {start|stop|restart|status}"
exit 1
esac
exit 0
«
Last Edit: September 12, 2008, 12:25:40 AM by xlr8or
»
Logged
Follow me :
@cucurb
.~. new
Smokin' guns official website
xlr8or
[ www.xlrstats.com ]
Project Lead
OS: Linux
Type: Owner dedicated server(s)
Gameservers:
CoD, CoD2, CoD5, UrT
Posts: 2022
Offline
Support Specialty:
B3-Core, CoD/UrT/WoP/ETPro parsers, Plugin development
Re: bash script to start/stop/restart b3
«
Reply #1 on:
July 29, 2008, 11:52:24 PM »
I'm using a very small restarter script from within screen. It automatically restarts the server/bot when it crashes (not when it hangs tho).
http://www.snt.utwente.nl/wiki/Howto_Server_Restarter
When you have multiple accounts that should be able to access the running processes for the gameserver and/or bot we have a more comprehensive set of scripts available, but it is quite a hassle to set it up. Interested how it looks? Take a look here:
http://www.snt.utwente.nl/wiki/Howto_StartStopScripts
Logged
Github repo
-
Groupware
Deemer
Jr. Member
Posts: 17
Offline
Re: bash script to start/stop/restart b3
«
Reply #2 on:
July 30, 2008, 10:02:00 AM »
Quote from: tomdesinto on July 29, 2008, 10:59:14 AM
Hi
This the script I use to start my b3 bot from linux.
It makes sure b3 is not already running before starting and does not kill the bot when you leave the console.
Tomdesinto,
I just wanted to thank you for your script. You have completely solved my b3 issues of having to manually restart it once a day. Thank you again!
«
Last Edit: July 30, 2008, 02:50:36 PM by ThorN
»
Logged
Deemer
Jr. Member
Posts: 17
Offline
Re: bash script to start/stop/restart b3
«
Reply #3 on:
July 30, 2008, 10:02:37 AM »
Can we sticky this???
Logged
Courgette
Senior Dev.
OS: Linux
Type: Home user
Posts: 3483
Offline
Support Specialty:
B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
Re: bash script to start/stop/restart b3
«
Reply #4 on:
July 30, 2008, 10:05:21 AM »
glad it help you ...
«
Last Edit: July 30, 2008, 11:32:24 AM by Courgette
»
Logged
Follow me :
@cucurb
.~. new
Smokin' guns official website
Huddex
Newbie
Posts: 1
Offline
Re: bash script to start/stop/restart b3
«
Reply #5 on:
December 03, 2008, 11:55:27 PM »
Is there anything similar for windows?
Logged
Bakes
B3 Contrib/Support
OS: --No B3 installed--
Type: --No B3 installed--
Posts: 1225
Offline
Support Specialty:
B3-Core, CoD/BFBC2 parsers, FTP-functionality, Plugin development
Re: bash script to start/stop/restart b3
«
Reply #6 on:
December 04, 2008, 09:36:35 AM »
not that I know of, but a quick autorestart script:
Code:
:TOP
path-to-b3_run eg C:\b3\b3_run.py
GOTO TOP
that will restart it
otherwise you could use firedaemon to do that for you.
Logged
[
Openbanter
|
Scrim (cod4)
|
BanTweeter
|
FTPyTail
|
ForumLink
]
Platanos
Beta Testers
OS: Linux
Type: Owner dedicated server(s)
Gameservers:
BF3,Cod2,Cod4,Cod5,Cod6,Cod7
Posts: 257
Offline
Re: bash script to start/stop/restart b3
«
Reply #7 on:
November 28, 2010, 02:54:27 PM »
Nice Script, but the Ingame Command !restart kills BB is there an Option do put --restart in the script?
LG
Logged
Courgette
Senior Dev.
OS: Linux
Type: Home user
Posts: 3483
Offline
Support Specialty:
B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
Re: bash script to start/stop/restart b3
«
Reply #8 on:
November 28, 2010, 03:23:19 PM »
just set
Code:
B3_OPTS="--config $B3_CONFIGFILE --restart"
Logged
Follow me :
@cucurb
.~. new
Smokin' guns official website
MordyT
Moderator
OS: Windows
Type: Gameserver Rental Co.
Gameservers:
2x CoD4, 1x BF3
Posts: 2625
Offline
Owner of Host4B3.com - Over 70 bots hosted!
Re: bash script to start/stop/restart b3
«
Reply #9 on:
December 26, 2010, 01:45:30 AM »
Trying to implement this but small issue: error: cannot execute b3_run.py
Logged
Need B3 Bot hosting? Check out
Host4B3.com
Check
Twitter.com/Host4B3
for updates if the site it down.
Help will be given to those with a b3.log
System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
epiacum
Jr. Member
OS: --No B3 installed--
Type: --No B3 installed--
Gameservers:
BFBC2
Posts: 42
Offline
Re: bash script to start/stop/restart b3
«
Reply #10 on:
January 22, 2011, 09:42:35 PM »
Quote from: MordyT on December 26, 2010, 01:45:30 AM
Trying to implement this but small issue: error: cannot execute b3_run.py
Same here, path is definately correct.
«
Last Edit: January 22, 2011, 09:45:48 PM by epiacum
»
Logged
v1ad
Jr. Member
OS: Linux
Type: Renting Server, no B3
Gameservers:
Black Ops
Posts: 29
Offline
Re: bash script to start/stop/restart b3
«
Reply #11 on:
February 16, 2011, 12:04:29 PM »
@ mordy chmod u+x b3_run.py
the chmod should be imported into the script. at least check 4 it.
Logged
MordyT
Moderator
OS: Windows
Type: Gameserver Rental Co.
Gameservers:
2x CoD4, 1x BF3
Posts: 2625
Offline
Owner of Host4B3.com - Over 70 bots hosted!
Re: bash script to start/stop/restart b3
«
Reply #12 on:
February 16, 2011, 12:43:33 PM »
Quote from: v1ad on February 16, 2011, 12:04:29 PM
@ mordy chmod u+x b3_run.py
the chmod should be imported into the script. at least check 4 it.
Will try and let you know. Thanks for the help!
Logged
Need B3 Bot hosting? Check out
Host4B3.com
Check
Twitter.com/Host4B3
for updates if the site it down.
Help will be given to those with a b3.log
System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
epiacum
Jr. Member
OS: --No B3 installed--
Type: --No B3 installed--
Gameservers:
BFBC2
Posts: 42
Offline
Re: bash script to start/stop/restart b3
«
Reply #13 on:
February 16, 2011, 01:09:06 PM »
Thanks, Im getting this :
ERROR: you have to run that script as b3
Logged
TmR
Full Member
OS: Windows
Type: Renting Server, no B3
Gameservers:
CoD7
Posts: 75
Offline
Re: bash script to start/stop/restart b3
«
Reply #14 on:
March 04, 2011, 03:42:36 AM »
Quote from: epiacum on February 16, 2011, 01:09:06 PM
Thanks, Im getting this :
ERROR: you have to run that script as b3
you should make a user called b3 i think, or change
Code:
## the user that must be used to run the bot
USER=b3
to your unix username (not really safe to use root imho)
-edit-
hm i couldnt change it to my user, so i did use root.
Gonna reboot now
-edit2-
works like a charm (using 3 b3 bots so far)
«
Last Edit: March 04, 2011, 05:54:53 AM by TmR
»
Logged
Tags:
Pages: [
1
]
2
3
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> News (Read Only)
===> News Archive
===> Website News
=> General Discussion
===> Servers
=> Shared Services
-----------------------------
Support Forums
-----------------------------
=> Support Instructions
=> Installation Support
=> General Usage Support
=> Game specific Support
===> Battle Field 3
=====> BF3/B3 beta board
===> Battle Field Bad Company 2
===> Call of Duty series
=====> CoD, CoD:UO, CoD2
=====> Call of Duty 4 (Modern Warfare)
=====> Call of Duty 5 (World at War)
=====> Call of Duty 6 (Modern Warfare 2)
=====> Call of Duty 7 (Black Ops)
=======> AlterOps
===> Frontlines, Fuel of War
===> Enemy Territory
===> Homefront
===> Medal of Honor 2010
===> Open Arena
===> Red Orchestra 2
===> Smokin' Guns
===> Soldier of Fortune 2
===> Urban Terror
===> World of Padman
===> Other games
-----------------------------
Add-Ons
-----------------------------
=> Plugins Discussion
===> Plugin Releases!
===> Plugins by xlr8or
===> Plugins by Courgette
===> Plugins by Freelander
===> Plugins by Bakes
===> Plugins by Ismael
===> Plugins by flinkaflenkaflrsk
===> Plugins by Anubis
===> Plugins by Spoon
===> Plugins by PtitBigorneau
===> Plugins by BlackMamba
===> Plugins by Beber888
===> Plugins by grosbedo
=> XLRstats
===> Weaponmodifiers
=> Echelon
===> Echelon version 2
=> Configurations
=> Installers
-----------------------------
Community Developers
-----------------------------
=> Plugin Developers
=> The Code Bin
Rate this page +1 at Google Search
Web Toolbar by Wibiya
SimplePortal 2.3.1 © 2008-2009, SimplePortal