Posts tagged with ubuntu

Sugar on LTSP Ubuntu Intrepid Ibex with ejabberd and collaboration

With the announcement that the Sugar packages were finally up to date in Ubuntu, it was time to try something I've been wanting to do for a while, run a sugar environment on Ubuntu LTSP terminals with collaboration. With the help of some sugar devs I managed to get it all working quite nicely:

Installing Sugar

The base sugar and activities all seem to work wonderfully, although at the time of writing some of the other sugar activties are not working yet. By the time Intrepid is released this will probably be fixed.

sudo apt-get install sugar sugar-activities

You can search for what other sugar activites you can install like this:

sudo apt-cache search sugar

Then change the default session to sugar like this:

sudo nano /home/$username/.xsession

(where $username is the user for whom you want sugar to be the default shell.)

And add the following to the .xsession file:

export SUGAR_LOGGER_LEVEL=debug
export GABBLE_DEBUG=all
export GABBLE_LOGFILE=/home/$user/.sugar/default/logs/telepathy-gabble.log
export PRESENCESERVICE_DEBUG=1
export LM_DEBUG=net
exec ck-launch-session dbus-launch --exit-with-session sugar-shell

A quick explanation of the file is in order. The export lines are actually for debugging, and aren't needed if you don't intend to look at the log files. Remember $user should be the user home folder. The ck-launch-session is for making sugar exit properly when exiting from the menu. The --exit-with-session is for making sure there are no lingering sessions on ctrl-alt-backspace, currently the only way to exit, as ck-launch-session doesn't seem to work.

Finally, make sure you have your server hostname in place of olpc.collabora.co.uk:

sudo sed -ie "s/olpc.collabora.co.uk/hostname/" /home/username/.sugar/default/config

There are now 2 ways to install ejabberd, as the ejabberd packages in debian are up to date so installing ejabberd from scratch only really helps for non debian distros.

Installing Ejabberd from the repositories

sudo apt-get install ejabberd
sudo dpkg-reconfigure ejabberd

You need to add the user (usually admin) and the fully qualified domain name where ejabberd will be running. You can find what this is by doing hostname -f.

Patch /etc/ejabberd.cfg by downloading the olpc based patch and applying it:

wget http://dev.laptop.org/~morgan/ejabberd/ejabberd.cfg.patch
sudo patch /etc/ejabberd/ejabberd.cfg  ejabberd.cfg.patch
sudo /etc/init.d/ejabberd restart

skip the installing ejabberd from source and continue where it says installing the SSL certificate

Installing Ejabberd from source

The first step involves downloading the source package like this:

mkdir ejabberd
cd ejabberd
wget http://www.process-one.net/downloads/ejabberd/2.0.0/ejabberd-2.0.0.tar.gz
tar xfz ejabberd-2.0.0.tar.gz

We then need to download the patches from olpc that allow ejabberd to perform proper collaboration, and install the patches:

wget http://people.collabora.co.uk/~robot101/olpc-ejabberd/shared_roster_push2.diff
wget http://people.collabora.co.uk/~robot101/olpc-ejabberd/shared_roster_recent.diff
wget http://people.collabora.co.uk/~robot101/olpc-ejabberd/shared_roster_online.diff
wget http://people.collabora.co.uk/~robot101/olpc-ejabberd/mod_ctlextra.diff
wget http://people.collabora.co.uk/~robot101/olpc-ejabberd/ejabberd.cfg
cd ejabberd-2.0.0/
patch -p1  ../shared_roster_push2.diff
patch -p1  ../shared_roster_recent.diff
patch -p1  ../shared_roster_online.diff
patch -p1  ../mod_ctlextra.diff
cd src
./configure
make
sudo make install

We also edit /etc/ejabberd/ejabberd.cfg and replace jabber.laptop.org with the actual server hostname and the user "jtest" with "admin" (although u can use a different user if you like):

cd ../..
sudo cp ejabberd.cfg /etc/ejabberd/
sudo sed -ie "s/{hosts, ["jabber.laptop.org"]}./{hosts, ["hostname"]}./" /etc/ejabberd/ejabberd.cfg
sudo sed -ie "s/{acl, admin, {user, "jtest","jabber.laptop.org"}}./{acl, admin, {user, "admin","hostname"}}./" /etc/ejabberd/ejabberd.cfg

Remember to change hostname for the actual server hostname.

Installing the SSL certificate

You must also install an SSL certificate, which is required for collaboration to work (this is an important step.)

openssl req -newkey rsa:1024 -keyout ejabberd.pem -nodes -x509 -days 3650 -out ejabberd.cer
echo "" >> ejabberd.pem
cat ejabberd.cer >> ejabberd.pem
sudo cp ejabberd.pem /etc/ejabberd/ejabberd.pem
sudo chown ejabberd:ejabberd /etc/ejabberd/ejabberd.pem
sudo chmod 400 /etc/ejabberd/ejabberd.pem

Finally we add the user@hostname to /etc/ejabberd/ejabberdctl.cfg remembering to change hostname for your real server hostname:

echo "ejabberd@hostname" | sudo tee -a /etc/ejabberdctl.cfg /dev/null

Then you can turn ejabberd on with

sudo ejabberdctl start

See if ejabberd is running properly:

sudo ejabberdctl status

which should produce the following output:

Node ejabberd@hostname is started. Status: started
ejabberd is running

Then add the admin user:

sudo ejabberdctl register admin hostname xx

This should now allow you to login to the web ejabberd control panel:

Go to http://yourserver:5280/admin/
Log in as your ejabberd's administrative user. Your username is a Jabber address e.g. "admin@yourserver".
Select Virtual Hosts, then your server hostname, then Shared Roster
Add a group called Online with the following settings:
o Name: Online
o Members: @online@
o Displayed Groups: Online

It is recommended you register a user via your favorite jabber program and as the sugar users log in, you'll be able to see them in the Online group.

If you run into problems you can check the logs in /var/log/ejabberd/ to see what could be wrong. And for Sugar logs, you can look at /home/$user/.sugar/default/logs/

Enjoy your terminal session sugar experience!

Rate It! (Average 0, 0 votes)



eggdrop IRC bot with logging to website

After playing around a bit with the php bot logging to mysql, I turned to a little more industrial solution, which involved installing an eggdrop bot and a script which lives inside the bot to convert its log files to html. This turned out to be the easiest solution, albeit a time consuming one. First it was necessary to install an eggdrop bot, which on Debian and Ubuntu can be done like so:

apt-get install eggdrop

This installs the eggdrop to its global area, and if like me you want to run it from a specific user's home you need to copy the configuration file (eggdrop.conf) to the home dir of your choice (example: /home/logbotuser/eggdrop.conf) You must thoroughly go through the configuration file, and uncomment various locations that stop you from executing the bot without reading through ALL the configuration options. The important stuff is at the top, like the botnick, the channel, etc, but there is also important stuff further down, like which irc servers to connect to and the like. When you are done, you should start the bot doing:

eggdrop -m eggdrop.conf

you use the -m option only the first time, as this tells it to create a new user list, after which you can msg the bot hello from irc, or telnet into it and type NEW as the username. The bot should now be happily running on the channel of your choice. One other thing you can do is setup a cron job that makes sure your bot is running always. Basically the crontab checks every 10 minutes to see that the bot is still active, if it isn't it relaunches it. To set it up, move the botchk script from /usr/share/eggdrop/scripts/ to your user directory:

mv /usr/share/eggdrop/scripts/botchk /home/user/eggdrop/

Then you need to edit the bothck script which has some self explanatory settings corresponding to what you already configured in eggdrop.conf, but something that is not mentioned is the need to replace the 3 entries that have the string ./ $botdir to:

/path/to/eggdrop/dir/ $botdir

In the example above that would be /home/username/eggdrop/ $botdir

You then need to do the final part which is add the crontab entry like so:

crontab -e

Here you add the following line:

0,10,20,30,40,50 * * * *   /path/to/botchk

Now you can now download the logs2html script from here.

To install it, unzip it and follow the readme instructions. One thing not mentioned is that the actual compiled module is in the precompiled/eggdrop 3/ directory.You need to move this to /usr/lib/eggdrop/modules/

Then you must edit the logs2html.conf script and the chan.list file. You must also re-edit the eggdrop.conf file and add a line in the end that contains:

source logs2html.conf

When you are done, you should be able to view your irc logs on a website as defined in chan.list. There is an example here: www.nubae.com/logs


Rate It! (Average 0, 0 votes)



Using cron and anacron in Ubuntu Linux

One of the LTSP scipts I was working on has a set of cronjobs that need to be entered into the cron manager for repeated execution every hour. I figured the easiest way to set up a task that needs to repeat every hour is to create a script and drop it into /etc/cron.hourly, letting the crontab take care of the rest. In theory, one doesn't even have to reload the crontab since that is done automatically every hour, day and week. I spent a good half day trying to figure out why my cron jobs were just not being executed, thinking first it was my scripting, then my cron installation, and finally concluding crontab was somehow not working properly. After talking with someone on IRC about the issue, it turned out my script was being ignored by crontab because it had the following missing from it:

set -e

Now I know not all scripts need this, but just in case someone else runs into a problem where they're script isn't executing in crontab, the solution is to add the headers:

#! /bin/sh

set -e

Rate It! (Average 0, 0 votes)



OCROpus - next gen. OCR for Linux

I was recently asked to scan in a small book, with relatively small text for addition to a database that could then be looked up by typing key words. The first step is to scan and OCR the entire book. Fortunately I've got all the necessary software to do scanning (sane and xsane) and my scanner was automatically recognised by Ubuntu.

The hard part was finding a suitable OCR software for Linux. In the past finding such a beast was a sad state of affairs in the Linux world indeed. With revived interest though, last year saw a few Google summer of code projects being released including tesseract and ocropus. Since they are very recent additions, the software is not exactly mature, but its the best there is, boasting a 95% accuracy.

I installed Ocropus and Tesseract from subversion, since it makes sense to check out the latest release. Though there are some recent releases in the Ubuntu repositories, I couldn't get OCROpus to recognise the needed extras. So the instructions I used are as follows:

svn checkout http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract-ocr-read-only svn checkout http://iulib.googlecode.com/svn/trunk/ iulib-read-only svn checkout http://ocropus.googlecode.com/svn/trunk/ ocropus-read-only

Tesseract source has a bug that doesn't allow it to compile with gcc 4.3 (Intrepid Ibex comes with this default) so you need to install this patch by downloading to the directory where tesseract-ocr-read-only is located, and running:

patch -p1 tesseract+gcc-4.3.diff

Then u can do ./configure, followed by make and finally make install.

To install iulib, go into its directory and do:

./configure && make && sudo make install

The documentation session also use OpenFST which you can download here. There is a problem however, with building using the latest Ubuntu, so I chose not to use it.

To build ocropus, go into the ocropus-read-only folder and do:

./configure --without-fst --without-leptonica

make

sudo make install

Right now, OCROpus works only as a command line tool, with some frontends coming soon one hopes. In any case, using it from the command line is not too hard if all you want is to convert to a html formatted page:

ocroscript recognise

You can also recognize a sequence of pages by listing them one by one in a file, say, file-list by doing:

ocroscript recognize @file-list > text.html WHAT DO THE ROLLS ROYCE PHANTOM AND THE HYUNDAI GENESIS HAVE IN COMMON? HINT: IT’S NOT THE PRICE. For starters——they both share a 17-speaker Lexic0n® 7.1 surround sound system} Now, we don’t suppose you’ll confuse a Genesis with a Rolls—Royce anytime soon, but these two luxury cars do share more vital appointments than you might expect. For instance—a quiet cabin—assm·ed (like the Phantoms) by whisper valves that select an alternate exhaust at low speeds to reduce noise, and by acoustic laminated windows. The car’s trailblazing ergonomics are exceptional too. A widely acclaimed DIS knob gives you intuitive access to GPS, the sound system, and any_ Bluetooth" phone. Outside, the Genesis glows with a finish so nearly perfect that (just like Rol1s—Royce) we have to use robots to achieve it. No wonder it looks so good. In fact, if you’d rather have money than a hood ornament, it may tend to look even better than a Rolls-Royce.

Rate It! (Average 0, 0 votes)