Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!

Author Topic: bash script to start/stop/restart b3  (Read 29384 times)

Offline Storm3y

  • Jr. Member
  • **
  • Posts: 35
Re: bash script to start/stop/restart b3
« Reply #30 on: June 10, 2011, 11: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.

Offline Storm3y

  • Jr. Member
  • **
  • Posts: 35
Re: bash script to start/stop/restart b3
« Reply #31 on: June 16, 2011, 09:19:56 PM »
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?

Offline 40-1 Toffees

  • Sr. Member
  • ****
  • Posts: 171
Re: bash script to start/stop/restart b3
« Reply #32 on: December 18, 2011, 11: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: [Select]
#!/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, 03:02:49 PM by Toffees »

Offline jlatour88

  • Full Member
  • ***
  • Posts: 73
Re: bash script to start/stop/restart b3
« Reply #33 on: April 30, 2012, 06:14:08 AM »
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.

Offline Dwarfer

  • Full Member
  • ***
  • Posts: 52
Re: bash script to start/stop/restart b3
« Reply #34 on: April 30, 2012, 01:13:37 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..

Offline jlatour88

  • Full Member
  • ***
  • Posts: 73
Re: bash script to start/stop/restart b3
« Reply #35 on: May 01, 2012, 12:20:11 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..
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....."

Offline Miramar

  • Sr. Member
  • ****
  • Posts: 200
Re: bash script to start/stop/restart b3
« Reply #36 on: May 01, 2012, 01:27:27 PM »
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...

Offline corian

  • Jr. Member
  • **
  • Posts: 36
  • www.3-designs.de
    • 3ses
Re: bash script to start/stop/restart b3
« Reply #37 on: May 24, 2012, 08:47:34 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...

Hey Miramar
Can you post your edit script?
www.3-designs.de       jepp i am from germany

Offline TmR

  • Full Member
  • ***
  • Posts: 94
Re: bash script to start/stop/restart b3
« Reply #38 on: May 24, 2012, 09:16:57 AM »
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....."
http://forum.bigbrotherbot.net/configurations/php-startstop-script/msg34368/
php start/stop script for apache on windows
we've also got a version running now on unix. Will ask our php coder if he wants to share that here ;-)

Offline Miramar

  • Sr. Member
  • ****
  • Posts: 200
Re: bash script to start/stop/restart b3
« Reply #39 on: May 25, 2012, 07:28:55 PM »
Hey Miramar
Can you post your edit script?

i have posted it already...
checkitoutnow

Offline gtjj

  • Jr. Member
  • **
  • Posts: 27
Re: bash script to start/stop/restart b3
« Reply #40 on: August 08, 2012, 01:56:00 PM »
hey guys, i have got some problem <_<

after running this script im getting the following error:

Code: terminal [Select]
[email protected]:~#/home/server/big stop
ERROR: cannot execute '/home/server/b3/b3_run.py'


what could i do?
and please tell me how do i stop b3 by hands [without scripts]
« Last Edit: August 08, 2012, 05:27:42 PM by gtjj »

 


Rate this page +1 at Google Search

anything