-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
176 lines (154 loc) · 5.28 KB
/
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
apt-get update
apt-get upgrade -y && sudo apt-get install hostapd dnsmasq build-essential git -y
systemctl stop NetworkManager && systemctl disable NetworkManager
cat > /etc/network/interfaces << EOF
#----- lan interface ( standard maintenance connection via ssh )
allow-hotplug eth0
iface eth0 inet dhcp
#----- RockPI onboard ( access defined in /etc/hostapd.conf )
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
#----- LB-Link dongle ( access defined in /etc/wpa_supplicant/wpa_supplicant.conf )
allow-hotplug wlxaca2136650d6
iface wlxaca2136650d6 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
EOF
cat > /etc/wpa_supplicant/wpa_supplicant.conf << EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Flamingo"
psk="KennyBeats24"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
EOF
cat >> /etc/default/hostapd << EOF
DAEMON_CONF="/etc/hostapd/hostapd.conf"
EOF
cat > /etc/hostapd/hostapd.conf << EOF
interface=wlan0
driver=nl80211
ssid=SmartParks
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
cat > /etc/dnsmasq.conf << EOF
# Interface to bind to
interface=wlan0
# Specify starting_range,end_range,lease_time
dhcp-range=10.0.0.3,10.0.0.20,12h
# Uncomment and modify the following lines if you don't want to forward dns from the host's /etc/resolv.conf
## disables dnsmasq reading any other files like /etc/resolv.conf for nameservers
#no-resolv
## dns addresses to send to the clients
#server=8.8.8.8
#server=8.8.4.4
EOF
systemctl start hostapd && systemctl enable hostapd
systemctl start dnsmasq && systemctl enable dnsmasq
cat > /etc/network/interfaces << EOF
#----- lan interface ( standard maintenance connection via ssh )
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
#----- RockPI onboard ( access defined in /etc/hostapd.conf )
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
#----- LB-Link dongle ( access defined in /etc/wpa_supplicant/wpa_supplicant.conf )
allow-hotplug wlxaca2136650d6
iface wlxaca2136650d6 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
EOF
#####Chirpstack installeren#####
apt install mosquitto mosquitto-clients redis-server redis-tools postgresql -y
echo "create role chirpstack_as with login password 'dbpassword';
create role chirpstack_ns with login password 'dbpassword';
create database chirpstack_as with owner chirpstack_as;
create database chirpstack_ns with owner chirpstack_ns;
\c chirpstack_as
create extension pg_trgm;
create extension hstore;
\q" | sudo -u postgres psql
apt install apt-transport-https dirmngr -y
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1CE2AFD36DBCCA00
echo "deb https://artifacts.chirpstack.io/packages/3.x/deb stable main" | sudo tee /etc/apt/sources.list.d/chirpstack.list
apt update
apt install chirpstack-gateway-bridge
systemctl start chirpstack-gateway-bridge
systemctl enable chirpstack-gateway-bridge
apt install chirpstack-network-server
cat > /etc/chirpstack-network-server/chirpstack-network-server.toml << EOF
[general]
log_level=4
[postgresql]
dsn="postgres://chirpstack_ns:dbpassword@localhost/chirpstack_ns?sslmode=disable"
[network_server]
net_id="000000"
[network_server.band]
name="EU_863_870"
[[network_server.network_settings.extra_channels]]
frequency=867100000
min_dr=0
max_dr=5
[[network_server.network_settings.extra_channels]]
frequency=867300000
min_dr=0
max_dr=5
[[network_server.network_settings.extra_channels]]
frequency=867500000
min_dr=0
max_dr=5
[[network_server.network_settings.extra_channels]]
frequency=867700000
min_dr=0
max_dr=5
[[network_server.network_settings.extra_channels]]
frequency=867900000
min_dr=0
max_dr=5
EOF
systemctl start chirpstack-network-server
systemctl enable chirpstack-network-server
# journalctl -f -n 100 -u chirpstack-network-server
apt install chirpstack-application-server
cat > /etc/chirpstack-application-server/chirpstack-application-server.toml << EOF
[general]
log_level=4
[postgresql]
dsn="postgres://chirpstack_as:dbpassword@localhost/chirpstack_as?sslmode=disable"
[application_server.external_api]
jwt_secret="JTopwCWDI9BjEZO5VgCfxm2rjKpNUUjD0RkeSy9/DTs="
EOF
systemctl start chirpstack-application-server
systemctl enable chirpstack-application-server
#journalctl -f -n 100 -u chirpstack-application-server
##### Install InfluxDB and create DB#####
wget -qO- https://repos.influxdata.com/influxdb.key | apt-key add -
echo "deb https://repos.influxdata.com/debian buster stable" | tee /etc/apt/sources.list.d/influxdb.list
apt update && apt install influxdb -y
systemctl unmask influxdb
systemctl start influxdb && systemctl enable influxdb
echo "CREATE USER nodered WITH PASSWORD 'nodered' WITH ALL PRIVILEGES" | influx
echo "CREATE DATABASE SmartParks" | influx
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
systemctl start nodered.service
systemctl enable nodered.service
echo "Script done! sudo reboot to finish setup. Connect to WiFi Smartparks, PI IP = 10.0.0.1"