-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure-sonostreamer
executable file
·111 lines (91 loc) · 3.3 KB
/
configure-sonostreamer
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
#!/bin/bash
# This script configures the SonoConnect Streambox environment on the Raspberry Pi platform
# Licence: GPLv3
# Author: Elias Jaffa (@jaffa_md)
echo "Beginning configuration........."
# Update packages and install initial networking dependencies
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install hostapd dnsmasq -y
# hostapd service needs to be unmasked before it will work (new issue with Buster)
sudo systemctl unmask hostapd
# Disable services to prevent them from automatically starting on boot (script below will control these)
sudo systemctl disable hostapd
sudo systemctl disable dnsmasq
# Populate `/etc/hostapd/hostapd.conf`
# This defines the specific settings of the access point, including name, password, security, WiFi channel, etc
sudo bash -c 'cat > /etc/hostapd/hostapd.conf' << EOF
interface=wlan0
driver=nl80211
ssid=POCUS-Pi
hw_mode=g
channel=8
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=pocuspi01
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP
rsn_pairwise=CCMP
country_code=US
ieee80211n=1
ieee80211d=1
EOF
# Populate `/etc/default/hostapd`
sudo bash -c 'cat > /etc/default/hostapd' << EOF
DAEMON_CONF="/etc/hostapd/hostapd.conf"
EOF
# Populate `/etc/dnsmasq.conf`
# This allows the Pi to act as a router and hand out local IP addresses
sudo bash -c 'cat > /etc/dnsmasq.conf' << EOF
interface=wlan0
bind-dynamic
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.50.150,192.168.50.200,12h
EOF
# Enable port forwarding (just on the off chance you want to connect an ethernet cable)
sudo echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
# Prevent the dhcpcd service from starting the wifi network (the script will take care of this)
sudo echo "nohook wpa_supplicant" >> /etc/dhcpcd.conf
# Create service to automatically run the autohotspot script on boot
sudo bash -c 'cat > /etc/systemd/system/autohotspot.service' << EOF
[Unit]
Description=Automatic hotspot (generate local hotspot when not connected to wifi)
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/autohotspot
[Install]
WantedBy=multi-user.target
EOF
# Enable the newly created service
sudo systemctl enable autohotspot.service
# Move autohotspot script to the proper location
sudo mv ./autohotspot /bin/autohotspot
echo "Network configuration complete"
echo "Installing additional dependencies.........."
# Install NodeJS (from NodeSource for the latest version)
# First, update apt repo to include the NodeSource packages
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
# Now you can actually install the latest version of NodeJS (don't forget to install ffmpeg too)
sudo apt-get install nodejs ffmpeg -y
# Uncomment the next line if installing on Raspberry Pi Zero W
#sudo apt-get install npm -y
sudo npm install pm2 -g
sudo pm2 startup
# Change file permissions for important files
sudo chmod ugo+rw /etc/wpa_supplicant/wpa_supplicant.conf
# Give the webpage access to the video device
sudo usermod www-data -aG video
# Give the webpage access to the video device
sudo chmod ugo+rw /dev/video0
# Install the dependencies from the NPM package and start the script running
npm install
sudo npm start
# Save the PM2 dump so that the web app will start when the Pi boots
sudo pm2 save
echo "System configuration complete. Please reboot your Pi now....."