2019-10-24 09:20:33 -05:00
|
|
|
#!/bin/bash
|
|
|
|
# use bash instead of sh
|
2019-07-26 01:19:44 -04:00
|
|
|
./untrack-css.sh
|
|
|
|
|
2017-01-24 02:12:36 -03:00
|
|
|
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
|
2017-11-26 10:02:31 +01:00
|
|
|
export DISPLAY=:0 # Set by default display
|
2017-01-24 02:12:36 -03:00
|
|
|
fi
|
2019-10-24 09:20:33 -05:00
|
|
|
# get the processor architecture
|
|
|
|
arch=$(uname -m)
|
2019-11-22 06:18:04 -06:00
|
|
|
false='false'
|
2019-12-10 08:29:18 -06:00
|
|
|
|
2019-11-22 06:18:04 -06:00
|
|
|
# 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 ,\"\')
|
2019-10-24 09:20:33 -05:00
|
|
|
# set default if not defined in config
|
2019-11-22 06:18:04 -06:00
|
|
|
serveronly=${serveronly:-false}
|
2019-10-25 06:22:10 -05:00
|
|
|
# check for xwindows running
|
|
|
|
xorg=$(pgrep Xorg)
|
2019-10-27 09:13:44 -05:00
|
|
|
#check for macOS
|
|
|
|
mac=$(uname)
|
2019-10-24 09:20:33 -05:00
|
|
|
#
|
|
|
|
# if the user requested serveronly OR
|
2019-10-25 06:22:10 -05:00
|
|
|
# electron support for armv6l has been dropped OR
|
|
|
|
# system is in text mode
|
2019-10-24 09:20:33 -05:00
|
|
|
#
|
2019-10-27 09:13:44 -05:00
|
|
|
if [ "$serveronly." != "false." -o "$arch" == "armv6l" ] || [ "$xorg." == "." -a $mac != 'Darwin' ]; then
|
2019-12-10 08:29:18 -06:00
|
|
|
|
2019-10-24 09:20:33 -05:00
|
|
|
# if user explicitly configured to run server only (no ui local)
|
2019-10-25 06:22:10 -05:00
|
|
|
# OR there is no xwindows running, so no support for browser graphics
|
|
|
|
if [ "$serveronly." == "true." -o "$xorg." == "." ]; then
|
2019-10-24 09:20:33 -05:00
|
|
|
# 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
|
2019-11-22 06:18:04 -06:00
|
|
|
electron js/electron.js $1;
|
|
|
|
fi
|