add support for armv6l using serveronlymode, make serveronly config option, electron install optional

This commit is contained in:
Sam Detweiler 2019-10-24 09:20:33 -05:00
parent 937080b011
commit e958f33450
3 changed files with 63 additions and 5 deletions

View File

@ -24,6 +24,11 @@ var config = {
language: "en", language: "en",
timeFormat: 24, timeFormat: 24,
units: "metric", 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: [ modules: [
{ {

View File

@ -4,7 +4,7 @@
"description": "The open source modular smart mirror platform.", "description": "The open source modular smart mirror platform.",
"main": "js/electron.js", "main": "js/electron.js",
"scripts": { "scripts": {
"start": "sh run-start.sh", "start": "./run-start.sh",
"install": "cd vendor && npm install", "install": "cd vendor && npm install",
"install-fonts": "cd fonts && npm install", "install-fonts": "cd fonts && npm install",
"postinstall": "sh untrack-css.sh && sh installers/postinstall/postinstall.sh && npm run install-fonts", "postinstall": "sh untrack-css.sh && sh installers/postinstall/postinstall.sh && npm run install-fonts",
@ -55,9 +55,11 @@
"stylelint-config-standard": "latest", "stylelint-config-standard": "latest",
"time-grunt": "latest" "time-grunt": "latest"
}, },
"optionalDependencies": {
"electron": "^3.0.13"
},
"dependencies": { "dependencies": {
"colors": "^1.1.2", "colors": "^1.1.2",
"electron": "^3.0.13",
"express": "^4.16.2", "express": "^4.16.2",
"express-ipfilter": "^1.0.1", "express-ipfilter": "^1.0.1",
"feedme": "latest", "feedme": "latest",

55
run-start.sh Normal file → Executable file
View File

@ -1,7 +1,58 @@
#!/bin/bash
# use bash instead of sh
./untrack-css.sh ./untrack-css.sh
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display export DISPLAY=:0 # Set by default display
fi 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