Digital Signage/Displays: Difference between revisions

Jump to navigation Jump to search
m
 
(21 intermediate revisions by the same user not shown)
Line 3: Line 3:
= Prerequisites =
= Prerequisites =
You will need a few prerequisites before this will work:
You will need a few prerequisites before this will work:
* A TV/Monitor (preferable mounted) to display content
* A TV/Monitor (preferably mounted) to display content
* A RaspberryPi or similar SBC (I've also used LibreComputer LePotato SBC running Armbian)
* A RaspberryPi or similar SBC (I've also used LibreComputer LePotato SBC running Armbian)
* A webserver to serve up the content you want to show (preferable external)
* A webserver to serve up the content you want to show (preferably external to the SBC)
=== Simple Display 1 ===
=== Basic Display===
This is the most basic configuration you can use to turn a RaspberryPi/SBC into a digital sign/display that serves up a web page when started.
This is the most basic configuration you can use to turn a RaspberryPi/SBC into a digital sign/display that serves up a web page when started.
==== Software ====
==== Software ====
Line 20: Line 20:
Do the following to setup the device to display the URL of your choice.
Do the following to setup the device to display the URL of your choice.
===== /etc/xdg/openbox/autostart =====
===== /etc/xdg/openbox/autostart =====
Add the following to this file:
Replace the contents of this file with the following:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
# Disable any form of screen saver / screen blanking / power management
# Disable any form of screen saver / screen blanking / power management
Line 53: Line 53:
#chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.50 $URL
#chromium --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.50 $URL
</syntaxhighlight>
</syntaxhighlight>
===== Add kiosk user =====
===== Add kiosk user =====
We will add a user called kiosk that will autologin and display the web page we defined in the script above.  
We will add a user called kiosk that will autologin and display the web page we defined in the script above.  
Line 61: Line 62:
</syntaxhighlight>
</syntaxhighlight>
===== Turn on autologin =====
===== Turn on autologin =====
1. Create the required directory with '''''mkdir /etc/systemd/system/getty@tty1.service.d'''''
1. Create the required directory with:
<syntaxhighlight lang="bash">
mkdir /etc/systemd/system/getty@tty1.service.d
</syntaxhighlight>


2. Create the '''''autologin.conf''''' file in /etc/systemd/system/getty@tty1.service.d and add the contents below.
2. Create the '''''autologin.conf''''' file in the newly created '''''/etc/systemd/system/getty@tty1.service.d''''' directory and add the contents below.


Note:  Change '''''kiosk''''' below to the username that will be used for autologin if you are using something different (root is not recommended)
Note:  Change '''''kiosk''''' below to the username that will be used for autologin if you are using something different (root is not recommended)
Line 78: Line 82:
</syntaxhighlight>
</syntaxhighlight>


Ensure this is enabled with '''''systemctl status getty@tty1''''':
Ensure this is enabled with:
<syntaxhighlight lang="bash">
systemctl status getty@tty1
</syntaxhighlight>


<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
Line 94: Line 101:
             └─776 /sbin/agetty -o "-p -- \\u" --noclear - linux
             └─776 /sbin/agetty -o "-p -- \\u" --noclear - linux
</syntaxhighlight>
</syntaxhighlight>
Run the following command if the service isn't enabled:
<syntaxhighlight lang="bash">
systemctl enable getty@tty1
</syntaxhighlight>
===== Set kiosk user .profile =====
===== Set kiosk user .profile =====
Change /home/kiosk/.profile to the contents below:
Change '''''/home/kiosk/.profile''''' to the contents below:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 145: Line 158:
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
</syntaxhighlight>
</syntaxhighlight>
==== First Time Startup ====
==== First Time Startup ====
Now restart the SBC and it should automatically login as your kiosk user and stop at the command prompt.
Now restart the SBC and it should automatically login as your kiosk user and stop at the command prompt.
===== Additional Configuration =====
===== Additional Configuration =====
If you need to do additional configuration for Chromium (install an autorefresh or other extension(s), change screen size, etc). then start the browser with
If you need to do additional configuration for Chromium (install an autorefresh or other extension(s), change screen size, etc). then start the browser with:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
startx
startx
</syntaxhighlight>
</syntaxhighlight>
This will start the Chromium browser showing the address bar and menu where you can make the necessary adjustments.  Once finished, press '''''CTRl+ALT+BACKSPACE''''' to exit X back to the command line.
This will start the Chromium browser displaying the URL you specified and showing the address bar and menu where you can make the necessary adjustments.  Once finished, press '''''CTRL+ALT+BACKSPACE''''' to exit back to the command line.


===== Finalize Configuration =====
===== Finalize Configuration =====
Line 160: Line 174:


The SBC will boot up and launch Chromium to show the web page you specified.
The SBC will boot up and launch Chromium to show the web page you specified.
=== Display with Remote Management===
This builds off the Display 1 setup with some additional features:
* VNC using NOVNC.  This allows remote control of the display via a web browser.
* Loading message and time displayed.  This uses OSDSH for the overlay.
==== Software ====
Install the following additional packages:
* osdsh
* novnc
* python3-websockify
* python3-numpy
* tigervnc-scraping-server
* tigervnc-standalone-server
* tightvncpasswd
* tightvncserver
* tigervnc-tools
==== Setup ====
Make the following changes
===== /etc/xdg/openbox/autostart =====
Replace the contents of this file with the following:
Note: change '''''<URL TO VISIT>''''' to webserver URL you want to display.
<syntaxhighlight lang="bash">
#
# These things are run when an Openbox X Session is started.
# You may place a similar script in $HOME/.config/openbox/autostart
# to run user-specific things.
#
# If you want to use GNOME config tools...
#
#if test -x /usr/lib/aarch64-linux-gnu/gnome-settings-daemon >/dev/null; then
#  /usr/lib/aarch64-linux-gnu/gnome-settings-daemon &
#elif which gnome-settings-daemon >/dev/null 2>&1; then
#  gnome-settings-daemon &
#fi
# If you want to use XFCE config tools...
#
#xfce-mcs-manager &
#Start x0vncserver and serve up VNC on port localhost:5900
/usr/bin/x0vncserver -passwordfile /home/kiosk/.vnc/passwd -display :0
# If you want to use XFCE config tools...
#
#xfce-mcs-manager &
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
xset -dpms
# Allow quitting the X server with CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp
#Start websockify to proxy novnc to port 6080 using self-signed SSL cert and vnc on localhost:5900
/usr/bin/websockify -D --web=/usr/share/novnc/ --cert=/home/kiosk/novnc.pem --ssl-only 6080 localhost:5900
#Start OSDSH
/usr/bin/osdsh -p 1 -a 1 -n 20 -c blue
chromium-browser --disable-infobars --kiosk --noerrdialogs --enable-features=OverlayScrollbar --disable-restore-session-state --force-device-scale-factor=1.25 '<URL TO VISIT>' &
#Display to give a 15 second delay for initial page loading/rendering
/usr/bin/osdctl -e "dset(f,helvetica)"
/usr/bin/osdctl -e "dset(C,dark red)"
dload="DISPLAY LOADING - ONE MOMENT"
for LSET in 10 20 30 40 50 60 70 80 90
do
  /usr/bin/osdctl -b "$dload,$LSET"
  sleep 2
done
/usr/bin/osdctl -b "LOADING DONE,100"
sleep 5
#Set default color to cyan
/usr/bin/osdctl -e "dset(C,cyan)"
#Set clock to bottom of screen
/usr/bin/osdctl -e "sclk(b)"
#Set clock to center of screen
/usr/bin/osdctl -e "sclk(c)"
#set clock color to blue
/usr/bin/osdctl -e "sclk(C,blue)"
#Set clock font to courier new
/usr/bin/osdctl -e "sclk(f,courier new)"
#Set clock format
/usr/bin/osdctl -e "clkf(%a %b %d %Y - %l : %M : %S %p)"
sleep 1
#Run clock indefinitely
/usr/bin/osdctl -c 1
#Loop to pause then press F5 in chromium for page refresh
while true; do
    sleep 90
    osdctl -s "Screen will refresh in 5 seconds"
    sleep 5
    xdotool key F5
done
</syntaxhighlight>
===== Generate SSL certificate =====
* Navigate to the '''''/home/kiosk''''' user directory
* Run the following command to generate a self-signed SSL certificate with a 10 year life span:
<syntaxhighlight lang="bash">
openssl req -x509 -nodes -newkey rsa:3072 -keyout novnc.pem -out novnc.pem -days 3650
</syntaxhighlight>
===== Generate VNC Password File =====
Run the following command to create the vnc password file (make note of this for later):
<syntaxhighlight lang="bash">
vncpasswd
</syntaxhighlight>
===== Firewall =====
Edit (or create) the '''''/etc/rc.local''''' file and add/replace the contents with the following:
<syntaxhighlight lang="bash">
#!/bin/bash
#Firewall rules to block VNC to all but localhost for NOVNC access
iptables -F log-and-drop
iptables -X log-and-drop
iptables -N log-and-drop
# Specific chain used for logging packets before blocking them
iptables -A log-and-drop -j LOG --log-prefix "[IPTables] Drop "
iptables -A log-and-drop -j DROP
iptables -A INPUT -p tcp --dport 5900 -j ACCEPT --src localhost
iptables -A INPUT -p udp --dport 5900 -j ACCEPT --src localhost
iptables -A INPUT -p tcp --dport 5900 -j log-and-drop
iptables -A INPUT -p udp --dport 5900 -j log-and-drop
</syntaxhighlight>
* Enable systemd service to run rc.local at start
<syntaxhighlight lang="bash">
systemctl enable rc-local
</syntaxhighlight>
* Make script executable
<syntaxhighlight lang="bash">
chmod a+x /etc/rc.local
</syntaxhighlight>
==== First Time Startup ====
Restart the SBC to make sure it will boot up and start Chromium.
==== Remote Access via NOVNC ====
You can manage the device by pointing a web browser at '''''https://<device IP>:6080'''''
* When prompted accept the invalid certificate
* Login to NOVNC using the password you created using vncpasswd
= Miscellaneous =
Sometimes things happen and the display will "get stuck" or lose internet connectivity.  When this happens you have a few options:
# Setup a nightly reboot event via crontab or systemd timers
# Setup a watchdog to look for lost network connectivity and restart the system

Navigation menu