-
Notifications
You must be signed in to change notification settings - Fork 63
/
setup_browser_over_server.sh
executable file
·133 lines (125 loc) · 4.24 KB
/
setup_browser_over_server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# This is an installer script for MagicMirror2. It works well enough
# that it can detect if you have Node installed, run a binary script
# and then download and run MagicMirror2.
if [ $USER == 'root' ]; then
echo Please login as a user to execute the MagicMirror installation, not root
exit 1
fi
cd $HOME
# set default log location
logdir=$HOME
mm_folder=MagicMirror
mm_script=$HOME/$mm_folder/installers/mm.sh
mac=$(uname -s)
if [ 0 -eq 1 ]; then
if [ "$0" == "bash" ]; then
logdir=.
else
if [ $mac == 'Darwin' ]; then
echo this is a mac >> $logfile
logdir=$(dirname "$0")
else
# put the log where the script is located
logdir=$(dirname $(readlink -f "$0"))
fi
fi
# if the script was execute from the web
if [[ $logdir != *"MagicMirror/installers"* ]]; then
# use the MagicMirror/installers folder, if setup
if [ -d ~/mm_folder ]; then
if [ ! -d $HOME/$mm_folder/installers ]; then
mkdir $HOME/$mm_folder/installers 2>/dev/null
fi
cd $HOME/$mm_folder/installers >/dev/null
logdir=$(pwd)
cd - >/dev/null
else
# use the users home folder if initial install
logdir=$HOME
fi
fi
fi
logfile=$logdir/browser_over_server.log
echo install log being saved to $logfile
# Determine which Pi is running.
date +"browser over server setup starting - %a %b %e %H:%M:%S %Z %Y" >>$logfile
cd $HOME/MagicMirror
curl -sL https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/run-start.sh >run-start.sh
chmod +x run-start.sh
sed '/start/ c \ "start\"\:\"./run-start.sh $1\",' < package.json >new_package.json
if [ -s new_package.json ]; then
cp new_package.json package.json
rm new_package.json
echo "package.json update for browser over server, completed ok" >>$logfile
else
echo "package.json update for browser over server failed " >>$logfile
fi
echo which browser would you like to use
echo 1 chrome
echo 2 firefox
echo 3 midori
echo 4 surf
read choice
choice="${choice:-1}"
case $choice in
1) echo selected chrome browser
if [ "$(which chromium-browser)." != "." -o "$(which chrome)." != "." ]; then
echo chrome already installed | tee -a $logfile
else
sudo apt install chromium-browser -y
echo chrome installed | tee -a $logfile
fi
if [ $(grep external_browser $mm_script | wc -l) -eq 0 ]; then
sed -i '/npm start/i export external_browser=chromium-browser' $mm_script
else
#sed -i '/npm start/i export external_browser=chromium-browser' $mm_script
sed -i "/export external_browser=.*/c\export external_browser=chromium-browser" $mm_script
fi
;;
2) echo selected firefox browser
if [ "$(which firefox)." != "." ]; then
echo firefox already installed | tee -a $logfile
else
sudo apt install firefox -y
echo firefox installed | tee -a $logfile
fi
if [ $(grep external_browser $mm_script | wc -l) -eq 0 ]; then
sed -i '/npm start/i export external_browser=firefox' $mm_script
else
#sed -i '/npm start/i export external_browser=chromium-browser' $mm_script
sed -i "/export external_browser=.*/c\export external_browser=firefox" $mm_script
fi
;;
3) echo selected midori browser
if [ "$(which midori)." != "." ]; then
echo midori already installed | tee -a $logfile
else
sudo apt install midori -y
echo midori installed | tee -a $logfile
fi
if [ $(grep external_browser $mm_script | wc -l) -eq 0 ]; then
sed -i '/npm start/i export external_browser=midori' $mm_script
else
#sed -i '/npm start/i export external_browser=chromium-browser' $mm_script
sed -i "/export external_browser=.*/c\export external_browser=midori" $mm_script
fi
;;
4) echo selected surf browser
if [ "$(which surf)." != "." ]; then
echo surf already installed | tee -a $logfile
else
sudo apt install surf -y
echo surf installed | tee -a $logfile
fi
if [ $(grep external_browser $mm_script | wc -l) -eq 0 ]; then
sed -i '/npm start/i export external_browser=surf' $mm_script
else
#sed -i '/npm start/i export external_browser=chromium-browser' $mm_script
sed -i "/export external_browser=.*/c\export external_browser=surf" $mm_script
fi
;;
*) echo unknown selection $choice
;;
esac
date +"browser over server setup ending - %a %b %e %H:%M:%S %Z %Y" >>$logfile