From 09c1ea992c669cad3fe24eeb7fd328fc0d526906 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Sat, 1 Feb 2020 13:56:15 +0100 Subject: [PATCH] Update start methods. --- CHANGELOG.md | 3 ++ js/app.js | 6 +++- package.json | 3 +- run-start.sh | 75 -------------------------------------------------- untrack-css.sh | 11 -------- 5 files changed, 10 insertions(+), 88 deletions(-) delete mode 100755 run-start.sh delete mode 100755 untrack-css.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 53441236..a97536ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/js/app.js b/js/app.js index 3c7a51f8..920d0c49 100644 --- a/js/app.js +++ b/js/app.js @@ -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; } diff --git a/package.json b/package.json index 42baf1da..31490b5f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/run-start.sh b/run-start.sh deleted file mode 100755 index f4c2d4e3..00000000 --- a/run-start.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/untrack-css.sh b/untrack-css.sh deleted file mode 100755 index d5969b84..00000000 --- a/untrack-css.sh +++ /dev/null @@ -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 -