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

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

Author Topic: Need Bebot To Start When Server Starts  (Read 26177 times)

0 Members and 1 Guest are viewing this topic.

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #15 on: March 08, 2012, 03:15:40 am »
As the user that runs the bot... try "/bin/bash" and see if you get a new shell or an error message.

It really sounds like the bot user does not have access to /bin/bash ... maybe /usr/bin/bash?

If there is no error running /bin/bash... try changing
mailx -s "Starting ${BOTNAME} bot " [email protected] <${BOTLOGS}/${BOTNAME}.log ;

to
#mailx -s "Starting ${BOTNAME} bot " [email protected] <${BOTLOGS}/${BOTNAME}.log ;

If that works then "find / -name mailx" it may not be in the user's normal path. A faster way is also to use "which mailx" as this search only uses the user's known path statement.


« Last Edit: March 08, 2012, 03:26:47 am by Shelly »

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #16 on: March 08, 2012, 10:49:32 am »
: No such file or directorys: line 2: /home/kevin-0/Bots/start_bot1

Are you sure you using the right paths for the script?...

"cat /home/kevin-0/Bots/start_bot1" should give you a output of the file if its correct path..
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline seknetari

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #17 on: March 08, 2012, 12:24:29 pm »
As the user that runs the bot... try "/bin/bash" and see if you get a new shell or an error message.

It really sounds like the bot user does not have access to /bin/bash ... maybe /usr/bin/bash?

If there is no error running /bin/bash... try changing
mailx -s "Starting ${BOTNAME} bot " [email protected] <${BOTLOGS}/${BOTNAME}.log ;

to
#mailx -s "Starting ${BOTNAME} bot " [email protected] <${BOTLOGS}/${BOTNAME}.log ;

If that works then "find / -name mailx" it may not be in the user's normal path. A faster way is also to use "which mailx" as this search only uses the user's known path statement.

When I type "/bin/bash" I get a new prompt (is that what you mean by "shell"?) [I'm still learning the lingo]. When I type /usr/bin/bash I get an error that it isn't found. Since the /bin/bash command didn't give me an error, I did your second suggestion. I get the same result when I run the script.



: No such file or directorys: line 2: /home/kevin-0/Bots/start_bot1

Are you sure you using the right paths for the script?...

"cat /home/kevin-0/Bots/start_bot1" should give you a output of the file if its correct path..

When I use the cat command, I get the text of the file. I did this with both files just to be sure.

I have a hunch that the "-" in my name may be screwing up the path. Whether it is or isn't, I am thinking of starting over from scratch and re-installing Ubuntu. I think it would be good practice for me too.

When I install Ubuntu again, what suggestions do you have for a clean server install? Should I create a user account and install Bebot there? If I am using the "adduser _NEWUSERNAME_" command, are there any modifications I need to make at this time to get the Bebot to work (permissions?)?

I have been making a modified bebot zip file with all of my scripts and updated Bebot files to make it easier to install the next time. Although my bot works, I do get 4 error messages when it starts. I will start a new thread to address those before I re-install.

Again, I want to stress how thankful I am to Getrix, Shelly, and everyone else that has tried to help me. I realize you are donating your time to help out a stranger and I GREATLY appreciate it. Thank you, thank you, thank you!!

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #18 on: March 08, 2012, 09:01:44 pm »
You can actually try with another user before you reinstall Ubuntu.

sudo adduser USERNAME

Try without any special chars this time, only letter from a to z. Was also thinking if that could be your problem..
You should not need to set special permission, other then password, and set a homedir (/home/username)
Then login with the new user, ex from ssh or local terminal. Download Bebot from start and try from start again.
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #19 on: March 09, 2012, 02:31:54 am »
When I type "/bin/bash" I get a new prompt (is that what you mean by "shell"?) [I'm still learning the lingo].

Yep! That's correct.

BUT!! Don't reinstall yet....

on the first line of your start_bot1 file modify it from:
#!/bin/bash

-to-
#!/bin/bash -vx

Then try to run the script. It should show you everything it is doing. then we can pinpoint the error... hopefully :)

Paste that here if you can.

Shelly

Offline seknetari

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #20 on: March 11, 2012, 10:44:33 pm »
When I type "/bin/bash" I get a new prompt (is that what you mean by "shell"?) [I'm still learning the lingo].

Yep! That's correct.

BUT!! Don't reinstall yet....

on the first line of your start_bot1 file modify it from:
#!/bin/bash

-to-
#!/bin/bash -vx

Then try to run the script. It should show you everything it is doing. then we can pinpoint the error... hopefully :)

Paste that here if you can.

Shelly

Okay, I used the command: "/bin/bash start_bot1" and here is what I get:

Quote
start_bot1: line 2: $'\r': command not found
start_bot1: line 19: $'\r': command not found
start_bot1: line 20: $'\r': command not found
start_bot1: line 21: $'\r': command not found
start_bot1: line 22: $'\r': command not found
start_bot1: line 23: $'\r': command not found
start_bot1: line 24: syntax error in conditional expression
'tart_bot1: line 24: syntax error near ']]
'tart_bot1: line 24: 'if [[ $z == "" ]]

I hope this helps makes sense of what is going on.
-Sek

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #21 on: March 12, 2012, 02:40:42 am »
Okay, I used the command: "/bin/bash start_bot1" and here is what I get:

Quote
start_bot1: line 2: $'\r': command not found
start_bot1: line 19: $'\r': command not found
start_bot1: line 20: $'\r': command not found
start_bot1: line 21: $'\r': command not found
start_bot1: line 22: $'\r': command not found
start_bot1: line 23: $'\r': command not found
start_bot1: line 24: syntax error in conditional expression
'tart_bot1: line 24: syntax error near ']]
'tart_bot1: line 24: 'if [[ $z == "" ]]

I hope this helps makes sense of what is going on.
-Sek

Looks like something got misplaced in your script. Please load this one with your bot details and see if it works.

And I suggest using an editor on your linux machine to edit with. Windows editors are different formats.
« Last Edit: March 12, 2012, 02:42:36 am by Shelly »

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #22 on: March 12, 2012, 04:02:47 pm »
Here's how I used to do it with screen. Hope it's helpful.


Code: [Select]
#!/bin/bash

BOTDIR=/home/botrunner/bots

# Start the guild relay bot first.
cd ${BOTDIR}/relaybot
screen -dmS relaybot php StartBot.php
# Wait for relay bot to startup and connect before starting the rest of the guild bots.
sleep 30s

cd ${BOTDIR}/guildbot
screen -dmS guildbot php StartBot.php
cd ${BOTDIR}/partybot
screen -dmS partybot php StartBot.php
cd ${BOTDIR}/dosbott
screen -dmS guildbot2 php StartBot.php


I so rarely rebooted my bot server (it was under my stairs on a good UPS) so I never bothered setting up a start on boot, if I did it would have been an @reboot cron entry.

I created a .screenrc in my botrunner account's home directory.

Code: [Select]
multiuser on
addacl root

And then I had an attach script:
botattach:
Code: [Select]
#!/bin/bash
namereq="root"
name="$LOGNAME"

command="/usr/bin/screen -r $1"

if [ $namereq != $name ];  then
    command="/usr/bin/sudo /usr/local/bin/attach $1"
fi

$command

And the following entries in /etc/sudoers:
Code: [Select]
User_Alias BOTADMINS = user1, user2, user3
# Cmnd alias specification
Cmnd_Alias BOTATTACH = /usr/local/bin/botattach
BOTADMINS ALL = NOPASSWD: ATTACH

So the other admins of Campalot or the various guildbots could log into my Linux server, run botattach botname, and pull up the screen for that bot. There are some security holes there to be sure, but it worked well enough for trusted administrators. Fixing the security issues wasn't important enough to me with trusted bot administrators, the goal was to make it easy to pull up the bot console and restart the bot if need be.

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #23 on: March 14, 2012, 12:36:11 am »
Okay, I used the command: "/bin/bash start_bot1" and here is what I get:

Quote
start_bot1: line 2: $'\r': command not found
start_bot1: line 19: $'\r': command not found
start_bot1: line 20: $'\r': command not found
start_bot1: line 21: $'\r': command not found
start_bot1: line 22: $'\r': command not found
start_bot1: line 23: $'\r': command not found
start_bot1: line 24: syntax error in conditional expression
'tart_bot1: line 24: syntax error near ']]
'tart_bot1: line 24: 'if [[ $z == "" ]]

I hope this helps makes sense of what is going on.
-Sek

Actually... I bet you edited the script with Notepad and then copied it to your bot... :) Try using "
Code: [Select]
dos2unix start_bot1"

I have a feeling that will fix your original start script. :)

Oh and... you don't need the "/bin/bash " in front of your script. If you are in the bot's home folder just "
Code: [Select]
./start_bot1" should do it.

Shelly

Offline seknetari

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Need Bebot To Start When Server Starts
« Reply #24 on: March 15, 2012, 03:21:52 am »
Hi Shelley. I hope you are right. I haven't had a chance to play with the bot yet. I should be able to check that file tomorrow. I'll post the results. AND I did edit the file in Windows before zipping it up and transfering it to my Ubuntu box. I thought it would make my life easier... guess not.  ::)

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 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: 140
  • 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