You are here: Big Brother Bot ForumAdd-OnsConfigurations (Moderator: MordyT)bash script to start/stop/restart b3
Pages: 1 2 [3]   Go Down
  Print  
Author Topic: bash script to start/stop/restart b3  (Read 9810 times) Bookmark and Share
Jr. Member
**
Posts: 35
Offline Offline
« Reply #30 on: June 10, 2011, 01:22:53 PM »

I assume you have to modify the script to point to install 2...
Take a look at:
B3_CONFIGFILE="/home/b3/b3bot_tmr/b3/conf/b3_tmr.xml" 
And stuff like that. Post the full script you are using and I will take a closer look.

(As a side note, you don't need 2 separate installs. You can start the same install with a different config file.)

Fixed. Just renamed the config.
Logged

Jr. Member
**
Posts: 35
Offline Offline
« Reply #31 on: June 16, 2011, 11:19:56 AM »

Hi,

I was using this script fine as a root user but when I made a new user for B3 it no longer lets me execute it. When I do ./bigbrotherbot start it says ERROR: cannot execute 'b3_run.py'

I did chown on the directory for the new user.

any ideas?
Logged
Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: BF3, RO2, COD-BO
Posts: 127
Offline Offline
« Reply #32 on: December 18, 2011, 02:27:21 AM »

Hi TmR

Thanks for posting this centos friendly script :-)  I've been looking for one for a while.  Have you played around with daemonizing this script so it can be run at startup as a different user? I'm told that running it as root isn't a good idea.

BR
Toffees

*EDIT*  Managed to create a simple startup script that runs the bot as the b3 user in the background.  Still have some work to do on error checking, but it works.  Make sure your log files are owned by the b3 user that is used to run the process, otherwise you will see errors in the b3/logs/b3.bf3.start.log

Code:
#!/bin/bash

# chkconfig: 235 99 98
# description: Start and stop b3 bot

# B3 Bot
########### SETTINGS | ############
. /etc/rc.d/init.d/functions

B3_CONFIG="/home/b3/b3/conf/b3.bf3.xml"
B3_RUN="/home/b3/b3_run.py"

## where the python binary is located
PYTHON_BIN=/usr/bin/python

########### SETTINGS END ############

case "$1" in
    start)
        
        echo -n "Starting B3 for BF3: "
daemon --user=b3 "python $B3_RUN $B3_CONFIG > /home/b3/logs/b3.bf3.start.log 2>&1 &"
sleep 7
echo "b3 for BF3 is running (PID: `ps ax |grep b3|grep bf3|grep Sl|awk '{print $1;}'`)"
    ;;
    stop)
        echo -n "Stopping b3 for BF3: `ps ax |grep b3|grep bf3|grep Sl|awk '{print $1;}'`"
        kill -9 `ps ax |grep b3|grep bf3|grep Sl|awk '{print $1;}'`
        echo
    ;;
    status)
        
echo

PID=`ps ax |grep b3|grep bf3|grep Sl|awk '{print $1;}'| wc -l`
        if [ $PID -gt 0 ]; then
            echo "b3 for BF3 is running (PID: `ps ax |grep b3|grep bf3|grep Sl|awk '{print $1;}'`)"
        else
            echo "b3 for BF3 is not running"
        fi
    ;;
    restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
    ;;
esac

exit 0

I'm having to sleep the script for 7 seconds whilst b3 starts in order that I can grab the process ID.  I'm sure there's a better way to do this, but I'm a newbie at bash scripts :-)
« Last Edit: December 18, 2011, 06:02:49 AM by Toffees » Logged
Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: BF3
Posts: 73
Offline Offline
« Reply #33 on: April 29, 2012, 08:14:08 PM »

can this somehow be access thru a simple web interface? like a master login then once logged in you'll have the start|stop|Restart|Status buttons and a small output or info box letting you know if it worked or not?

How hard would this be to implement or is it already made somewhere? details and info please.
Logged
Jr. Member
**
OS: Linux
Type: Owner dedicated server(s)
Gameservers: Homefront, BF3
Posts: 23
Offline Offline
« Reply #34 on: April 30, 2012, 03:13:37 AM »

Hi jlatour88,

If you are familiar with PHP web coding this would/could be simple to-do using the exec() function.

You would probably need to look to use sudo as well so it could be executed as apache/nobody but run as say "b3user"

you could then secure this with a simple htaccess file or if you were feeling funky tie it into "echelon" user auth..

I have been thinking about the same thing as well..
Logged

Full Member
***
OS: Linux
Type: Owner dedicated server(s)
Gameservers: BF3
Posts: 73
Offline Offline
« Reply #35 on: April 30, 2012, 02:20:11 PM »

Hi jlatour88,

If you are familiar with PHP web coding this would/could be simple to-do using the exec() function.

You would probably need to look to use sudo as well so it could be executed as apache/nobody but run as say "b3user"

you could then secure this with a simple htaccess file or if you were feeling funky tie it into "echelon" user auth..

I have been thinking about the same thing as well..
this does sound like something i want todo but im by no means an expert in php. i will study this more and see if its something im able todo.

"hmm maybe i could find another web control panel that i can link into this script....."
Logged
Sr. Member
****
OS: Linux
Type: Owner dedicated server(s)
Gameservers: COD2, COD4, COD5WaW, Homefront
Posts: 173
Offline Offline
« Reply #36 on: May 01, 2012, 03:27:27 AM »

take a look at this
LINK

i use this to start all of my gameservers and b3 servers too...
when configured right you can start everything with it...
Logged
Tags:
Pages: 1 2 [3]   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal