User Tools

Site Tools


operating_systems:raspbian:easydoor_configuration

This is an old revision of the document!


easyDoor configuration

Intercom

config.txt

Add this to your /boot/config.txt file

# Reference: https://elinux.org/RPiconfig
# This option should be specified when using the camera module
start_x=1
# The rainbow splash screen will not be shown on boot
disable_splash=1

#gpu_mem=128

#ignore_lcd=0

# Rotates the display 90 degrees clockwise on the screen (default=0) or flips the display
display_rotate=1

# Comment the following line to enable Bluetooth
dtoverlay=pi3-disable-bt

# Removes the warning overlay
avoid_warnings=1

Remove boot log messages

# vi /boot/cmdline.txt
logo.nologo splash vt.global_cursor_default=0 loglevel=3

xorg setup

# apt install --no-install-recommends xorg
# apt install --no-install-recommends xinput unclutter iceweasel matchbox-window-manager
Make sure .Xauthority has the folowing owners - root:root

If you start XORG it WON'T WORK since the system is in READ-ONLY mode. To solve this problem, move .Xauthority to a READ-WRITE DIRECTORY.

# mkdir /media/data/root
# touch /media/data/root/.Xauthority
# chmod 600 /media/data/root/.Xauthority
Make sure that ONLY ROOT user can READ and WRITE into .Xauthority. If it doesn't have, you will get the following error: Error in locking authority file

rc.local

Add this to your /etc/rc.local file

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
export HOME=/root
# Sets .xauthority location file
export XAUTHORITY=/media/data/root/.Xauthority
/usr/bin/startx &
 
sudo modprobe bcm2835-v4l2

.xinitrc

Your /root/.xinit file should look like this

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
/bin/echo -ne "\nStarting: " >> /tmp/startx.log
/bin/date >> /tmp/startx.log

export DISPLAY=:0

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

#/bin/echo -ne "\nDisabling screensaver: " >> /tmp/startx.log
#/bin/date >> /tmp/startx.log

#/usr/bin/xset s noblank
#/usr/bin/xset s off
#/usr/bin/xset -dpms

/bin/echo -ne "\nTouchscreen correction: " >> /tmp/startx.log
/bin/date >> /tmp/startx.log

# Fix inverted mouse/pointer issues on touch screen
/usr/bin/xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1 &
/usr/bin/xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1 &

/bin/echo -ne "\nRemoving iceweasel files: " >> /tmp/startx.log
/bin/date >> /tmp/startx.log

/bin/sleep 5

/bin/echo -ne "\nStarting iceweasel: " >> /tmp/startx.log
/bin/date >> /tmp/startx.log
#/bin/rm -r ~/.mozilla
#/bin/cp -a ~/mozilla ~/.mozilla

/bin/rm -r /media/data/root/.mozilla
/bin/cp -a ~/mozilla /media/data/root/.mozilla

# Display sleep after 65s
/usr/bin/xset -display :0 s 65

#Hide the mouse
/usr/bin/unclutter -idle 0.1 -root &

matchbox-window-manager &
  
#If I start iceweasel from cmd line instead of here it will use the full screen available.
/usr/bin/iceweasel easydoor/index.php &
#/usr/bin/iceweasel localhost/index.php &
#/usr/bin/iceweasel localhost/test.php -fullscreen &
#/usr/bin/iceweasel localhost:50001 -fullscreen &

/bin/sleep 365d

exit 0

If you reboot your raspberry pi you may see that it displays the following errors:

'Evdev Axes Swap' doesn't exist, you need to specify its type and format
'Evdev Axis Inversion' doesn't exist, you need to specify its type and format

This happens because raspbian Stretch uses libinput as it's mouse drivers instead of the evdev. To solve this, uninstall linunput and replace it by evdev drivers.

# apt install --no-install-recommends xserver-xorg-input-evdev
# apt remove xserver-xorg-input-libinput

Reference: https://raspberrypi.stackexchange.com/a/79049

Firefox setup

# cp -pr ~/.mozilla /media/data/root/.mozilla
# mv /root/.mozilla /root/mozilla
# ln -s /media/data/root/.mozilla /root/.mozilla

Make sure you have the following intructions in your .xinitrc.

# vi ~/.xinitrc
/bin/rm -r /media/data/root/.mozilla
/bin/cp -a ~/mozilla /media/data/root/.mozilla
# mv /root/.cache /media/data/root/
# ln -s /media/data/root/.cache /root/.cache

Crontab

acdsn

# m h  dom mon dow   command

*/6 * * * * acdsn /bin/bash /home/acdsn/git/easydoor-scripts/minicentral/intercom/sync/sync.sh -t 30 -p fHQQgXvMrWPLgdTXU -mC >/dev/null 2>&1
*/5 * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 22 -r 3800 >/dev/null 2>&1
*/4 * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 1081 -r 3277 >/dev/null 2>&1
*/3 * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 1091 -r 3271 >/dev/null 2>&1

#* * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 5666 -r 3272 >/dev/null 2>&1
#* * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 20514 -r 10514 -f L >/dev/null 2>&1
# mkdir /etc/acdsn
# mkdir -p/media/data/etc/acdsn/conf.d/
# ln -s /media/data/etc/acdsn/conf.d/ /etc/acdsn/conf.d
# chown -R acdsn:acdsn /etc/acdsn/conf.d
$ mkdir -p /etc/acdsn/conf.d/spool
# curl -C - -R -o /tmp/manifest.json -u <port>:<token> --silent https://files.easydoor.co/<port>/manifest.json
# curl -C - -R -o /tmp/style1.css -u <port>:BwtOsnJQUwafmmvSni --silent https://files.easydoor.co/<port>/www/style1.css
I don't know why I had to execute this command in order to execute sync.sh in the crontab
# apt install --no-install-recommends jq

root

# m h  dom mon dow   command
#*/5 * * * * /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server1.bolay.co -l 22 -r  2090
#*/3 * * * * /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server1.bolay.co -l 50001 -r  2097
*/10 * * * * root /bin/bash /home/acdsn/git/acdsn-scripts/reboot.sh -u http://server5.bolay.co/eD/reboot.txt >/dev/null 2>&1 && /bin/bash /home/acdsn/git/acdsn-scripts/network.sh wlan0 > /dev/null 2>&1
@hourly root /bin/bash /home/acdsn/git/acdsn-scripts/reboot.sh -u http://server5.bolay.co/eD/reboot.txt >/dev/null 2>&1
#* * * * * /usr/bin/php /home/acdsn/spool.php >/dev/null 2>&1
#00 06,18 * * * /bin/bash /home/acdsn/git/easydoor-scripts/minicentral/intercom/motion_detection.sh >/dev/null 2>&1

Lighttpd setup

# apt install --no-install-recommends lighttpd

Once you have installed the web server, start it and test if there is any error.

# systemctl start lighttpd.service

Get the raspberry pi ip address and access the web server from a different machine (it could be macOS, windows, linux, etc…).

~ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.28.12.18  netmask 255.255.255.0  broadcast 172.28.12.255
        inet6 fe80::6083:8250:c66f:e0f7  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:d8:dc:72  txqueuelen 1000  (Ethernet)
        RX packets 435  bytes 100953 (98.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 500  bytes 66954 (65.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

PHP installation

First, you need to install PHP-FPM, which is a process manager for PHP.

# apt install --no-install-recommends php7.0-fpm

Then, enable it the typing the following:

# lighttpd-enable-mod fastcgi
# lighttpd-enable-mod fastcgi-php

Now before we can go reloading Lighttpd, we will have to make changes to its configuration. By default, it is configured to work with PHP-CGI and not PHP-FPM, luckily it is easy to make these changes.

Change the content of fastcgi config file to this:

# vi /etc/lighttpd/conf-available/15-fastcgi-php.conf
# -*- depends: fastcgi -*-
# /usr/share/doc/lighttpd/fastcgi.txt.gz
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi

## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
        ((
                "socket" => "/var/run/php/php7.0-fpm.sock",
                "broken-scriptfilename" => "enable"
        ))
)

Restart lighttpd to apply the modifications.

# systemctl restart httpd.service

To test the PHP installation, create an index.php file in /var/www/html.

# vi /var/www/html/index.php
<?php
  phpinfo();
?>

And again, test it from a local machine.

Now that PHP is setup, it's time to create a virtual host. In lighttpd, all you need to do is to create a file in /etc/lighttpd/conf-available, in our case it will be easydoor.conf.

# vi /etc/lighttpd/conf-available/easydoor.conf
$HTTP["host"] == "easydoor" { #FDQN
	server.document-root = "/home/acdsn/git/easydoor-scripts/minicentral/intercom/www/html"
}

Don't forget to add easydoor to your hosts file.

# vi /etc/hosts
127.0.0.1	easydoor

Since /var/log is mounted in tmpfs and apache stores its log in /var/log/apache2, apache won't start. Solve this by telling to systemd that it must create that directory at startup.

# vi /etc/tmpfiles.d/apache2.conf
d /var/log/apache2 0750 root root

Reference: https://pimylifeup.com/raspberry-pi-lighttpd/

Strike

Crontab

acdsn

# m h  dom mon dow   command
@reboot acdsn /bin/bash /home/acdsn/git/easydoor-scripts/minicentral/strike/listen.sh >/dev/null 2>&1

* * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 22 -r 3810 > /tmp/cron.log 2>&1
* * * * * acdsn /bin/bash /home/acdsn/git/acdsn-scripts/connect.acdsn.sh -u acdsn -t server5.bolay.co -l 1091 -r 3291 > /tmp/cron.log 2>&1

Fix backlight missing directory

# mkdir /var/lib/systemd/backlight

# vi /etc/tmpfiles.d/backlightDir.conf
d /var/lib/systemd/backlight 0755 root root
operating_systems/raspbian/easydoor_configuration.1562836546.txt.gz · Last modified: 2019/07/11 09:15 by maferreira