Update start methods.

This commit is contained in:
Michael Teeuw 2020-02-01 13:56:15 +01:00
parent 3bb801f579
commit 09c1ea992c
5 changed files with 10 additions and 88 deletions

View File

@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Updated config.js.sample: Corrected some grammar on `config.js.sample` comment section.
- Remove `run-start.sh` script and update start commands:
- To start using electron, use `npm run start`.
- To start in server only mode, use `npm run server`.
## [2.11.0] - Unreleased (Develop Branch)

View File

@ -4,7 +4,6 @@
* By Michael Teeuw http://michaelteeuw.nl
* MIT Licensed.
*/
var fs = require("fs");
var Server = require(__dirname + "/server.js");
var Utils = require(__dirname + "/utils.js");
@ -24,6 +23,11 @@ console.log("Starting MagicMirror: v" + global.version);
// global absolute root path
global.root_path = path.resolve(__dirname + "/../");
if (!process.env.DISPLAY) {
console.log("DISPLAY environment variable not set. Using DISPLAY=:0");
process.env.DISPLAY = ":0";
}
if (process.env.MM_CONFIG_FILE) {
global.configuration_file = process.env.MM_CONFIG_FILE;
}

View File

@ -4,7 +4,8 @@
"description": "The open source modular smart mirror platform.",
"main": "js/electron.js",
"scripts": {
"start": "./run-start.sh",
"start": "./node_modules/.bin/electron js/electron.js",
"server": "node ./serveronly",
"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",

View File

@ -1,75 +0,0 @@
#!/bin/bash
# use bash instead of sh
./untrack-css.sh
if grep docker /proc/1/cgroup -qa; then
# if running in docker, only start electron
electron js/electron.js $1;
else
# not running in docker
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display
fi
# get the processor architecture
arch=$(uname -m)
false='false'
# get the config option, if any
# only check non comment lines
serveronly=$(grep -v '^\s//' config/config.js | grep -i serveronly: | awk '{print tolower($2)}' | tr -d ,\"\')
# set default if not defined in config
serveronly=${serveronly:-false}
# check for xwindows running
xorg=$(pgrep Xorg)
#check for macOS
mac=$(uname)
#
# 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" ] || [ "$xorg." == "." -a $mac != 'Darwin' ]; 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
fi

View File

@ -1,11 +0,0 @@
# Long history here
# https://github.com/MichMich/MagicMirror/pull/1540
STATUS_CUSTOM_CSS=$(git ls-files -v css/custom.css| awk '{print $1}')
if [ "$STATUS_CUSTOM_CSS" = "H" ]; then
echo "We'll remove from the repository the css/custom.css"
echo "This script apply git update-index --skip-worktree css/custom.css"
git update-index --skip-worktree css/custom.css
git rm --cached css/custom.css
fi