You are here: Big Brother Bot ForumAdd-OnsConfigurations (Moderator: MordyT)Run B3 as a FreeBSD Daemon
Pages: [1]   Go Down
  Print  
Author Topic: Run B3 as a FreeBSD Daemon  (Read 1201 times) Bookmark and Share
Newbie
*
OS: Linux
Type: Owner dedicated server(s)
Gameservers: BFBC2
Posts: 2
Offline Offline
WWW
« on: May 24, 2011, 03:15:28 PM »

After doing a lot of searching and digging, I was finally able to modify and create a start up script for big brother bot for anyone who is running it on FreeBSD.

Credits go to wernerdev

The basic jist of how I have big brother bot setup on my server is as follows.

I have my start up script saved to:
/usr/local/etc/rc.d/b3
Code:
#!/bin/sh 
#
# PROVIDE: b3
# REQUIRE: mysql
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# b3_enable (bool):     Set to NO by default.
#                               Set it to YES to enable b3.
#

. /etc/rc.subr

name="b3"
rcvar=`set_rcvar`

load_rc_config ${name}

: ${b3_enable:="NO"}
: ${b3_user:="b3"}
: ${b3_dir:="/home/b3/bigbrotherbot"}
: ${b3_chdir:="${b3_dir}"}
: ${b3_pid:="${b3_dir}/b3.pid"}

status_cmd="${name}_status"
stop_cmd="${name}_stop"

command="/usr/sbin/daemon"
command_args="-f -p ${b3_pid} python ${b3_dir}/b3_run.py  -c ${b3_dir}/conf/b3.xml"

# Ensure user is root when running this script
if [ `id -u` != "0" ]; then
echo "Oops, you should be root before running this!"
exit 1
fi

verify_b3_pid() {
# Make sure the pid corresponds to the b3 process
pid=`cat ${b3_pid} 2>/dev/null`
ps -p ${pid} | grep -q "python ${b3_dir}/b3_run.py"
return $?
}

# Try to stop b3 cleanly
b3_stop() {
echo "Stopping $name"
verify_b3_pid
kill ${pid}
if [ -n "${pid}" ]; then
wait_for_pids ${pid}
echo "Stopped"
fi
}

b3_status() {
verify_b3_pid && echo "$name is running as ${pid}" || echo "$name is not running"
}

run_rc_command "$1"
With this script you can stop/start/restart/ and check the status of big brother bot, ie is it running or not.

I have big brother bot installed at /home/b3/bigbrotherbot with an unprivileged user, b3, that runs my big brother bot.

I also created a directory under /var/log/b3 that is owned by b3 as I like to have my logs in one place.  This ensures that the installation directory does not get clogged up with log files.

Other than that its pretty straight forward, hope this helps someone out as it drove me nuts for the past 2 days Smiley
Logged

Moderator
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2625
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #1 on: May 24, 2011, 06:02:55 PM »

thanks for sharing!
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
XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #2 on: May 25, 2011, 03:57:49 AM »

Nice post, thanks for sharing!
Logged

Newbie
*
OS: Linux
Type: Owner dedicated server(s)
Gameservers: BFBC2
Posts: 2
Offline Offline
WWW
« Reply #3 on: May 25, 2011, 03:35:55 PM »

One thing I forgot to mention, when configuring b3.xml and other scripts.  Use absolute paths for all logs/files.  Otherwise freebsd will attempt to write to /usr/local/etc/rc.d.

Here is my b3.xml as an example:
Code:
<configuration>
        <settings name="b3">
                <set name="parser">bfbc2</set>
                <set name="database">mysql://b3:emptyinside@localhost/b3</set>
                <set name="bot_name">NNG</set>
                <set name="bot_prefix">^0(^2NNG^0)^7:</set>
                <set name="time_format">%I:%M%p %Z %m/%d/%y</set>
                <set name="time_zone">CEST</set>
                <set name="log_level">9</set>
                <set name="logfile">/var/log/b3/b3.log</set>
        </settings>
        <settings name="bfbc2">
                <set name="max_say_line_length">100</set>
        </settings>
        <settings name="server">
                <set name="public_ip">whatever</set>
                <set name="port">19567</set>
                <set name="rcon_ip">whatever</set>
                <set name="rcon_port">48888</set>
                <set name="rcon_password">something</set>
                <set name="timeout">3</set>
                <set name="punkbuster">on</set>
        </settings>
        <settings name="autodoc">
                <set name="type">xml</set>
                <set name="maxlevel">100</set>
                <set name="destination">/home/b3/bigbrotherbot/commands.xml</set>
        </settings>
        <settings name="messages">
                <set name="kicked_by">$clientname was kicked by $adminname $reason</set>
                <set name="kicked">$clientname was kicked $reason</set>
                <set name="banned_by">$clientname was banned by $adminname $reason</set>
                <set name="banned">$clientname was banned $reason</set>
                <set name="temp_banned_by">$clientname was temp banned by $adminname for $banduration $reason</set>
                <set name="temp_banned">$clientname was temp banned for $banduration $reason</set>
                <set name="unbanned_by">$clientname was un-banned by $adminname $reason</set>
                <set name="unbanned">$clientname was un-banned $reason</set>
        </settings>
        <settings name="plugins">
                <set name="external_dir">@b3/extplugins</set>
        </settings>
        <plugins>
                <plugin name="spamcontrol" config="@conf/plugin_spamcontrol.xml"/>
                <plugin name="admin" config="@conf/plugin_admin.xml"/>
                <plugin name="pingwatch" config="@conf/plugin_pingwatch.xml" />
                <plugin name="adv" config="@conf/plugin_adv.xml"/>
                <plugin name="status" config="@conf/plugin_status.xml"/>
                <plugin name="welcome" config="@conf/plugin_welcome.xml"/>
                <plugin name="xlrstats" config="@conf/xlrstats.xml"/>
                <plugin name="ctime" config="@conf/plugin_ctime.xml"/>
                <plugin name="tk" config="@conf/plugin_tk.xml"/>
                <plugin name="autoreg" config="@conf/autoreg.xml"/>
                <plugin name="firstkill" config="@conf/firstkill.xml"/>
                <plugin name="chatlogger" config="@conf/plugin_chatlogger.xml"/>
                <plugin name="bfbc2mixedgames" config="@conf/bfbc2mixedgames.xml"/>
                <plugin name="poweradminbfbc2" config="@conf/poweradminbfbc2.xml"/>
        </plugins>
</configuration>
Logged
Tags: freebsd daemon start script boot 
Pages: [1]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal