thankyou
Donate to the B3 fund!

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

Author Topic: Fully Debian integrated start-stop script  (Read 26679 times)

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4883
    • Github repository
Re: Fully Debian integrated start-stop script
« Reply #15 on: December 08, 2009, 09:35:42 AM »
Sorry I'm not that familiar with monit install issues nor update-rc.d. I'm afraid I cannot help much on those topics.

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Fully Debian integrated start-stop script
« Reply #16 on: December 08, 2009, 12:50:38 PM »
Sorry I'm not that familiar with monit install issues nor update-rc.d. I'm afraid I cannot help much on those topics.

OK, no problem. I will figure it out someday :P

EDIT:


Remove is possible by doing the following:
Code: [Select]
sudo update-rc.d -f  b3 remove

Don't forget to add it afterwards...

Thank you very much, for all the support you gave to me.

Kind regards,
Melroy vd Berg
« Last Edit: December 08, 2009, 05:31:06 PM by danger89 »
JoinMyServer.com
Call of Duty 4 Game Servers

Offline ryry46d9

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 337
    • Pb| clan
Re: Fully Debian integrated start-stop script
« Reply #17 on: March 27, 2010, 02:58:23 PM »
Steps I took for: Ubuntu 9.10 Desktop edition (headless)

Code: [Select]
sudo vim /etc/init.d/b3
changed lines
Code: [Select]
13, 14, 17, 18, 20 (path to the b3 dir), 21 (full path to b3.xml)

Code: [Select]
sudo chmod +x /etc/init.d/b3

Code: [Select]
sudo /etc/init.d/b3 start
and got:
Quote
/etc/init.d/b3: 48: Syntax error: "fi" unexpected

so I
Code: [Select]
sudo vim /etc/init.d 
Quote
:48
Quote
dd
Quote
:wq

then
Code: [Select]
sudo /etc/init.d/b3 start
then
Code: [Select]
sudo /etc/init.d/b3 status
and got
Quote
*  running


moving on to the auto start on boot:

Code: [Select]
sudo update-rc.d b3 defaults
output:
Quote
update-rc.d: warning: b3 stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (S 0 1 6)
 Adding system startup for /etc/init.d/b3 ...
   /etc/rc0.d/K20b3 -> ../init.d/b3
   /etc/rc1.d/K20b3 -> ../init.d/b3
   /etc/rc6.d/K20b3 -> ../init.d/b3
   /etc/rc2.d/S20b3 -> ../init.d/b3
   /etc/rc3.d/S20b3 -> ../init.d/b3
   /etc/rc4.d/S20b3 -> ../init.d/b3
   /etc/rc5.d/S20b3 -> ../init.d/b3

not sure what all that means, but I hope it's safe to ignore  and hope this helps any Ubuntu users.
« Last Edit: July 02, 2010, 01:49:41 PM by ryry46d9 »

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Fully Debian integrated start-stop script
« Reply #18 on: March 27, 2010, 03:37:29 PM »
Read my message:

http://www.bigbrotherbot.com/forums/configurations/fully-debian-integrated-start-stop-script/msg8926/#msg8926
Quote
Please fix your code, remove line 47:
Code: [Select]
    fi



Steps I took for: Ubuntu 9.10 Desktop edition (headless)

Code: [Select]
sudo vim /etc/init.d/b3
changed lines
Code: [Select]
13, 14, 17, 18, 20 (path to the b3 dir), 21 (full path to b3.xml), 25(since I have 5 bots)

Code: [Select]
sudo chmod +x /etc/init.d/b3

Code: [Select]
sudo /etc/init.d/b3 start
and got:
so I
Code: [Select]
sudo vim /etc/init.d 
then
Code: [Select]
sudo /etc/init.d/b3 start
then
Code: [Select]
sudo /etc/init.d/b3 status
and got

moving on to the auto start on boot:

Code: [Select]
sudo update-rc.d b3 defaults
output:
not sure what all that means, but I hope it's safe to ignore  and hope this helps any Ubuntu users.
JoinMyServer.com
Call of Duty 4 Game Servers

Offline ryry46d9

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 337
    • Pb| clan
Re: Fully Debian integrated start-stop script
« Reply #19 on: March 27, 2010, 03:50:50 PM »
my error was line 48

what flavor of Linux are you running? and how many bots? I haven't tried to restart that box yet, I'm still working on other config's but if it's Ubuntu just start over from scratch trying my way.

the bots been up for one hour now
Quote
100327 06:40:02 BOT     www.BigBrotherBot.com (b3) v1.2.2b-20100224 [posix] (Daniel)
100327 06:40:02 BOT     Python: 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
[GCC 4.4.1]
100327 06:40:02 BOT     Starting Iourt41Parser server for 192.168.6.50:27960

Quote
100327 07:43:23 CONSOLE 651:26 say: 0 RYRY46d9: !STATUS
100327 07:43:23 VERBOSE Client Found: RYRY46d9 on slot 0
100327 07:43:23 VERBOSE Queueing event Say !STATUS
100327 07:43:23 VERBOSE Parsing Event: Say: ChatloggerPlugin
100327 07:43:23 DEBUG   ChatloggerPlugin: ALL, 2, RYRY46d9, !STATUS
100327 07:43:23 DEBUG   ChatloggerPlugin: query: INSERT INTO chatlog (msg_time, msg_type, client_id, client_name, client_team, msg) VALUES (1269701003, "ALL", 2, "RYRY46d9", 1, "!STATUS")
100327 07:43:23 DEBUG   ChatloggerPlugin: rowcount: 1, id:6277
100327 07:43:23 VERBOSE Parsing Event: Say: ChatPlugin
100327 07:43:23 VERBOSE Parsing Event: Say: SpamcontrolPlugin
100327 07:43:23 VERBOSE Parsing Event: Say: AdminPlugin
100327 07:43:23 DEBUG   AdminPlugin: OnSay handle 5:"!STATUS"
100327 07:43:23 DEBUG   AdminPlugin: Handle command !STATUS
100327 07:43:23 VERBOSE RCON sending (192.168.6.50:27960) tell 0 ^2(^2The Babysitter^2)^7: ^3[pm]^7 ^7Database appears to be ^2UP
 


Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Fully Debian integrated start-stop script
« Reply #20 on: March 27, 2010, 05:07:15 PM »
The error was in 48 the solution is on line 47...
JoinMyServer.com
Call of Duty 4 Game Servers

Offline ryry46d9

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 337
    • Pb| clan
Re: Fully Debian integrated start-stop script
« Reply #21 on: March 27, 2010, 06:34:15 PM »
either way ;)  48 was deleted and it works

Offline danger89

  • Full Member
  • ***
  • Posts: 129
    • JoinMyServer - Game Servers
Re: Fully Debian integrated start-stop script
« Reply #22 on: March 27, 2010, 10:22:45 PM »
Ok nice, maybe there is a new version or I just removed a white line :P
JoinMyServer.com
Call of Duty 4 Game Servers

Offline ryry46d9

  • B3 Contrib/Support
  • Sr. Member
  • *
  • Posts: 337
    • Pb| clan
Re: Fully Debian integrated start-stop script
« Reply #23 on: September 30, 2010, 01:03:50 AM »
Hey Courgette  I trided to change the line
Code: [Select]
DAEMON_ARGS="$B3_BASEDIR/b3_run.py -c $B3_CONFIGFILE"

to read
Code: [Select]
DAEMON_ARGS="$B3_BASEDIR/b3_run.py -r -c $B3_CONFIGFILE"
&
Code: [Select]
DAEMON_ARGS="$B3_BASEDIR/b3_run.py -rc $B3_CONFIGFILE"

but the bot fails to start with no logging. Do you know what the correct syntext  would be so I can get !restart working?

I been busy on other projects and the "how to restart in game" has been locked so I posted here, and yes they are 1.34b

Offline Courgette

  • Senior Dev.
  • Hero Member
  • *
  • Posts: 4883
    • Github repository
Re: Fully Debian integrated start-stop script
« Reply #24 on: September 30, 2010, 01:46:02 AM »
try
Code: [Select]
DAEMON_ARGS="$B3_BASEDIR/b3_run.py --restart -c $B3_CONFIGFILE"
(just a guess)

Offline xlr8or

  • [ www.xlrstats.com ]
  • Project Lead
  • Hero Member
  • *
  • Posts: 2057
    • The Art of Tactical Gaming
Re: Fully Debian integrated start-stop script
« Reply #25 on: October 03, 2010, 12:57:33 PM »
Code: [Select]
b3_run.py -r -c <configfile>
works fine on my end... are your paths correct?

Offline gazgaz

  • Jr. Member
  • **
  • Posts: 23
    • Brothers In Games
Re: Fully Debian integrated start-stop script
« Reply #26 on: January 06, 2011, 11:02:12 AM »
guys are all easier
to delete line 48 (fi)
and erase on line 20 (B3_BASEDIR = / bot/b3_run.py)
because it is duplicated in line 23 (DAEMON_ARGS = "$B3_BASEDIR/b3_run.py -c $B3_CONFIGFILE")
because of this there is a conflict))) is all that is needed to correct)) and it will work! ;)

Offline XMSK

  • Newbie
  • *
  • Posts: 1
Re: Fully Debian integrated start-stop script
« Reply #27 on: January 13, 2011, 01:05:40 PM »
full, script :)  :o

Code: [Select]
#! /bin/sh
### BEGIN INIT INFO
# Provides:          BigBrotherBot
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Main-Date          2011.01.13
# Short-Description: BigBrotherBot Start-Stop-Restart
# Description:       BigBrotherBot
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SCRIPTNAME=/etc/init.d/$NAME
DAEMON=`which python`


B3_BASEDIR="/xxx/xxx/xxxx/b3"                                     <--------- Full Path Dir.
B3_CONFIGFILE="/xxx/xxxx/xxxx/b3/b3/conf/b3.xml"     <--------- Full Path Configfiles.
B3_PID_FILE="/var/run/bigbrotherbot/${NAME}.pid"
DAEMON_ARGS="$B3_BASEDIR/b3_run.py -c $B3_CONFIGFILE"

# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then
{
        echo "Couldn't find $DAEMON"
        exit 99
}
fi

PIDDIR=`dirname "$B3_PID_FILE"`
if [ "$PIDDIR" -a "$PIDDIR" != "/var/run" ] ; then
   if [ ! -d "$PIDDIR" ] ; then
      mkdir "$PIDDIR"
   fi
   if [ "$DAEMON_USER" ] ; then
       chown "$DAEMON_USER" "$PIDDIR"
   fi
   if [ "$DAEMON_GROUP" ] ; then
       chgrp "$DAEMON_GROUP" "$PIDDIR"
   fi
    fi

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that check the daemon/service
#
do_status()
{
      NB_PROCESS=`ps ax | grep b3_run | grep "$B3_CONFIGFILE" | grep -v grep | wc -l`
      if [ $NB_PROCESS -gt 1 ]; then
         log_warning_msg "WARNING: $NAME is running multiple times"
            return 0
      elif [ $NB_PROCESS -eq 1 ]; then
         return 0
      else
            return 1
      fi
}

#
# Function that starts the daemon/service
#
do_start()
{
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started
   start-stop-daemon --start --quiet --chuid $DAEMON_USER:$DAEMON_GROUP --pidfile $B3_PID_FILE --make-pidfile \
        --background --chdir $B3_BASEDIR --startas $DAEMON -- $DAEMON_ARGS
    return $?
}

#
# Function that stops the daemon/service
#
do_stop()
{
   # Return
   #   0 if daemon has been stopped
   #   1 if daemon was already stopped
   #   2 if daemon could not be stopped
   #   other if a failure occurred
   start-stop-daemon --stop --signal 15 --retry 5 --quiet --pidfile $B3_PID_FILE
   RETVAL="$?"
    [ "$RETVAL" = 0 ] && rm -f $B3_PID_FILE
   [ "$RETVAL" = 2 ] && return 2
   return "$RETVAL"
}

do_kill() {
        while [ 1 ]; do
            PID=`ps hax | grep "b3_run" | grep "$B3_CONFIGFILE" | grep -v grep | cut -d' ' -f1 | head -n1`
            [ "$PID" = "" ] && return
            log_daemon_msg "killing process [$PID]"
            kill -9 $PID
        done
}

case "$1" in
  start)
   log_daemon_msg "Starting $DESC" "$NAME"
   do_start
   case "$?" in
      0|1) log_end_msg 0 ;;
      2)  log_end_msg 1 ;;
   esac
   ;;
  stop)
   log_daemon_msg "Stopping $DESC" "$NAME"
   do_stop
   case "$?" in
      0|1) log_end_msg 0 ;;
      2) log_end_msg 1 ;;
   esac
   ;;
  status)
   do_status
   case "$?" in
      1) log_success_msg " stopped" ;;
      0) log_success_msg " running" ;;
   esac
   ;;
  kill)
    log_daemon_msg "Killing all process b3_run using $B3_CONFIGFILE"
    do_kill
    log_end_msg 0
    ;;
  restart|force-reload)
   log_daemon_msg "Restarting $DESC" "$NAME"
   do_stop
   case "$?" in
     0|1)
      do_start
      case "$?" in
         0) log_end_msg 0 ;;
         1) log_end_msg 1 ;; # Old process is still running
         *) log_end_msg 1 ;; # Failed to start
      esac
      ;;
     *)
        # Failed to stop
      log_end_msg 1
      ;;
   esac
   ;;
  *)
   echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
   exit 3
   ;;
esac

:
« Last Edit: January 13, 2011, 01:08:53 PM by XMSK »

Offline gtjj

  • Jr. Member
  • **
  • Posts: 27
Re: Fully Debian integrated start-stop script
« Reply #28 on: August 10, 2012, 12:12:34 PM »
@ryry46d9

what does that

:48
dd
:wq

means?

 


Rate this page +1 at Google Search

anything