From e958f33450cc5129e231c66ec9a9f4e50058f4a9 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Thu, 24 Oct 2019 09:20:33 -0500 Subject: [PATCH] add support for armv6l using serveronlymode, make serveronly config option, electron install optional --- config/config.js.sample | 7 +++++- package.json | 6 +++-- run-start.sh | 55 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 5 deletions(-) mode change 100644 => 100755 run-start.sh diff --git a/config/config.js.sample b/config/config.js.sample index 790ada34..0e5ff840 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -24,7 +24,12 @@ var config = { language: "en", timeFormat: 24, units: "metric", - + // serverOnly: true/false/"local" , + // local for armv6l processors, default + // starts serveronly and then starts chrome browser + // false, default for all NON-armv6l devices + // true, force serveronly mode, because you want to.. no UI on this device + modules: [ { module: "alert", diff --git a/package.json b/package.json index 4685bbd0..643f48e0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "The open source modular smart mirror platform.", "main": "js/electron.js", "scripts": { - "start": "sh run-start.sh", + "start": "./run-start.sh", "install": "cd vendor && npm install", "install-fonts": "cd fonts && npm install", "postinstall": "sh untrack-css.sh && sh installers/postinstall/postinstall.sh && npm run install-fonts", @@ -55,9 +55,11 @@ "stylelint-config-standard": "latest", "time-grunt": "latest" }, + "optionalDependencies": { + "electron": "^3.0.13" + }, "dependencies": { "colors": "^1.1.2", - "electron": "^3.0.13", "express": "^4.16.2", "express-ipfilter": "^1.0.1", "feedme": "latest", diff --git a/run-start.sh b/run-start.sh old mode 100644 new mode 100755 index bbfcf921..0d83e7bd --- a/run-start.sh +++ b/run-start.sh @@ -1,7 +1,58 @@ - +#!/bin/bash + # use bash instead of sh ./untrack-css.sh if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty export DISPLAY=:0 # Set by default display fi -electron js/electron.js $1 +# get the processor architecture +arch=$(uname -m) +# got the config option, if any +serveronly=$(grep -i serveronly: config/config.js | awk '{print tolower($2)}' | tr -d ,\"\') +# set default if not defined in config +serveronly="${serveronly:=false}" +# +# if the user requested serveronly OR +# electron support for armv6l has been dropped +# +if [ "$serveronly." != "false." -o "$arch" == "armv6l" ]; then + + # if user explicitly configured to run server only (no ui local) + if [ "$serveronly." == "true." ]; then + # start server mode, + node serveronly + else + # start the server in the background + # wait for server to be ready + # need bash for this + exec 3< <(node serveronly) + + # Read the output of server line by line until one line 'point your browser' + while read line; do + case "$line" in + *point\ your\ browser*) + echo $line + break + ;; + *) + echo $line + #sleep .25 + ;; + esac + done <&3 + + # Close the file descriptor + exec 3<&- + + # lets use chrome to display here now + # get the server port address from the ready message + port=$(echo $line | awk -F\: '{print $4}') + # start chromium + echo "Starting chromium browser now, have patience, it takes a minute" + chromium-browser -noerrdialogs -kiosk -start_maximized --disable-infobars --app=http://localhost:$port --ignore-certificate-errors-spki-list --ignore-ssl-errors --ignore-certificate-errors 2>/dev/null + exit + fi +else + # we can use electron directly + `electron js/electron.js $1`; +fi \ No newline at end of file