|
| 1 | +#!/bin/bash |
| 2 | +LOG="$(dirname "$SCRIPT_PATH")""/log-run.out" |
| 3 | +LOG_CLIENT="/dev/null" |
| 4 | +echo "$(date +'%Y_%m_%d_%H:%M:%S') - Log file: $LOG" >> "$LOG" |
| 5 | + |
| 6 | +is_headless=0 |
| 7 | + |
| 8 | +# Source and XServer check |
| 9 | +script_source="" |
| 10 | +is_xserver_running=0 |
| 11 | +if [ -n "$1" ]; then |
| 12 | + script_source=$1 |
| 13 | +fi |
| 14 | +if [ "$script_source" = "xserver" ] || [ -n "$DISPLAY" ]; then |
| 15 | + is_xserver_running=1 |
| 16 | +fi |
| 17 | +if [ "$is_xserver_running" -eq "0" ]; then |
| 18 | + if [ "$is_headless" -eq "0" ] || [ "$is_headless" -eq "2" ]; then |
| 19 | + if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then |
| 20 | + # On device call |
| 21 | + echo "Starting X-Server to support display ..." |
| 22 | + echo "$(date +'%Y_%m_%d_%H:%M:%S') - Starting X-Server to support display ..." >> "$LOG" |
| 23 | + startx |
| 24 | + exit |
| 25 | + else |
| 26 | + # Call from SSH terminal |
| 27 | + echo "Cannot start client in display-mode via SSH terminal (no X-Server support)." |
| 28 | + echo "Please use reboot + auto-login or call directly on device." |
| 29 | + echo "$(date +'%Y_%m_%d_%H:%M:%S') - Cannot start client in display-mode via SSH terminal (no X-Server support) - Use reboot + auto-login or call directly on device." >> "$LOG" |
| 30 | + exit |
| 31 | + fi |
| 32 | + fi |
| 33 | +fi |
| 34 | + |
| 35 | +# Start Chromium in kiosk mode |
| 36 | +echo "$(date +'%Y_%m_%d_%H:%M:%S') - Preparing Chromium ..." >> "$LOG" |
| 37 | +client_url="http://localhost:20721/app/index.html" |
| 38 | + |
| 39 | +chromedatadir=~/sepia-client/chromium |
| 40 | +if [ -f "$chromedatadir/Default/Preferences" ]; then |
| 41 | + echo "$(date +'%Y_%m_%d_%H:%M:%S') - Setting default preferences for Chromium (permissions: mic, location, notifications)" >> "$LOG" |
| 42 | + sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' $chromedatadir/'Local State' |
| 43 | + sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' $chromedatadir/Default/Preferences |
| 44 | + sed -i 's/"notifications":{}/"notifications":{"http:\/\/localhost:8080,*":{"last_modified":"13224291659276737","setting":1}}/' $chromedatadir/Default/Preferences |
| 45 | + sed -i 's/"geolocation":{}/"geolocation":{"http:\/\/localhost:8080,http:\/\/localhost:8080":{"last_modified":"13224291716729005","setting":1}}/' $chromedatadir/Default/Preferences |
| 46 | + sed -i 's/"media_stream_mic":{}/"media_stream_mic":{"http:\/\/localhost:8080,*":{"last_modified":"13224291643099497","setting":1}}/' $chromedatadir/Default/Preferences |
| 47 | +else |
| 48 | + echo "$(date +'%Y_%m_%d_%H:%M:%S') - Could not set default preferences for Chromium (yet?) - Please restart client once more and check if 'chromium/Default/Preferences' was created." >> "$LOG" |
| 49 | +fi |
| 50 | + |
| 51 | +default_chrome_flags="--user-data-dir=$chromedatadir --allow-insecure-localhost --autoplay-policy=no-user-gesture-required --disable-infobars --enable-features=OverlayScrollbar --hide-scrollbars --no-default-browser-check --check-for-update-interval=31536000" |
| 52 | +chrome_extensions="--load-extension=~/sepia-client/chromium-extensions/sepia-fw" |
| 53 | + |
| 54 | +echo "Running SEPIA-Client in 'display' mode. Use SEPIA Control-HUB to connect and control via remote terminal, default URL is: $clexi_ws_url" |
| 55 | +chromium $default_chrome_flags $chrome_extensions --kiosk "$client_url?isApp=true&hasTouch=true" >"$LOG_CLIENT" 2>&1 |
0 commit comments