Merge pull request #1788 from sdetweil/newservermode

New servermode
This commit is contained in:
Michael Teeuw 2019-10-25 14:24:05 +02:00 committed by GitHub
commit fcdc84a12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 4 deletions

View File

@ -3,6 +3,9 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## Updated
- improve handling for armv6l devices, where electron support has gone away, add optional serveronly config option
---
❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² core.

View File

@ -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",

View File

@ -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,6 +55,9 @@
"stylelint-config-standard": "latest",
"time-grunt": "latest"
},
"optionalDependencies": {
"electron": "^3.0.13"
},
"dependencies": {
"colors": "^1.1.2",
"console-stamp": "^0.2.9",

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

@ -1,7 +1,62 @@
#!/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}"
# check for xwindows running
xorg=$(pgrep Xorg)
#
# if the user requested serveronly OR
# electron support for armv6l has been dropped OR
# system is in text mode
#
if [ "$serveronly." != "false." -o "$arch" == "armv6l" -o "$xorg." == "." ]; then
# if user explicitly configured to run server only (no ui local)
# OR there is no xwindows running, so no support for browser graphics
if [ "$serveronly." == "true." -o "$xorg." == "." ]; 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