Wednesday, February 27, 2013

Tomboy's new sync-server Rainy running on the Raspberry Pi!


As Ubuntu One is shutting down their note-sync service based on the Snowy server, I needed to come up with a solution for this problem. My main thought was: Why should I trust anyone on this again, if it is so easy to build your own "cloud" for syncing notes?
Rainy is still in early development, but already does an awesome job on syncing notes between Tomboy and Tomdoid. Special thanks to Timo Dรถrr for this! Further, the Raspberry Pi (a credit-card sized computer) is the ideal platform for this purpose as it only "eats" 2 Watts per hour and can be easily run 24/7.

How do I build my own note-sync-server?

To create a minimal Debian system on a SD Card for the Raspberry Pi, just follow the steps here: 
http://blog.kmp.or.at/2012/05/build-your-own-raspberry-pi-image/

In summary you need to:
1. Install these dependencies on your computer: 
apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx lvm2 dosfstools
2. Adopt the script (Optional! Just search for the lines and put your things in there!):
x) Change the debian mirror url: deb_mirror="http://http.debian.my/debian"
x) Add the network interface wlan0 for wifi access and use a static IP address of your choice:
echo "auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet static
# address 192.168.0.4
# netmask 255.255.255.0
# gateway 192.168.0.1

auto wlan0
iface wlan0 inet static
address 192.168.0.4
netmask 255.255.255.0
gateway 192.168.0.1
wpa-ssid MYSSID
wpa-psk MYWIRELESSKEY
" > etc/network/interfaces

    x) Change the password: echo \"root:MYPASSWORD\" | chpasswd
    x) Add packages to pre-install for wifi (you might need other firmware packages!): 
apt-get -y install locales console-common ntp openssh-server less vim wireless-tools firmware-atheros firmware-realtek wpasupplicant
3. Run script: sudo ./build_rpi_sd_card.sh /dev/sdX
4. Put the SD Card into your Raspberry Pi and plug it in. It should automatically connect to your wifi (or lan)!

After you logged in (either directly or over ssh root@192.168.0.4), you will see a typical Linux shell. At first we will have to install the dependencies and necessary packages for our mono based Rainy server:
apt-get -y install libmono-system-runtime2.0-cil libmono-microsoft-csharp4.0-cil libmono-system-componentmodel-dataannotations4.0-cil libmono-system-web2.0-cil libmono-system-web-services4.0-cil libmono-system-data-linq2.0-cil libmono-system-data-linq4.0-cil libmono-system-web-abstractions4.0-cil mono-runtime unzip screen
Then we have to download the pre-compiled Rainy binary, unzip it and change into the directory:
wget http://rainy.notesync.org/release/rainy-0.1.3.zip
unzip rainy-0.1.3.zip
cd rainy-0.1.3
With a text editor of you choice you can edit the settings.conf file to change the user names, passwords, etc. Then start Rainy:
mono Rainy.exe -c settings.conf
If you want to run the server as a background job, I suggest to use screen. A very short explanation on how it works can be found here: http://jjjjango.blogspot.co.at/2013/01/linux-start-long-running-jobs-with-ssh.html

Now open your Tomboy, or Tomdroid and add the new sync server URL:
http://192.168.0.4:8080/<username>/<password>/
If you want to sync from outside your home, you have to redirect the 8080 port of your router to the IP address of the Pi. Further, you have to use the public IP of your router in the sync URL. In case you get a dynamic public IP, you will have to use http://www.noip.com/ or a similar service.

I hope, you know what to do! If not, please don't hesitate and ask your questions in the comments!