collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: UBUNTU Start up script problem  (Read 1562 times)

0 Members and 1 Guest are viewing this topic.

Offline muso

  • BeBot Rookie
  • *
  • Posts: 14
  • Karma: +0/-0
UBUNTU Start up script problem
« on: July 06, 2011, 02:41:19 am »
Web Server    Apache v2.2.14
PHP    5.3.2-1ubuntu4.9.1    
PHP Max Post Size    8.00 MB    
PHP Maximum Upload Size    2.00 MB
PHP Memory Limit    128.00 MB         
MySQL Version    5.1.41-3ubuntu12.10         
MySQL Packet Size    16.00 MB

Code: [Select]
root@angliaimagyarok:/home/muso/BeBot# su -c "php5 StartBot.php" muso
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
PHP Notice:  Undefined offset: 1 in /home/muso/BeBot/Sources/Conf.php on line 47
PHP Notice:  Undefined property: Conf::$cf in /home/muso/BeBot/Sources/Conf.php on line 70
Bot.conf Does not Exist
 What do you want to do?
(r=Retry, n=new, c=Change, q=quit)
Select: ^Croot@angliaimagyarok:/home/muso/BeBot#

Code: [Select]
root@angliaimagyarok:/home/muso/BeBot# ./bot.sh start
Starting Bot
Failed to start bot
root@angliaimagyarok:/home/muso/BeBot# /usr/bin/nohup: appending output to `nohup.out'

Code: [Select]
root@angliaimagyarok:/home/muso/BeBot# tail nohup.out
/home/muso/BeBot/StartBot.php: 5: ChangeLog.txt: not found
/home/muso/BeBot/StartBot.php: 5: Age: not found
/home/muso/BeBot/StartBot.php: 6: Syntax error: "(" unexpected
/home/muso/BeBot/StartBot.php: 1: cannot open ?php: No such file
/home/muso/BeBot/StartBot.php: 2: /bin: Permission denied
/home/muso/BeBot/StartBot.php: 3: ChangeLog.txt: not found
/home/muso/BeBot/StartBot.php: 4: ChangeLog.txt: not found
/home/muso/BeBot/StartBot.php: 5: ChangeLog.txt: not found
/home/muso/BeBot/StartBot.php: 5: Age: not found
/home/muso/BeBot/StartBot.php: 6: Syntax error: "(" unexpected
root@angliaimagyarok:/home/muso/BeBot#
Code: [Select]
#!/bin/sh
BASEDIR="/home/muso/BeBot"
PHPBIN="/usr/lib/php5"
CMD="/usr/bin/php5 ${BASEDIR}/StartBot.php"
# If you want to use your own INI file
# set the location of the ini file and
# comment out the two following lines
#INI="${BASEDIR}/php.ini"
#CMD="${PHPBIN} -c ${INI} ${BASEDIR}/bot.php"
NOHUP=/usr/bin/nohup

Error() {
  echo "Error: $1"
  exit 1
}

[ -d ${BASEDIR} ] || Error "Make sure the BASEDIR variable is set
  The value ${BASEDIR} is not valid"

[ -f "${BASEDIR}/StartBot.php" ] || Error "Make sure the BASEDIR variable
is
properly set
  I could not find helpbot.php in ${BASEDIR}"

[ -x ${PHPBIN} ] || Error "Make sure the PHPBIN variable is set
  The value ${PHPBIN} is not valid"

[ -x ${NOHUP} ] || Error "Make sure the NOHUP variable is set
  The value ${NOHUP} is not valid"

case $1
in
start*)
  PID=`/bin/ps x | /bin/grep -v grep | /bin/grep "$HOME/BeBot/StartBot" | awk '{ print $1; }'`
  ANS=0
  [ "${PID}" != "" ] || ANS=1;

  if [ $ANS -eq 0 ]
  then
    echo "Bot already running PID=${PID}"
  else
    echo "Starting Bot"
    cd ${BASEDIR}
    ${NOHUP} ${CMD} &

    PID=`/bin/ps x | /bin/grep -v grep | /bin/grep "$HOME/BeBot/StartBot" | awk '{print $1;}'`
    if [ "$PID" = "" ]
    then
      echo "Failed to start bot"
    else
      echo "Bot Started"
    fi
  fi
;;
stop*)
  PID=`/bin/ps x | /bin/grep -v grep | /bin/grep "$HOME/BeBot/StartBot" | awk '{ print $1; }'`
  ANS=0
  [ "${PID}" != "" ] || ANS=1;

  if [ $ANS -eq 0 ]
  then
    echo "Stopping bot matching PID=$PID"
    kill ${PID}
  else
    echo "Bot is not running"
  fi
;;
status*)
  PID=`/bin/ps x | /bin/grep -v grep | /bin/grep "$HOME/BeBot/StartBot" | awk '{ print $1; }'`
  ANS=0
  [ "${PID}" != "" ] || ANS=1;

  if [ $ANS -eq 0 ]
  then
    echo "Bot running PID=$PID"
  else
    echo "Bot not running :("
  fi
;;
*)
echo "Usage: $0 {start|stop|status}";
;;
esac


used to be it was work fine but now i have no ideal what is wrong.

Working fine with this one
Code: [Select]
`which php` -c ./ Main.php

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: UBUNTU Start up script problem
« Reply #1 on: July 08, 2011, 01:58:30 am »
Hi,

For one... never run your bot as the root user. :)

Always create a user that owns the bot folder and has rights to run php.

# chown -R bot_user <folder where your bot files live>

Then su - bot_user

and retry running your bot.

Shelly

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 474
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal