-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpi-setup.sh
146 lines (129 loc) · 4.99 KB
/
pi-setup.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
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
# Call me with:
# bash <(curl -sL http://bit.do/lorawan-workshop)
function pause() {
read -p "$* [ENTER TO CONTINUE]"
}
echo "----------------------------------------------";
echo " _ ___ __ __ _ _ _ ";
echo " | | ___ | _ \ __ _\ \ / //_\ | \| | ";
echo " | |__ / _ \| // _\` |\ \/\/ // _ \ | .\` | ";
echo " |____|\___/|_|_\\\__,_| \_/\_//_/ \_\|_|\_| ";
echo " \ \ / /___ _ _ | |__ ___| |_ ___ _ __ ";
echo " \ \/\/ // _ \| '_|| / /(_-<| ' \ / _ \| '_ \\";
echo " \_/\_/ \___/|_| |_\_\/__/|_||_|\___/| .__/";
echo " |_| ";
echo "----------------------------------------------";
echo "Setting up Raspberry Pi for the LoRaWAN workshop"
echo "Sit back, this is going to take a while ..."
if ! uname -a | grep 'aarch64' &>/dev/null; then
echo "Please use a 64-bit RPi image"
exit -1
fi
echo "-------------------------------------------"
echo "Updating the system"
echo "-------------------------------------------"
sudo apt update
sudo apt upgrade -y
echo "-------------------------------------------"
echo "Installing basic dependencies"
echo "-------------------------------------------"
sudo apt -y install git
sudo apt -y install mosquitto
sudo apt -y install build-essential curl
cd
if [ ! -d "lorawan-twin-workshop" ];
then
echo "-------------------------------------------"
echo "Cloning LoRaWAN TWIN Workshop repo"
echo "-------------------------------------------"
git clone https://github.com/99-bugs/lorawan-twin-workshop.git
else
echo "LoRaWAN TWIN Workshop dir already exists."
cd lorawan-twin-workshop
git pull origin master
fi
cd
if [ ! -d "arduino-1.8.19" ];
then
echo "-------------------------------------------"
echo "Downloading arduino IDE portable"
echo "-------------------------------------------"
curl -L -o portable-arduino-1.8.19-linuxaarch64.tar.xz "https://filesender.belnet.be/download.php?token=9118b6de-c395-41e2-a115-83f1c2ca9c4b&files_ids=955787"
tar -xf portable-arduino-1.8.19-linuxaarch64.tar.xz
cd arduino-1.8.19
./install.sh
else
echo "Arduino IDE is already installed. Skipping ...."
fi
## HOW TO CREATE THE ARDUINO PORTABLE FILE?
# # Based on https://www.arduino.cc/en/Guide/PortableIDE
# cd && curl -O "https://downloads.arduino.cc/arduino-1.8.19-linuxaarch64.tar.xz"
# tar -xf arduino-1.8.19-linuxaarch64.tar.xz
# cd arduino-1.8.19
# mkdir portable
# echo "boardsmanager.additional.urls=http://downloads.sodaq.net/package_sodaq_samd_index.json" >> portable/preferences.txt
# # Launch the IDE and install the SODAQ SAMD Board Package. This will take some time.
# # Install some Arduino libraries via Libray Manager
# # Sodaq_wdt v1.0.2
# # Sodaq_RN2483 v1.1.0
# cd && tar -czf portable-arduino-1.8.19-linuxaarch64.tar.xz arduino-1.8.19
cd
if [ ! -d ".node-red" ];
then
echo "-------------------------------------------"
echo "Installing node-RED and packages"
echo "-------------------------------------------"
yes | bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
cd ~/.node-red
npm install node-red-contrib-influxdb
npm install node-red-dashboard
sudo systemctl enable nodered.service
else
echo "node-RED is already installed. Skipping ...."
fi
apt search influxdb2 2>&1 | grep 'installed' &> /dev/null
if [ "$?" -ne 0 ];
then
echo "-------------------------------------------"
echo "Installing InfluxDB"
echo "-------------------------------------------"
curl https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /usr/share/keyrings/influxdb-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/influxdb-archive-keyring.gpg] https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt -y install influxdb2
sudo systemctl unmask influxdb
sudo systemctl enable influxdb
sudo systemctl start influxdb
else
echo "InfluxDB2 is already installed. Skipping ...."
fi
cd
if [ ! -f "Desktop/workshop.desktop" ];
then
touch "Desktop/workshop.desktop"
cat <<EOT > "Desktop/workshop.desktop"
[Desktop Entry]
Encoding=UTF-8
Name=LoRaWAN-Workshop
Type=Link
URL=https://lorawan-workshop.99bugs.be/
Icon=text-html
EOT
else
echo "Shortcut already exists. Skipping ..."
fi
echo "-------------------------------------------"
echo "Done ..."
echo "-------------------------------------------"
echo "----------------------------------------------";
echo " _ ___ __ __ _ _ _ ";
echo " | | ___ | _ \ __ _\ \ / //_\ | \| | ";
echo " | |__ / _ \| // _\` |\ \/\/ // _ \ | .\` | ";
echo " |____|\___/|_|_\\\__,_| \_/\_//_/ \_\|_|\_| ";
echo " \ \ / /___ _ _ | |__ ___| |_ ___ _ __ ";
echo " \ \/\/ // _ \| '_|| / /(_-<| ' \ / _ \| '_ \\";
echo " \_/\_/ \___/|_| |_\_\/__/|_||_|\___/| .__/";
echo " |_| ";
echo "----------------------------------------------";
echo "Done with setup of Raspberry Pi system"