Difference between revisions of "Raspberry Pi2 Raspbian"
Line 84: | Line 84: | ||
(adapted from [Debian_shared]) | (adapted 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 install locales | sudo apt-get install locales | ||
export LANGUAGE= | 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 | ||
( | (1014128 kb used on /) | ||
To be continued... | To be continued... |
Revision as of 22:42, 17 June 2016
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
System tested:
- 2015-11-07: Raspbian jessie released on 2015-09-24
Software versions tested:
- 2015-11-07: TBD DAViCal xxx, PostgreSql xxx, 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
- download Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
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
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
- launch a terminal
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 (under construction)
(adapted from [Debian_shared])
(858384 kb used on /)
Install current DAViCal version with Jessie dependencies:
sudo apt-get update 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
(1014128 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-${MediumPgVersion} 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-${MediumPgVersion} 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:
<?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'; $c->pg_connect[] = 'dbname=mycaldb port=5432 user=mycaluser_app password=12345';
Avoid permissions issues:
sudo chmod a+r /etc/davical/caldav.example.net-conf.php
Create or restore Apache virtualhost with its profile content as in this example:
<VirtualHost *:80 *:8008 *:8800> ServerName caldav.example.net DocumentRoot /usr/share/davical/htdocs DirectoryIndex index.php index.html Alias /images/ /usr/share/davical/htdocs/images/ <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>
(Apache may need to be configured in ports.conf to listen also ports 8008 and 8800)
Enable Apache website:
sudo a2ensite caldav.example.net
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.