Monday, 17 February 2014

bittorrent sync

Instead of using owncloud, which ran extremely slow on my Pi, I installed btsync (bittorrent sync). 

It is not an alternative for an "owncloud"-like service, but it is simple and efficient when it comes to syncing files made on the Raspberry's USB storage disk. 

When for example pictures are taken by the Raspberry, they immediately get synced to my other devices (iphone, ipad and mac), that is if you have the free BTsync app installed on your devices of course. There is also a version available for Mac which runs in the background.

You start by downloading the package from BitTorrent sync (ARM) and then follow these instructions (please note: I only used step 2 and 3 since I did not want the owncloud part!)

Have fun!

Thursday, 6 February 2014

Non graphical web browser and sending mails with RPi

This article is about setting up an automated task, using Lynx and sSMTP.

The goal is to set up a script which will automatically send an email to you with the current external IP address.

Lynx is a text browser for the web which you can use through the terminal. 

sSMTP is a lightweight mail client (it can not send attachments).


  • first install Lynx
sudo apt-get install lynx
You're done. Try this command line and see the result:
lynx -dump http://ipecho.net/plain 
(so this command reads the output of the webpage http://ipecho.net/plain and prints it out)
  • now install sSMTP
sudo apt-get install ssmtp
edit the ssmtp.conf file
sudo nano /etc/ssmtp/ssmtp.conf
verify that these settings are applied:
    • root=postmaster 
    • mailhub=smtp.gmail.com:587 
    • hostname=raspberrypi 
    • AuthUser=YourGmailUserName@gmail.com 
    • AuthPass=YourGmailPassword 
    • UseSTARTTLS=YES 
To be clear: in this case, the setup is for a gmail account. Change the mailhub if you use another account. Verify your hostname and enter your credentials.
Save and close this file.
Now edit the file revaliases
sudo nano /etc/ssmtp/revaliases
and add a line
pi:youremail@gmail.com:smtp.gmail.com:587  
Save and close this file.
Set permissions for ssmtp.conf to 774
sudo chmod 774 /etc/ssmtp/ssmtp.conf 
to test, try: lynx -dump http://ipecho.net/plain | mail -s "Your PI IP" me@myemailaddress.com


  •  instead of typing the complete command, you can create a script. Move to the directory where you want to create it, for example /home/pi and type:
sudo nano sendmemyIP.sh
copy the command line from above into the script and save and close it.
to make a cron job of this, you can copy this script to the hourly crons or daily crons, whichever you prefer:
sudo cp sendmemyIP.sh /etc/cron.hourly/sendmemyIP.sh

Pi Camera Board and Motion MMAL

I found this good working guide for installing Motion MMAL on the Raspberry Pi together with the Raspberry Pi Camera Board.

It enables you to build your own web surveillance camera.

First, when you connect your RPi camera board, make sure you have enabled it in raspi-config!

Now you can follow the clear instructions on this page: installing Motion-MMAL with Raspberry Pi Camera Board


Wednesday, 5 February 2014

Webmin: easy remote access to the Raspberry Pi through a web interface

Webmin allows you to see the complete setup of your RPi: configuration, attached storage, running processes, running servers, ability to create cron jobs, boot- and shut down options, network settings, and much much more... Very handy if you are not efficient enough with the linux tools and commands.

NOTE: it is better to install Webmin AFTER you have installed Apache2, PHP and MySQL (see later on in this blog)
  • Webmin website and installation instructions:
http://www.webmin.com/deb.html
After installation, open a web browser window on your Mac and enter the following address: 
https://yourIP:10000 
There you will be asked your login and password. 
The default port "10000" can be modified in the Webmin Configuration (left side bar), should you want to change that.

And voilĂ , a print screen for your information:


Make your web server accessible from the outside

The web server is now running (see previous article), but is only accessible from the local network. We should need outside access.

In this case I am lucky that we recently had a new modem/router from our ISP (Belgacom) on which you can easily enable DynDNS (Dynamic DNS).  (See below for non-Belgacom routers).

the steps:

  • sign up for a free account at No-IP and set up a hostname;
  • log in your router's page, mostly something like 192.168.1.1; 

  • click the "My Modem" section, and you will get this screen. Select the DynDNS tab. Switch the DynDNS button to "on", select the supplier (in this case No-IP) and fill out your username, password and hostname which you created at the No-IP web site;



  • go back to the home screen (192.168.1.1) and in the list of connected devices, select your Raspberry Pi;


  • A screen will pop-up in which you select the Port Forwarding tab. There you click "Add Rule" and fill out the following:
      • service: (no choice possible, so leave)
      • Protocol: TCP-UDP
      • External port: 80 (=default for web pages)
      • Internal host: is your Raspberry Pi's internal IP address
      • Internal port: 80
      • click OK and you're done.



Now if you connect your Raspberry to an external network (neighbour's wifi or wifi from iPhone) then you should be able to access the webpage (index.html in the /var/www folder) by typing the hostname which you created at No-IP instead of typing the Raspberry's static internal IP.


In case that you don't have a modem/router on which you can enable DynDNS then you can do the following: No-IP provides a DUC (Dynamic Update Client) which has to be installed on the Raspberry Pi. This software looks at an interval of 30 minutes (can be configured) what your external IP address is  and so enables that your web site stays accessible. The installation instructions are well explained in the link provided.

Tuesday, 4 February 2014

Apache2

setting up the webserver

For this we will be installing Apache2

sudo apt-get install apache2
Type "y" to agree for installation.

The folder /var/www is where the webpages will be located. This folder is owned by root and needs to be reassigned to user 'www-data' and group 'www-data'. Therefore type:

sudo chown -R www-data:www-data /var/www

(to check, type: cd /var and then ls -l : you will get a list of files and folders in the /var directory with their permissions)

To test the setup, open a browser window on a local computer (same network) and type in the IP address of the Raspberry Pi. You should see this screen: (this is in fact the index.html file located at your /var/www folder).




back up

Time for a first back up now we have our basic settings configured.

For this, I use the Pi Copier script. Can be found on Ivan's page. Simply install this on your Mac, put the Raspberry SD card in a card reader attached to your Mac and follow the instructions.

Tip: make sure your screensaver or sleep settings from the Mac are more than 30 minutes. If not you could get a time out error, in which case you just have to restart the procedure.




Tip: once the back up is finished, I select the back up file on the Mac and press Cmd+i. In the box "Spotlight comments" above, I fill in all the programs or settings which I already installed.