How To: Budabot on Linux

Questions, comments, suggestions, and bug reports
Tyrence
Posts: 1908
Joined: Sat Jan 09, 2010 1:32 am

How To: Budabot on Linux

Postby Tyrence » Thu Sep 29, 2011 10:52 pm

Note: This was taken from Arsenal's original [excellent] guide for setting up Budabot on Linux which can be found here: viewtopic.php?f=2&t=80

I have updated it to reflect changes in Budabot 2.0. --Tyrence

=========================

How-To: Budabot on Linux

Preliminary:
This tutorial was written for Ubuntu, but should work for most debian-based distributions, and shows you how to configure Budabot to use MySQL.

All directories mentioned are only for example and should be changed according to your very own setup.

Installation

Prerequisites

First of all we need some stuff to give Budabot even the slightest chance of running.
Among these are a PHP command line interpreter, MySQL and probably phpMyAdmin.

If you are running a webserver and are wondering why you should need to install a command line interpreter for PHP, because your webserver has already PHP built in, well let's just assume that it's not a very good idea to start a bot in a webserver, I didn't try what happens if you do, but I also don't want to (like somehow somebody finds out and opens 100 bots or something).

So back on installation:
We need some packages, that are the names under Ubuntu, in your distribution they'll hopefully have similar names.
  • php5-cli (the php command line interpreter, this will probably trigger a lot of additional packages to be installed as well)
  • php5-mysql
  • php5-gmp or php5-bcmath (actually I used gmp because there was no bcmath to be found)
  • php5-curl
  • Either:
  • mysql-server
  • phpmyadmin (if you don't have any webserver you won't need this one, as it's only a webfrontend to MySQL)
  • Or:
  • php5-sqlite

On an Ubuntu Console installing the stuff will look something like:

Code: Select all

apt-get install php5-cli php5-mysql php5-gmp php5-curl mysql-server phpmyadmin


I won't cover the setup of MySQL. For this topic see something like German Ubuntu Wiki or MySQL beginner guide or Ubuntu LAMP Guide.

Now there should be a functional installation of PHP5, MySQL and hopefully PHPMyAdmin.

Setting up Budabot

Next up, is downloading and installing Budabot. There is little magic to this one.

First Step
First we start with downloading the Budabot. We change into our main directory (if we left it):

Code: Select all

cd /home/Budabot


Then we download Budabot, I highly recommend downloading a new Budabot, even if you already set up one under Windows earlier (you can find a list of the current downloads here: http://code.google.com/p/budabot2/downloads/list).

For instance, to download 2.2_GA you'd do:

Code: Select all

wget http://budabot2.googlecode.com/files/Budabot2.2_GA_build1348.zip


Unzip the files:

Code: Select all

unzip Budabot2.2_GA_build1348.zip


This should create a new directory named 'Budabot2.2_GA_build1348'. There are now all the files needed to run Budabot.

Second Step (only MySQL)
Next up is creating a database for our Bot. I prefer creating a new user and a new database for every bot I run, because I always fear that multiple bots writing to one database will sooner or later collide and become unstable. Though I don't really know if this can happen.
You can skip this step if you decided to use SQLite.

First the simple method, if you set up phpMyAdmin:
Log into your phpMyAdmin and switch to the tab Privileges.

Click on Add a new user.

Type in some name, for example myBudaBot.
Restrict the host to localhost (because we don't want to allow anybody to log in)
Enter a password and retype it.

Select Create database with same name and grant all privileges.

Do not give the user any global privileges, because he doesn't need them!

Click Go and you are finished.

The command line method:
If you haven't installed phpMyAdmin or you have no webserver running to use it, you must use the mysql command line to setup the new database.

So, assuming you have root access to your MySQL server, log in:

Code: Select all

mysql -u root -p


Type your password, and you will get a prompt like this:

Code: Select all

mysql>


Then type in the following (you may copy and paste one line at a time, BUT CHANGE THE myBudabot AND myBudapwd):

Code: Select all

CREATE DATABASE IF NOT EXISTS `myBudabot` ;

CREATE USER 'myBudabot'@'localhost' IDENTIFIED BY 'myBudapwd';

GRANT ALL PRIVILEGES ON `myBudabot`.* TO 'myBudabot'@'localhost' IDENTIFIED BY 'myBudapwd';


Quit MySQL using quit.

Note that ` and ' are both used here and it makes a difference which one is used.

In either way you now have created a user named myBudabot with the password myBudapwd. And a database named myBudabot.

Remember those, because you need them to configure your Budabot.

Last step

We almost got it!

Start the bot either using:

Code: Select all

./chatbot.sh


If this isn't possible, you need to mark it as executable:

Code: Select all

chmod +x ./chatbot.sh


Since this is the first time running the bot, it will ask you some questions. Go ahead and answer the questions. When you get to the question

Code: Select all

Do you want to setup the database manually?

type "yes" (people wishing to use Sqlite can type "no" to skip the MySQL configuration). The next question will be

Code: Select all

Choose a Database system

Enter "2" for MySQL. The next question will be

Code: Select all

Enter the Hostname for the Database

In most cases you will leave that blank (unless your database is on a different server from where your bot will be running). Proceed to enter the database name (myBudabot), database user (myBudabot) and database password (myBudapwd). Finish answering the rest of the questions in the wizard.

Now the bot will start up and hopefully will log on and not quit with some evil errors.

But you know: You can't log out without taking the bot with you.
Now comes some Linux-command-line-magic-voodoo-stuff:
The utility screen allows us to run a command line tool in background, and even allows logging out without killing the process.

So use this:

Code: Select all

screen -S myBudabot -L -d -m chatbot.sh


Eeks, what does that mean?
  • -S myBudabot creates a Session named myBudabot, this makes identifying the right screen session easier
  • -L enables logging to screenlog.0, this just logs everything budabot sends to the prompt. Can be disabled, but I like to have another logging feature than budabots.
  • -d -m in this combination the parameters tell screen to create a new session in detached mode, so we actually see nothing on the console
  • chatbot.sh this is the command to run the bot

If you want to know whats going on, you can reattach to the screen typing screen -R. To detach the screen press CTRL-a and d if you want to quit the screen press CTRL-a and k
For a more advanced feature list have a look at the manpage of screen

Finshed, yay, gratz, roxxors!
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Tyrence
Posts: 1908
Joined: Sat Jan 09, 2010 1:32 am

Re: How To: Budabot 2.0 on Linux

Postby Tyrence » Thu Sep 29, 2011 11:10 pm

QuickStart Instructions for running Budabot on CentOS using Sqlite

Code: Select all

yum install php php-pdo php-bcmath php-xml subversion
cd /home/Tyrence
mkdir bots
cd bots

svn checkout http://budabot2.googlecode.com/svn/tags/2.3_GA budabot
-- OR --
(download the bot from the website and extract it here)

cd budabot
chmod 711 chatbot.sh
./chatbot.sh


For Mysql, you would also need to install these packages

Code: Select all

yum install mysql mysql-server php-mysql


It is recommended that you use CentOS 6 instead of CentOS 5. CentOS 5 only supports PHP 5.1.6 and Budabot requires PHP 5.3 for all functionality to work correctly.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Tyrence
Posts: 1908
Joined: Sat Jan 09, 2010 1:32 am

Re: How To: Budabot 2.0 on Linux

Postby Tyrence » Thu Sep 29, 2011 11:13 pm

Other guides
===========

How to use top to view the effect of running bots on your system: viewtopic.php?p=761#p761

Basic usage of screen: viewtopic.php?p=913#p913

How to run Budabot in a VM on Windows 2008 R2 HyperV server: viewtopic.php?p=2567#p2567

There are many other good bits of info in the original thread. Please feel free to read through it: viewtopic.php?f=2&t=80

If you have something to add to the guides or have a guide you'd like to add for a setup that hasn't already been covered, please feel free to reply to this post. For any other post, including problems running Budabot on Linux, please create a new thread.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
nagahiro
Member
Posts: 41
Joined: Mon Oct 03, 2011 6:42 pm
antispam: Rimor

Re: How To: Budabot 2.0 on Linux

Postby nagahiro » Mon Nov 21, 2011 1:16 am

Finally got around to installing buda today. Noticed that it also requires curl. Hence the cli install line should read:

Code: Select all

sudo apt-get install php5-cli php5-mysql php5-gmp php5-curl mysql-server phpmyadmin

rather than:

Code: Select all

apt-get install php5-cli php5-mysql php5-gmp mysql-server phpmyadmin


Hope this helps those who find their bot stuck in a restart-loop following the initial configuration.

Oh, also, screen is no longer installed as part of the default packages in Ubuntu, to install it use:

Code: Select all

sudo apt-get install screen
Tyrence
Posts: 1908
Joined: Sat Jan 09, 2010 1:32 am

Re: How To: Budabot 2.0 on Linux

Postby Tyrence » Mon Nov 21, 2011 6:03 am

Ah yeah, thanks. :) Updated.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Tyrence
Posts: 1908
Joined: Sat Jan 09, 2010 1:32 am

Re: How To: Budabot 2.0 on Linux

Postby Tyrence » Thu Jan 05, 2012 12:10 am

To use the runkit classloading (which makes it so you don't have to restart the bot to see the majority of changes as you code) you simply need to enable it in your config.php file:

Code: Select all

define("USE_RUNKIT_CLASS_LOADING", false);

Change to:

Code: Select all

define("USE_RUNKIT_CLASS_LOADING", true);


Then [re]start the bot.

For operating systems besides windows, you will need to first compile and then install runkit (see: http://code.google.com/p/budabot2/wiki/CompilingRunkit).

Note that this is only available in Budabot 3.0+.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Marebone
The Team
Posts: 175
Joined: Sun Sep 04, 2011 7:38 am
antispam: Rimor

Re: How To: Budabot 2.0 on Linux

Postby Marebone » Fri Jan 06, 2012 12:10 pm

Added Runkit compiling instructions for CentOS, Ubuntu and Windows in to wiki as well.
skoopy
Member
Posts: 1
Joined: Mon Jul 04, 2016 4:00 pm
antispam: Rimor

Re: How To: Budabot on Linux

Postby skoopy » Mon Jul 04, 2016 11:02 pm

What are the updated dependencies for 3.4 on CentOS 7?
twist3ed
Member
Posts: 22
Joined: Mon Nov 26, 2012 3:45 am
antispam: rimor
Location: IA

Re: How To: Budabot on Linux

Postby twist3ed » Wed Mar 22, 2017 6:13 pm

Has anybody installed this on Ubuntu 16 with php 7 yet?

This guide is rather outdated now.
Tyrence
Posts: 1908
Joined: Sat Jan 09, 2010 1:32 am

Re: How To: Budabot on Linux

Postby Tyrence » Fri Mar 24, 2017 5:08 am

I don't have a server to test this on, but it should be mostly the same. The package names for PHP might be different, but otherwise it should work as prescribed. If you do decide to do this, it might be helpful to record the steps for other people who may want to.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest