Set up Raspberry Pi with YaCy

The Raspberry Pi ('RPi') is a credit-card-sized single-board computer which can run Linux kernel-based operating systems. We consider the usage of a 'Model B' with 512 MB SDRAM. Since this computer consumes only 3.5 W it is an ideal plattform for private 'cloud' applications and also to run a YaCy peer 24x7.

There is a wide range of available operating systems for the RPi. There is also a 'default' system recommended by the makers of the RPi, called "Raspbian" which is based on debian wheezy.

There are several options for an OS on the Raspberry PI ('RPi'). We consider to run YaCy on Raspbian but you might want to insert more sections here for other OS'

Running YaCy on Raspbian

We take the default Raspbian image but modify it to fit it for our needs:

Preparation of Raspbian

rm -Rf ~/python_games
sudo apt-get remove --purge python

.. followed by the same deborphan-process as described in Headless Debian

sudo apt-get remove --purge python python2.6 python2.7 python3 python3.2 perl

You may want to remove orphan and not required packages after this using the Headless Debian tutorial again.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

followed by a restart

sudo shutdown -r now

Repeat this until no updates appear. Then do a cleanup

sudo apt-get clean

then you should have at most 627M used on your SD card:

df -h .

Java Installation

scp ejre-1_6_0_38-fcs-b05-linux-arm-vfp-eabi-headless-13_nov_2012.tar.gz pi@192.168.1.70:~/
sudo tar xfz ejre-1_6_0_38-fcs-b05-linux-arm-vfp-eabi-headless-13_nov_2012.tar.gz -C /usr/lib/

which creates a directory ejre1.6.0_38 in /usr/lib. To add the java command to the execution path, do

sudo ln -s /usr/lib/ejre1.6.0_38/bin/java /usr/bin/java
sudo apt-get install openjdk-7-jre-headless
java

YaCy Installation

There is the option to install YaCy like any other debian package (see: Debian Installation), but then you cannot use the Oracle JVM as described above. We will just use the YaCy tarball release.

wget https://release.yacy.net/yacy_latest.tar.gz
tar xfz yacy_latest.tar.gz

We should change some default settings in the yacy.init file (lower RAM usage and lower disk space limit)

sed "s/disk.free = 3000/disk.free = 1000/" -i ~/yacy/defaults/yacy.init
sed "s/javastart_Xmx=Xmx600m/javastart_Xmx=Xmx120m/" -i ~/yacy/defaults/yacy.init

Now you can start YaCy:

~/yacy/startYACY.sh
~/yacy/bin/passwd.sh {yournewpassword}

If you click on a protected page in YaCy, you must put in that password.

YaCy Auto-Start and Watchdog

We want that our RPi starts YaCy at boot time and shuts it down properly. Create a file in /etc/init.d/yacy with the following content:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          YaCy
# Required-Start:    $local_fs $remote_fs $network $time
# Required-Stop:     $local_fs $remote_fs $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: YaCy Search Engine
### END INIT INFO
case "$1" in
 start)
  su - pi -c "/home/pi/yacy/startYACY.sh"
  ;;
 stop)
  su - pi -c "/home/pi/yacy/stopYACY.sh"
  ;;
 *)
  exit 3
  ;;
esac
:

and make it executable and linked with

sudo chmod 755 /etc/init.d/yacy
sudo update-rc.d yacy defaults

This will start and stop YaCy automatically. We also want that YaCy is supervised with a watchdog and automatically restarted if it failed, crashed or behaves dead. Add the following line to /etc/crontab

0 * * * * pi cd /home/pi/yacy/bin && ./checkalive.sh

This will check and if necessary restart YaCy once an hour.

YaCy Search on (default http) Port 80

You need an iptables entry for that, just write the following line into /etc/rc.local

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8090

Then your YaCy peer on the RPi is available at http://192.168.1.70

Converted from http://wiki.yacy.de/index.php?title=En:Raspberry_Pi, may be outdated