-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpi-config.sh
executable file
·195 lines (180 loc) · 5.37 KB
/
pi-config.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
###########################
# To use:
# chmod +x pi-config.sh
# ./pi-config.sh
###########################
# Functions
function updateRaspbian {
echo ""
echo ""
echo "---------------------------------------------------------"
echo "Setting up your Raspberry Pi"
echo "---------------------------------------------------------"
echo ""
echo ""
echo "Updating Raspbian ..."
echo ""
sudo apt update
sudo apt full-upgrade -y
}
# Vars
doneMessage=""
optionMainMenu=
optionVideoMenu=
optionStandardMenu=
clear
echo ""
echo "---------------------------------------------------------"
echo "BasementMaker Raspberry Pi Configurator"
echo "Version: 1.2.0 - BETA"
echo ""
echo "Warning: This file should only be ran on a Raspberry Pi"
echo "running a recent version of Raspbian. Additionally, this"
echo "script assumes a fresh installation of Raspbian without"
echo "other software installed & that you are running as the"
echo "default pi user."
echo ""
echo "Note: This script has only been tested on Raspberry Pi 3s"
echo "and not yet on Raspberry Pi 4."
echo ""
echo "Website:"
echo "https://github.com/basementmaker/raspberrypi-configurator"
echo "---------------------------------------------------------"
echo ""
echo ""
echo "Your Raspberry Pi Hardware:"
cat /sys/firmware/devicetree/base/model
echo ""
echo ""
echo "Raspbian Version:"
awk -F= '$1=="PRETTY_NAME" { print $2 ;}' /etc/os-release
echo ""
echo ""
echo "Menu:"
echo "1 -> Video Projects"
echo "2 -> Standard Setups"
echo "x -> Exit"
read -p "Choose One: " -n 1 optionMainMenu
if [ $optionMainMenu == "1" ]; then
echo ""
echo ""
echo "Menu:"
echo "1 -> Raspberry Pi - HomeKit Controlled Single Color LED Strip [May 2020]"
echo "2 -> Raspberry Pi - HomeKit Controlled RGB LED Strip (Updated) [May 2020]"
echo "x -> Exit"
read -p "Choose One: " -n 1 optionVideoMenu
elif [ $optionMainMenu == "2" ]; then
echo ""
echo ""
echo "Menu:"
echo "1 -> PiGPIO"
echo "2 -> PiGPIO & Node.js v12"
echo "3 -> PM2 (Requires Node.js)"
echo "x -> Exit"
read -p "Choose One: " -n 1 optionStandardMenu
else
clear
exit 0
fi
#
# Video Setups
#
#
if [ "$optionVideoMenu" == "1" ]; then
updateRaspbian
echo ""
echo "Installing Node.js & PiGPIO ..."
echo ""
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs git build-essential python-setuptools python3-setuptools
wget https://github.com/joan2937/pigpio/archive/master.zip && unzip master.zip && cd pigpio-master && make && sudo make install
cd ..
echo ""
echo "Fetching BasementMaker project code ..."
echo ""
git clone https://github.com/basementmaker/raspberrypi-homekit-led-strip.git
cd raspberrypi-homekit-led-strip
npm install
doneMessage="Type: cd raspberrypi-homekit-led-strip; sudo npm start"
elif [ "$optionVideoMenu" == "2" ]; then
updateRaspbian
echo ""
echo "Installing Node.js & PiGPIO ..."
echo ""
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs git build-essential python-setuptools python3-setuptools
wget https://github.com/joan2937/pigpio/archive/master.zip && unzip master.zip && cd pigpio-master && make && sudo make install
cd ..
echo ""
echo "Fetching BasementMaker project code ..."
echo ""
git clone https://github.com/basementmaker/raspberrypi-homekit-rgb-led-strip.git
cd raspberrypi-homekit-rgb-led-strip
npm install
doneMessage="Type: cd raspberrypi-homekit-rgb-led-strip; sudo npm start"
elif [ "$optionVideoMenu" == "x" ]; then
clear
exit 0
fi
#
# Standard Setups
#
#
if [ "$optionStandardMenu" == "1" ]; then
updateRaspbian
echo ""
echo "Installing PiGPIO ..."
echo ""
sudo apt install -y build-essential python-setuptools python3-setuptools
wget https://github.com/joan2937/pigpio/archive/master.zip && unzip master.zip && cd pigpio-master && make && sudo make install
elif [ "$optionStandardMenu" == "2" ]; then
updateRaspbian
echo ""
echo "Installing Node.js & PiGPIO ..."
echo ""
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs build-essential python-setuptools python3-setuptools
wget https://github.com/joan2937/pigpio/archive/master.zip && unzip master.zip && cd pigpio-master && make && sudo make install
elif [ "$optionStandardMenu" == "3" ]; then
updateRaspbian
echo ""
echo "Installing PM2 ..."
echo ""
sudo npm install pm2@latest -g
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
pm2 list
elif [ "$optionStandardMenu" == "x" ]; then
clear
exit 0
fi
sudo apt clean
clear
echo ""
echo "Your Raspberry Pi IP Addresses:"
echo "Note: Blank means no connection."
echo ""
echo "Wired IP Address:"
ip addr show eth0 | grep -Po 'inet \K[\d.]+'
echo ""
echo "Wireless IP Address:"
ip addr show wlan0 | grep -Po 'inet \K[\d.]+'
echo ""
sshStatus=$(systemctl is-active ssh)
if [ $sshStatus != "active" ]; then
echo "SSH is disabled, would you like to enable it for remote connectivity?"
read -p "Enter y or n: " -n 1 optionSSH
echo ""
if [ $optionSSH == "y" ]; then
sudo systemctl enable ssh
sudo systemctl start ssh
echo ""
echo "SSH should now be active. In the future if you wish to turn it off and disable it, run these commands:"
echo "sudo systemctl stop ssh"
echo "sudo systemctl disable ssh"
fi
fi
echo ""
echo "Finished!"
echo ""
echo $doneMessage