-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstallMagicMirrorWithModules.sh
More file actions
executable file
·110 lines (80 loc) · 3.33 KB
/
InstallMagicMirrorWithModules.sh
File metadata and controls
executable file
·110 lines (80 loc) · 3.33 KB
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
#!/bin/bash
# Get user input to install autostart function
while true; do
read -p "Do you want the MagicMirror to autostart after a reboot? (y/n) " yn
function InstallMagicMirror {
# Installing nodejs and npm and cleanup
sudo apt update -y
sudo apt install nodejs -y && sudo apt install npm -y
sudo apt autoremove -y
# Installing MagicMirror
cd .. && curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
git clone https://github.com/MichMich/MagicMirror
echo "CD and npm install"
cd "$(dirname "$0")/MagicMirror" && npm install --only=prod --omit=dev && npm audit fix --force
npm install postman-request
echo "Copy config sample"
cp "config/config.js.sample" "config/config.js"
cd "$(dirname "$0")/modules" && git clone https://github.com/YR/MMM-YrNow
# The author has not fixed two errors (request module depricated and incorrect url) Lets fix it
sed -i 's/request/postman-request/2' "$(dirname "$0")/MMM-YrNow/node_helper.js"
sed -i 's/\/id//1' "$(dirname "$0")/MMM-YrNow/MMM-YrNow.js"
# Install MMM-Worldclock
git clone https://github.com/BKeyport/MMM-Worldclock
# Install MMM-PostDelivery-Norway
git clone https://github.com/reidarw/MMM-PostDelivery-Norway.git
# The author has not fixed one error (request module depricated)
sed -i 's/request/postman-request/2' "$(dirname "$0")/MMM-PostDelivery-Norway/node_helper.js"
# Install MMM-TRV-WastePlan
git clone https://github.com/reidarw/MMM-TRV-WastePlan.git
# The author has not fixed one error (request module depricated)
sed -i 's/request/postman-request/2' "$(dirname "$0")/MMM-TRV-WastePlan/node_helper.js"
# Install MMM-Entur-tavle
git clone https://github.com/Arve/MMM-Entur-tavle.git
# Install MMM-Tibber
git clone https://github.com/ottopaulsen/MMM-Tibber
cd "$(dirname "$0")/MMM-Tibber" && npm install && npm audit fix --force
# Back to modules install MMM-Tools
cd ..
git clone https://github.com/bugsounet/MMM-Tools
cd "$(dirname "$0")/MMM-Tools" && npm install && npm audit fix --force
# Back to modules install
cd ..
# Go parent directory where the script is
cd ..
# Go out of the script directory
cd ..
# Copy the config file
cp "$(dirname "$0")/AutomatedMagicMirrorInstallation/config.js" "$(dirname "$0")/MagicMirror/config/config.js"
}
case $yn in
[yY] )
# If user wants to start at reboot
# Call install function
InstallMagicMirror
# Starting MagicMirror
echo "Start MagicMirror with autostart..."
cd "$(dirname "$0")/MagicMirror"
#sed -i 's/~\/MagicMirror/../1' "$(dirname "$0")/installers/mm.sh"
# Install pm2
sudo npm install -g pm2
sudo pm2 startup
# Downloaded / Cloned folder
cd ..
# Copy the bash file
cp "$(dirname "$0")/AutomatedMagicMirrorInstallation/mm.sh" "$(dirname "$0")/mm.sh"
# https://docs.magicmirror.builders/configuration/autostart.html#using-pm2
pm2 start mm.sh
pm2 save --force
break;;
[nN] )
# Call install function
InstallMagicMirror
# Starting MagicMirror
echo "Starting MagicMirror..."
cd "$(dirname "$0")/MagicMirror"
npm run start;
exit;;
* ) echo invalid response;;
esac
done