Difference between revisions of "Raspberry Pi2 Raspbian"

From Davical
Jump to navigationJump to search
(SW installation guide)
(DAViCal Install)
 
(22 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
'''Hardware tested:'''
 
'''Hardware tested:'''
 
* 2015-11-07: Raspberry Pi 2 model B
 
* 2015-11-07: Raspberry Pi 2 model B
 +
* 2015-06-18: Raspberry Pi 2 model B
  
 
'''System tested:'''
 
'''System tested:'''
 
* 2015-11-07: Raspbian jessie released on 2015-09-24
 
* 2015-11-07: Raspbian jessie released on 2015-09-24
 +
* 2016-06-18: Raspbian jessie released on 2016-05-27
  
 
'''Software versions tested:'''
 
'''Software versions tested:'''
 
* 2015-11-07: TBD ''DAViCal xxx, PostgreSql xxx, InfCloud xxx''
 
* 2015-11-07: TBD ''DAViCal xxx, PostgreSql xxx, InfCloud xxx''
 +
* 2016-06-18: TBD ''DAViCal 1.1.3.1, AWL 0.55, PostgreSql 9.4.8, InfCloud xxx''
  
 
= HW and network installation guide =
 
= HW and network installation guide =
Line 32: Line 35:
 
== Preparing Raspberry Pi micro-SD card from a linux computer ==
 
== Preparing Raspberry Pi micro-SD card from a linux computer ==
 
* download Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
 
* download Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  wget https://downloads.raspberrypi.org/raspbian_latest
+
  wget https://downloads.raspberrypi.org/raspbian_lite_latest
  unzip 2015-09-24-raspbian-jessie.zip
+
  openssl dgst -sha1 raspbian_lite_latest
  md5sum 2015-09-24-raspbian-jessie.img
+
# SHA1(raspbian_lite_latest)= 03b6ea33efc3bb4d475f528421d554fc1ef91944
  # a24eed8b6338940013cdcd5a74a3935d  2015-09-24-raspbian-jessie.img
+
  unzip raspbian_lite_latest
 +
  # 2016-05-27-raspbian-jessie-lite.img
 
* flash your micro-SD card (carefully identify micro-SD card device letter and replace sdX with correct drive!)
 
* flash your micro-SD card (carefully identify micro-SD card device letter and replace sdX with correct drive!)
 
  # before micro-SD card connexion, have a look to your computer drives (to preserve)
 
  # before micro-SD card connexion, have a look to your computer drives (to preserve)
Line 41: Line 45:
 
  # after micro-SD card connexion, have a look to the new micro-SD card drive (to write to)
 
  # after micro-SD card connexion, have a look to the new micro-SD card drive (to write to)
 
  ls -l /dev/sd?
 
  ls -l /dev/sd?
  dd bs=2M if=2015-09-24-raspbian-jessie.img of=/dev/sdX
+
  dd bs=2M if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdX
 
  sync
 
  sync
 
  # if root required, you probably need to prefix dd and gparted commands with sudo
 
  # if root required, you probably need to prefix dd and gparted commands with sudo
* expand your raspberry / partition to full micro-SD card
+
* expand your raspberry / partition to full micro-SD card (useless with Raspbian 2018-11-13 and next versions)
 
  gparted
 
  gparted
 
  # select micro-SD drive
 
  # select micro-SD drive
Line 71: Line 75:
 
If you fail guessing your Raspberry IP address:
 
If you fail guessing your Raspberry IP address:
 
* connect USB mouse and Keyboard + HDMI display
 
* connect USB mouse and Keyboard + HDMI display
* launch a terminal
 
  
 
Then, you should write down a paper your Raspberry Mac address:
 
Then, you should write down a paper your Raspberry Mac address:
Line 80: Line 83:
 
Some boxes need a reboot to make static DHCP reservations active.
 
Some boxes need a reboot to make static DHCP reservations active.
  
= SW installation guide (under construction) =
+
= SW installation guide =
(adapted from [Debian_shared])
+
== DAViCal Install ==
  
(3201140 kb used on /)
+
(adapted and simplified from [[Debian_shared]])
 +
 
 +
(858384 kb used on /)
  
 
Install current DAViCal version with Jessie dependencies:
 
Install current DAViCal version with Jessie dependencies:
 
  sudo apt-get update
 
  sudo apt-get update
 +
sudo apt-get upgrade
 
  sudo apt-get install locales
 
  sudo apt-get install locales
  export LANGUAGE='en_GB'
+
  export LANGUAGE="en_GB"
 
  export LC_ALL="en_GB.UTF-8"
 
  export LC_ALL="en_GB.UTF-8"
  sudo dpkg-reconfigure locales
+
  sudo dpkg-reconfigure locales             # select your locale with TUI
 
  sudo apt-get install davical davical-doc
 
  sudo apt-get install davical davical-doc
  
(3277004 kb used on /)
+
(1121108 kb used on /)
  
 
To be continued...
 
To be continued...
Line 116: Line 122:
 
  sudo cat "${PgConfig}.davical-bak" | sudo tee --append "$PgConfig"
 
  sudo cat "${PgConfig}.davical-bak" | sudo tee --append "$PgConfig"
 
  # Service name can be only "postgresql" or more:
 
  # Service name can be only "postgresql" or more:
  sudo service postgresql-${MediumPgVersion} reload
+
  sudo service postgresql reload
  
 
Apply a temporary patch to creation script:
 
Apply a temporary patch to creation script:
Line 134: Line 140:
  
 
'''(only restoration of a backup)''' Restore data and run update script:
 
'''(only restoration of a backup)''' Restore data and run update script:
  echo "DROP DATABASE IF EXISTS mycaldb;" | sudo su -l postgres -c psql
+
  echo "DROP DATABASE IF EXISTS ${DatabaseName};" | sudo su -l postgres -c psql
  echo "DROP USER IF EXISTS mycaluser_dba;" | sudo su -l postgres -c psql
+
  echo "DROP USER IF EXISTS ${DBUsername_dba};" | sudo su -l postgres -c psql
  sudo su -l postgres -c "psql --quiet --file mycaluser_dba.pgdump"
+
  sudo su -l postgres -c "psql --quiet --file ${DBUsername_dba}.pgdump"
  echo "DROP USER IF EXISTS mycaluser_app;" | sudo su -l postgres -c psql
+
  echo "DROP USER IF EXISTS ${DBUsername_app};" | sudo su -l postgres -c psql
  sudo su -l postgres -c "psql --quiet --file mycaluser_app.pgdump"
+
  sudo su -l postgres -c "psql --quiet --file ${DBUsername_app}.pgdump"
  sudo su -l postgres -c "psql --quiet --file mycaldb.pgdump"
+
  sudo su -l postgres -c "psql --quiet --file ${DatabaseName}.pgdump"
 
  sudo su -l postgres -c "$UScript"
 
  sudo su -l postgres -c "$UScript"
  
Line 157: Line 163:
 
  sudo cat "${PgConfig}.davical-bak" | sudo tee --append "$PgConfig"
 
  sudo cat "${PgConfig}.davical-bak" | sudo tee --append "$PgConfig"
 
  # Service name can be only "postgresql" or more:
 
  # Service name can be only "postgresql" or more:
  sudo service postgresql-${MediumPgVersion} reload
+
  sudo service postgresql reload
  
Create or restore configuration file as /etc/davical/caldav.example.net-conf.php (for a virtualhost ''caldav.example.net'') with its content as in the following example:
+
Create or restore configuration file as /etc/davical/config.php (for default host ''example.net/davical'') with its content as in the following example:
 
  <?php
 
  <?php
 
  $c->admin_email = 'admin@example.net';
 
  $c->admin_email = 'admin@example.net';
 
  $c->system_name = "My CalDAV Server";
 
  $c->system_name = "My CalDAV Server";
 
  $c->enable_row_linking = true;
 
  $c->enable_row_linking = true;
  $c->default_locale = 'en_US.UTF-8';
+
  $c->default_locale = 'en_US.UTF-8';           # or something else: fr_FR.UTF-8, ...
 
 
 
 
 
  $c->pg_connect[] = 'dbname=mycaldb port=5432 user=mycaluser_app password=12345';
 
  $c->pg_connect[] = 'dbname=mycaldb port=5432 user=mycaluser_app password=12345';
 +
 
Avoid permissions issues:
 
Avoid permissions issues:
  sudo chmod a+r /etc/davical/caldav.example.net-conf.php
+
  sudo chmod a+r /etc/davical/config.php
  
Create or restore Apache virtualhost with its profile content as in this example:
+
Create or restore Apache virtualhost /etc/apache2/sites-available/000-default.conf with its profile content as in this example:
  <VirtualHost *:80 *:8008 *:8800>
+
  <VirtualHost *:80>
  ServerName caldav.example.net
+
  ServerAdmin webmaster@localhost
  DocumentRoot /usr/share/davical/htdocs
+
  DocumentRoot /var/www/html
DirectoryIndex index.php index.html
+
        ErrorLog ${APACHE_LOG_DIR}/error.log
Alias /images/ /usr/share/davical/htdocs/images/
+
        CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /usr/share/davical/htdocs/>
 
AllowOverride None
 
Order allow,deny
 
Allow from all
 
</Directory>
 
php_value include_path /usr/share/awl/inc
 
php_value magic_quotes_gpc 0
 
php_value magic_quotes_runtime 0
 
php_value register_globals 0
 
php_value error_reporting "E_ALL & ~E_NOTICE"
 
php_value default_charset "utf-8"
 
 
  </VirtualHost>
 
  </VirtualHost>
(Apache may need to be configured in ports.conf to listen also ports 8008 and 8800)
 
  
Enable Apache website:
+
Enable Apache website (may be useless):
  sudo a2ensite caldav.example.net
+
  sudo a2ensite 000-default
 +
 
 +
Enable davical:
 +
cd /var/www/html
 +
sudo ln -s /usr/share/davical/htdocs/ davical
 +
 
 +
Now you should be able to browse to example.net/davical with your favourite web browser. If not, check example.net/davical/setup.php for details.
  
==== Login to DAViCAL Admin ====
+
== Login to DAViCal Admin ==
  
 
If all is going well you should now be able to browse to the site pages and log in as 'admin' with the password set during installation.
 
If all is going well you should now be able to browse to the site pages and log in as 'admin' with the password set during installation.
 +
 +
== Apache2 setup for SSL access to DAViCal ==
 +
 +
Install SSL for apache2:
 +
sudo apt-get install ssl-cert
 +
sudo mkdir /etc/apache2/ssl
 +
sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem # (localhost + your box's public IP address)
 +
sudo a2enmod ssl
 +
sudo service apache2 restart
 +
sudo a2ensite default-ssl
 +
sudo service apache2 reload
 +
 +
Now, you can browse https://example.net/davical (you will probably have to add an exception in your browser because of self-signed certificate).
 +
 +
== InfCloud setup (optional) ==
 +
 +
Check for InfCloud version at https://www.inf-it.com/open-source/clients/infcloud/
 +
 +
Download, unzip configure an run InfCloud:
 +
cd
 +
wget https://www.inf-it.com/InfCloud_0.13.1.zip
 +
cd /usr/share
 +
sudo unzip $HOME/InfCloud_0.13.1.zip
 +
cd infcloud
 +
sudo vi config.js # In globalNetworkCheckSettings=, change '/caldav.php/' with '/davical/caldav.php/'
 +
sudo vi config.js # Check for globalInterfaceLanguage, globalDatepickerFirstDayOfWeek, globalDefaultAddressCountry
 +
cd /var/www/html
 +
sudo ln -s /usr/share/infcloud/ infcloud
 +
sudo service apache2 reload
 +
 +
Now you should be able to browse to example.net/infcloud with your favourite web browser (and through https if apache2 configured for SSL) and login with davical account.
 +
Note: due to HTML5 browser caching, an update in config.js after browsing will probably need to delete browser cache manually.

Latest revision as of 19:42, 6 April 2019

UNDER CONSTRUCTION

This guide is intended to people who want a lightweight calendar server at home, behind an internet box, up 24h/24h, with very low consumption, and chose a cheap Raspberry Pi. This guide has been written according to Raspberry Pi 2 model B but shall be working also with others versions. This guide explains how to install DaviCal calendar server and optionally InfCloud CalDAV/CardDAV web clients. It assume an other linux computer is available on the LAN with an Internet connexion.

Hardware tested:

  • 2015-11-07: Raspberry Pi 2 model B
  • 2015-06-18: Raspberry Pi 2 model B

System tested:

  • 2015-11-07: Raspbian jessie released on 2015-09-24
  • 2016-06-18: Raspbian jessie released on 2016-05-27

Software versions tested:

  • 2015-11-07: TBD DAViCal xxx, PostgreSql xxx, InfCloud xxx
  • 2016-06-18: TBD DAViCal 1.1.3.1, AWL 0.55, PostgreSql 9.4.8, InfCloud xxx

HW and network installation guide

Before starting, what you need

  • a Raspberry with RJ45 LAN connector (Pi 2 model B for example)
  • a Raspberry Pi Case (optional, but advised)
  • a 8 Go micro-SD card
  • a Raspberry Pi universal power supply (or equivalent)
  • an internet box with a free RJ45 connexion
  • an Ethernet cable (RJ45)
  • an other computer with an internet connexion and a micro-SD card adapter

See distributors on Raspberry shop page: https://www.raspberrypi.org/products/

What you don't need but can be useful

  • an USB keyboard
  • an USB mouse
  • an HDMI display

Preparing Raspberry Pi micro-SD card from a linux computer

wget https://downloads.raspberrypi.org/raspbian_lite_latest
openssl dgst -sha1 raspbian_lite_latest
# SHA1(raspbian_lite_latest)= 03b6ea33efc3bb4d475f528421d554fc1ef91944
unzip raspbian_lite_latest
# 2016-05-27-raspbian-jessie-lite.img
  • flash your micro-SD card (carefully identify micro-SD card device letter and replace sdX with correct drive!)
# before micro-SD card connexion, have a look to your computer drives (to preserve)
ls -l /dev/sd?
# after micro-SD card connexion, have a look to the new micro-SD card drive (to write to)
ls -l /dev/sd?
dd bs=2M if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdX
sync
# if root required, you probably need to prefix dd and gparted commands with sudo
  • expand your raspberry / partition to full micro-SD card (useless with Raspbian 2018-11-13 and next versions)
gparted
# select micro-SD drive
# right click on / partition and expand it to full size
# click on apply
# remove micro-SD card from linux computer

Connecting Raspberry Pi to LAN and boot

Okay, you need a RJ45 cable between Raspberry and your box, insert micro-SD card into your Raspberry and plug on power supply. You can check:

  • near micro-SD card, red light ON
  • green light blinking few seconds and then OFF
  • near RJ45 connector yellow and red lights ON

If red and green lights are ON near micro-SD card, you may have a problem with your SD-card (missing, wrongly inserted, badly flashed, ...).

Now, you just have to guess your Raspberry Pi IP address! What you can try:

  • have a look to your box administration page
  • get your linux computer IP address
ifconfig
# inet addr: 192.168.x.y
  • try addresses 192.168.x.2 to 192.168.x.254 around y
  • connect to your Raspberry Pi
ssh -Y pi@192.168.x.z
# password: raspberry

If you fail guessing your Raspberry IP address:

  • connect USB mouse and Keyboard + HDMI display

Then, you should write down a paper your Raspberry Mac address:

ifconfig
# HWaddr aa:bb:cc:dd:ee:ff

And configure your box router to assign a static local IP address to your Raspberry. Static DHCP reservation assigns a local IP address to a Mac HWaddr. Some boxes need a reboot to make static DHCP reservations active.

SW installation guide

DAViCal Install

(adapted and simplified from Debian_shared)

(858384 kb used on /)

Install current DAViCal version with Jessie dependencies:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install locales
export LANGUAGE="en_GB"
export LC_ALL="en_GB.UTF-8"
sudo dpkg-reconfigure locales              # select your locale with TUI
sudo apt-get install davical davical-doc

(1121108 kb used on /)

To be continued...


Prepare the DAViCal database values (please, for security reasons, choose your own values):

DatabaseName=mycaldb
DBUsername_dba=mycaluser_dba
DBUsername_app=mycaluser_app
DBPassword=12345
AdminPassword=1234

Add open permissions temporarily for the installation scripts:

MediumPgVersion="$(psql --version | grep -ie "sql" | tr -s " " "\n" | tail --lines=1 | cut -f 1,2 -d ".")"
PgConfig="/etc/postgresql/${MediumPgVersion}/main/pg_hba.conf"
sudo mv "$PgConfig" "${PgConfig}.davical-bak"
sudo cp -a "${PgConfig}.davical-bak" "$PgConfig"
echo "# Permissions for the DAViCal CMS" | sudo tee "$PgConfig"
echo "local $DatabaseName $DBUsername_dba trust" | sudo tee --append "$PgConfig"
echo "local $DatabaseName $DBUsername_app trust" | sudo tee --append "$PgConfig"
echo "" | sudo tee --append "$PgConfig"
sudo cat "${PgConfig}.davical-bak" | sudo tee --append "$PgConfig"
# Service name can be only "postgresql" or more:
sudo service postgresql reload

Apply a temporary patch to creation script:

CScript="/usr/share/davical/dba/create-database.sh"
sudo mv "$CScript" "${CScript}.davical-bak"
sudo cp -a "${CScript}.davical-bak" "$CScript"
cat "${CScript}.davical-bak" | sed -e "s/DBNAME=.*/DBNAME=${DatabaseName}/g" | sed -e "s/AWL_DBAUSER=.*/AWL_DBAUSER=${DBUsername_dba}/g" | sed -e "s/AWL_APPUSER=.*/AWL_APPUSER=${DBUsername_app}/g" | sudo tee "$CScript"

Apply a temporary patch to update script:

UScript="/usr/share/davical/dba/update-davical-database"
sudo mv "$UScript" "${UScript}.davical-bak"
sudo cp -a "${UScript}.davical-bak" "$UScript"
cat "${UScript}.davical-bak" | sed -e "s/\$dbname = .*/\$dbname = \"${DatabaseName}\";/g" | sed -e "s/\$dbuser = .*/\$dbuser = \"${DBUsername_dba}\";/g" | sed -e "s/\$appuser = .*/\$appuser = \"${DBUsername_app}\";/g" | sed -e "s/\$dbpass = .*/\$dbpass = \"${DBPassword}\";/g" | sudo tee "$UScript"

(only fresh install) Run main installation script and take note of the shown password for the 'admin' user:

sudo su -l postgres -c "$CScript" "$DatabaseName" "$AdminPassword"

(only restoration of a backup) Restore data and run update script:

echo "DROP DATABASE IF EXISTS ${DatabaseName};" | sudo su -l postgres -c psql
echo "DROP USER IF EXISTS ${DBUsername_dba};" | sudo su -l postgres -c psql
sudo su -l postgres -c "psql --quiet --file ${DBUsername_dba}.pgdump"
echo "DROP USER IF EXISTS ${DBUsername_app};" | sudo su -l postgres -c psql
sudo su -l postgres -c "psql --quiet --file ${DBUsername_app}.pgdump"
sudo su -l postgres -c "psql --quiet --file ${DatabaseName}.pgdump"
sudo su -l postgres -c "$UScript"

Restore installation scripts to original:

sudo mv "${UScript}.davical-bak" "$UScript"
sudo mv "${CScript}.davical-bak" "$CScript"

(only fresh install) Set password authentication for the database:

echo "ALTER USER $DBUsername_dba WITH PASSWORD '${DBPassword}';" | sudo su -l postgres -c psql
echo "ALTER USER $DBUsername_app WITH PASSWORD '${DBPassword}';" | sudo su -l postgres -c psql

Allow these authenticated access to PostgreSql:

echo "# Permissions for the DAViCal CMS" | sudo tee "$PgConfig"
echo "local $DatabaseName $DBUsername_dba password" | sudo tee --append "$PgConfig"
echo "local $DatabaseName $DBUsername_app password" | sudo tee --append "$PgConfig"
echo "" | sudo tee --append "$PgConfig"
sudo cat "${PgConfig}.davical-bak" | sudo tee --append "$PgConfig"
# Service name can be only "postgresql" or more:
sudo service postgresql reload

Create or restore configuration file as /etc/davical/config.php (for default host example.net/davical) with its content as in the following example:

<?php
	$c->admin_email = 'admin@example.net';
	$c->system_name = "My CalDAV Server";
	$c->enable_row_linking = true;
	$c->default_locale = 'en_US.UTF-8';            # or something else: fr_FR.UTF-8, ...
	
	$c->pg_connect[] = 'dbname=mycaldb port=5432 user=mycaluser_app password=12345';

Avoid permissions issues:

sudo chmod a+r /etc/davical/config.php

Create or restore Apache virtualhost /etc/apache2/sites-available/000-default.conf with its profile content as in this example:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot	/var/www/html
       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable Apache website (may be useless):

sudo a2ensite 000-default

Enable davical:

cd /var/www/html
sudo ln -s /usr/share/davical/htdocs/ davical

Now you should be able to browse to example.net/davical with your favourite web browser. If not, check example.net/davical/setup.php for details.

Login to DAViCal Admin

If all is going well you should now be able to browse to the site pages and log in as 'admin' with the password set during installation.

Apache2 setup for SSL access to DAViCal

Install SSL for apache2:

sudo apt-get install ssl-cert
sudo mkdir /etc/apache2/ssl
sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem # (localhost + your box's public IP address)
sudo a2enmod ssl
sudo service apache2 restart
sudo a2ensite default-ssl
sudo service apache2 reload

Now, you can browse https://example.net/davical (you will probably have to add an exception in your browser because of self-signed certificate).

InfCloud setup (optional)

Check for InfCloud version at https://www.inf-it.com/open-source/clients/infcloud/

Download, unzip configure an run InfCloud:

cd
wget https://www.inf-it.com/InfCloud_0.13.1.zip
cd /usr/share
sudo unzip $HOME/InfCloud_0.13.1.zip
cd infcloud
sudo vi config.js # In globalNetworkCheckSettings=, change '/caldav.php/' with '/davical/caldav.php/'
sudo vi config.js # Check for globalInterfaceLanguage, globalDatepickerFirstDayOfWeek, globalDefaultAddressCountry
cd /var/www/html
sudo ln -s /usr/share/infcloud/ infcloud
sudo service apache2 reload

Now you should be able to browse to example.net/infcloud with your favourite web browser (and through https if apache2 configured for SSL) and login with davical account. Note: due to HTML5 browser caching, an update in config.js after browsing will probably need to delete browser cache manually.