Difference between revisions of "Hardware: Raspberry Pi - Dashboard (Kiosk)"

From Luky-Wiki
Jump to: navigation, search
(Configuration)
(Configuration (Op2))
Line 292: Line 292:
  
  
... <code>/etc/systemd/system/dashboard.service</code>:
+
Recent version of Rasbian use systemd. Therefore we need systemd startup configuration. Create <code>/etc/systemd/system/dashboard.service</code> with content:
 
 
 
<pre>
 
<pre>
 
[Unit]
 
[Unit]
Line 307: Line 306:
 
</pre>
 
</pre>
  
 +
Reload configuration and start service:
  
 
<pre>
 
<pre>

Revision as of 15:01, 6 May 2016

Do You have spare RPi and big monitor / TV ? If yes then let's try to build dashboard. There are several ways how to get "data" on screen. Most common is to use browser to do all rendering and remote connections. This article describe configuration using browser. Browser needs X11 subsystem and there are several ways how to start X11 + browser. I selected two most common options.

Base OS

I recommend Rasbian installed using unattended installer. Keyboard is not necessary to perform installation and re-instillation. This article describe re-installation but with small modification you can use it also durring initial installation. Raspbian UA installer can be obtained from release page or homepage.

Step 1

Cleanup /boot and replace it with UA installer.

cd /root
wget https://github.com/debian-pi/raspbian-ua-netinst/releases/download/v1.0.8.1/raspbian-ua-netinst-v1.0.8.1.zip

cd /boot
rm -rf *

unzip /root/raspbian-ua-netinst-v1.0.8.1.zip

Step 2

Configure root file system type and hostname / domain.

Invoke editor:

vi /boot/installer-config.txt

Insert following lines:

hostname=RPi-hostname
domainname=localhost.localdomain
rootpw=root
rootfstype=btrfs

Alter hostname / domainname to fit your installation. Root password stay visible in this configuration file after installation. I recommend do leave it as is here and change it later.

Step 3

Start installation:

cd /
umount /boot

reboot -f

For more details review Raspbian UA installer documentation. After installation log-in using ssh and user: root / password: root"

OS configuration

Initial config

UA installer install only minimum packages and configuration files. It is necessary to "customize" system upon first log-in.

Locales:

dpkg-reconfigure locales
en_GB.UTF-8...
en_US.UTF-8...
sk_SK.UTF-8...

Timezone:

dpkg-reconfigure tzdata
Europe/Bratislava

root password:

passwd

Base packages installation

Minimum set of tools:

apt-get install raspi-config btrfs-tools apt-utils

Note: separate installation of "apt-utils" will speed up installation of packages later

System tools (may help to diagnose problems):

apt-get install screen htop nload git-core traceroute mc ddrescue rsync vim pydf lsof psmisc unzip util-linux collectl

HDMI port configuration

I highly recommend to disable overscan and properly configure connected TV / Monitor. It is necessary to switch TV aspect to "1:1", "Just", "16:9", "PC" or other mode (depending on vendor) to get 1:1 pixel mapping. Screen may be blurry without this configuration.

Overscan can be disabled by editing /boot/config.txt. Add following line:

disable_overscan=1

It may be neccesary to tweak it a bit more (depending on age of TV). Check RPiconfig for more details. Configuration is loaded on next reboot.

Network Time

If You don't like default NTP configuration and/or RPi can't be auto-configured (via DHCP) then configure NTP manually. Here is example how to do this configuration:

NTP daemon should be installed but to be sure:

apt-get install ntp

Then edit /etc/ntp.conf. I am using following configuration:

# Name of the servers ntpd should sync with

server ntp-server1
server ntp-server2

# local failback in case of network failure
server 127.127.1.0

# you should not need to modify the following paths
driftfile		/var/lib/ntp/ntp.drift
logfile			/var/log/ntp.log

# restriction config 
restrict default	nomodify notrap nopeer noquery
restrict 127.0.0.1	nomodify notrap nopeer

# EOF

Note: replace ntp-server1 and ntp-server2 with local ntp servers

Restart NTP to load new configuration:

/etc/init.d/ntp restart

Verify configuration using following command. It may take some time before NTP protocol settle down.

ntpq -p

Root Password + accounts

If You don't changed root password yet, then I recommend to do it now:

passwd root

Add user account(s):

useradd --create-home --shell /bin/bash lukas
passwd lukas

Replace "lukas" with your preferred name :o)

Add dashboard user:

useradd --create-home --shell /bin/bash dashboard

(optional) Migrate system to subvolume

One of great benefits of BTRFS is ability to take snapshots. It is necessary to have system in subvolume in order to utilize all its features. Here is step by step guide how to migrate system into subvolume.

Configure boot subvolume. Edit /boot/cmdline.txt and add following to end of line:

rootflags=subvol=system

Edit /etc/fstab and modify definition for / to looks like:

/dev/mmcblk0p2	/ 	btrfs 	noatime,subvol=system	0 0

Add entry point for btrfs system. Edit /etc/fstab and add following line:

/dev/mmcblk0p2	/btrfs 	btrfs 	noatime,subvolid=0	0 0

Create mountpoint and try to mount btrfs entry point:

mkdir /btrfs
chmod 0 /btrfs
mount /btrfs

Create subvolume by using snapshot feature:

btrfs sub snap / /system

Create file that indicate successful boot from subvolume and reboot system:

touch /system/boot_ok.txt

shutdown -r now

After reboot check if boot_ok.txt is directly in /. If yes then proceed with clenaup of /btrfs. There should remain only "system" subvolume / directory.

Option 1 -> Browser started using display manager

Required packages (Op1)

Following packages are required:

apt-get install midori unclutter x11-xserver-utils lightdm lxde

Note: unclutter will make sure that mouse pointed is hidden while input is idle.

Configuration (Op1)

Automatic cleanup. This will ensure that there will be no data left over from previous run of system / browser. Edit /etc/rc.local and add:

find /home/dashboard/ -mindepth 1 -delete

LightDM configuration. Edit /etc/lightdm/lightdm.conf and replace it with:

[SeatDefaults]
xserver-command=/usr/bin/X -s 0 -dpms
default-user=dashboard
autologin-user=dashboard
autologin-user-timeout=0
user-session=LXDE
greeter-session=lightdm-gtk-greeter
allow-guest=false

Edit /etc/xdg/lxsession/LXDE/autostart and insert following configuration:

@xset -dpms
@xset s off
@midori -e Fullscreen -a http://example.com/dashboard

Testing

Option 2 -> Browser started using init

Required packages (Op2)

Following packages are required:

apt-get install midori unclutter x11-xserver-utils xinit lwm

Note: unclutter will make sure that mouse pointed is hidden while input is idle.

Configuration (Op2)

Default security may be too strict to start X11 server from user account. Therefore it is necessary to tweak it a bit.

Execute following command:

dpkg-reconfigure x11-common

Select "Anybody" from menu. It is possible to do same by editing /etc/X11/Xwrapper.config but is not recommended.

This idea use one specific script that handle startup of dashboard. Create /usr/local/bin/dashboard-start.sh with following content:

#!/bin/bash

exec >> /var/log/dashboard.log 2>&1

echo
LANG=C date

echo
echo Cleaning homedir ...
find /home/dashboard/ -mindepth 1 -ls -delete

echo
echo Creating startup file ...
(

echo    'xset -dpms'
echo    'xset s off'
echo    'lwm &'
echo    'unclutter &'
echo    'exec midori -e Fullscreen -a http://example.com/dashboard'

) > /home/dashboard/.xinitrc
cat /home/dashboard/.xinitrc

echo
echo Starting X11 session ...
su - dashboard -c "startx -- tty7 -s 0 dpms"

echo
echo Waiting before restart ...
for a in 60 50 40 30 20 10 00
do
        echo -n "$a "
        sleep 10
done
echo

echo
echo Forcing termination of script ...
exec sleep 1

# EOF


Recent version of Rasbian use systemd. Therefore we need systemd startup configuration. Create /etc/systemd/system/dashboard.service with content:

[Unit]
Description=RPi dashboard
After=getty.target

[Service]
ExecStart=/usr/local/bin/dashboard-start.sh
Restart=always

[Install]
WantedBy=multi-user.target

Reload configuration and start service:

systemctl daemon-reload
systemctl start dashboard.service

Testing

Synthetic F5 (reload)

Dashboard source posibilities

Watchdog

snapshot

backup ?