-
Notifications
You must be signed in to change notification settings - Fork 18
/
install.sh
executable file
·303 lines (202 loc) · 6.78 KB
/
install.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash
#set -x
# pi-ap: These scripts configure a Raspberry Pi into a wireless Access Point
# Source: https://github.com/f1linux/pi-ap
# Version: 01.10.02
# License: GPL 3.0
# Script Author: Terrence Houlahan Linux & Network Engineer
# Contact: [email protected]
# Linkedin: www.linkedin.com/in/terrencehoulahan
# Do not edit below sources
source "${BASH_SOURCE%/*}/variables.sh"
source "${BASH_SOURCE%/*}/functions.sh"
echo
echo "$(tput setaf 5)****** GPL3 LICENSE: ******$(tput sgr 0)"
echo
echo 'All scripts/files in the pi-ap repository are Copyright (C) 2019 Terrence Houlahan'
echo
echo "This program comes with ABSOLUTELY NO WARRANTY express or implied."
echo "This is free software and you are welcome to redistribute it under certain conditions."
echo "Consult * LICENSE.txt * for full terms of GPL 3 License and conditions of use."
read -p "Press ENTER to accept GPL v3 license terms to continue or terminate this bash shell to exit script"
# Check for a router uplink on the Pi:
if [[ $(ip addr list|grep eth0|grep 'NO-CARRIER') != '' ]]; then
echo
echo 'No Router Uplink Connected to Raspberry Pi eth0 interface'
echo
echo 'Please connect and re-execute this install script; EXITING'
echo
exit
fi
# Create directory where logs will be written
if [ ! -d $PATHLOGSCRIPTS ]; then
mkdir $PATHLOGSCRIPTS
chmod 770 $PATHLOGSCRIPTS
chown $USEREXECUTINGSCRIPT:$USEREXECUTINGSCRIPT $PATHLOGSCRIPTS
fi
if [ ! -d /root/$PATHSCRIPTSROOT ]; then
mkdir /root/$PATHSCRIPTSROOT
chmod 770 /root/$PATHSCRIPTSROOT
chown root:root /root/$PATHSCRIPTSROOT
fi
echo
echo "$(tput setaf 5)******$(tput sgr 0) $(tput setaf 3)PRE$(tput sgr 0)-$(tput setaf 5)Configuration ******$(tput sgr 0)"
echo
echo "Default Config $(tput setaf 1)*BEFORE*$(tput sgr 0) host shaped by pi-ap scripts:"
echo
echo
echo "NETWORKING:"
echo "##########"
echo "$(tput setaf 9)eth0:$(tput sgr 0)"
ip addr list|grep eth0|awk 'FNR==2'|awk '{print $2}'
ip -6 addr list|grep eth0|awk 'FNR==2'|awk '{print $2}'
echo
echo "$(tput setaf 9)wlan0:$(tput sgr 0)"
ip addr list|grep wlan0|awk 'FNR==2'|awk '{print $2}'
ip -6 addr list|grep wlan0|awk 'FNR==2'|awk '{print $2}'
echo
echo "WIRELESS:"
echo "##########"
echo "Output of: $(tput setaf 9)iw dev wlan0 info$(tput sgr 0)"
iw dev wlan0 info
echo
echo "Output of: $(tput setaf 9)iwconfig wlan0$(tput sgr 0)"
iwconfig wlan0
echo
sleep 5
cd $PATHSCRIPTS
echo
echo "$(tput setaf 5)****** CONFIGURE HOST TIMEKEEPING: ******$(tput sgr 0)"
echo
./timedate.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** PACKAGE MANAGEMENT: ******$(tput sgr 0)"
echo
echo 'Elapsed Time for Package Management will be printed after this section completes:'
echo
time ./packages.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** AP Configuration: ******$(tput sgr 0)"
echo
./ap-config.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** Kernel: Driver Loading/Unloading and Setting Kernel Parameters ******$(tput sgr 0)"
echo
./kernel_modifications.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** DNS: systemd-resolved ******$(tput sgr 0)"
echo
./dns.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** CHANGE HOSTNAME: ******$(tput sgr 0)"
echo
./hostname.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** Create Customized Login Messages: ******$(tput sgr 0)"
echo
./login-messages.sh 2>> $PATHLOGSCRIPTS/install.log
echo
echo "$(tput setaf 5)****** Power Management: Disable ******$(tput sgr 0)"
echo
echo "Unless a device BOTH has a battery and a driver to support Power Mgmnt it is unnecessary and only breaks things"
./service-pwr-mgmnt-disable.sh 2>> $PATHLOGSCRIPTS/install.log
echo '###################################################################################################'
echo
echo "$(tput setaf 4)Troubleshooting: Show Processes Status:$(tput sgr 0)"
echo
echo
echo
systemctl status hostapd.service --no-pager 2>> $PATHLOGSCRIPTS/install.log
echo
echo
echo
echo
systemctl status dhcpcd.service --no-pager 2>> $PATHLOGSCRIPTS/install.log
echo
echo
echo
echo
systemctl status dnsmasq.service --no-pager 2>> $PATHLOGSCRIPTS/install.log
echo
echo
echo
echo
systemctl status wpa_supplicant 2>> $PATHLOGSCRIPTS/install.log
echo
echo
echo '###################################################################################################'
echo
echo "$(tput setaf 4)Troubleshooting: Show Key Config Files:$(tput sgr 0)"
echo
echo "Show $(tput setaf 9)/etc/dnsmasq.conf$(tput sgr 0)"
echo
cat /etc/dnsmasq.conf | grep "^[^#]"
echo
echo
echo "Show $(tput setaf 9)/etc/dhcpcd.conf$(tput sgr 0)"
echo
cat /etc/dhcpcd.conf | grep "^[^#]"
echo
echo
echo "Show $(tput setaf 9)/etc/hostapd/hostapd.conf$(tput sgr 0)"
echo
cat /etc/hostapd/hostapd.conf | grep "^[^#]"
echo
echo
echo "Check below feedback from $(tput setaf 9)rfkill list$(tput sgr 0) to determine if any interfaces register a hardblock"
echo
rfkill list
echo
echo
echo "Show $(tput setaf 9)systemd-networkd$(tput sgr 0) managed connections: $(tput setaf 4)networkctl list$(tput sgr 0) :"
networkctl list
echo
echo
echo
echo "$(tput setaf 5)****** FireWall Config: ******$(tput sgr 0)"
echo
./firewall_ipv4.sh 2>> $PATHLOGSCRIPTS/install.log
./firewall_ipv6.sh 2>> $PATHLOGSCRIPTS/install.log
./firewall_Default-Policies.sh 2>> $PATHLOGSCRIPTS/install.log
echo "$(tput setaf 4)Load UFW Firewall Changes$(tput sgr 0)"
echo "y" | ufw disable
echo "y" | ufw enable
ufw logging on
echo "$(tput setaf 4)Print Firewall Rules$(tput sgr 0)"
ufw status numbered verbose
echo
echo
echo "$(tput setaf 4)Print Firewall USER Rules Only$(tput sgr 0)"
echo
echo "$(tput setaf 4)Execute 'sudo ufw show user-rules' and view packet counts for non-zero values to determine if rules are matching$(tput sgr 0)"
echo "$(tput setaf 4)Specimen output of the command shown below:$(tput sgr 0)"
echo
ufw show user-rules
echo
echo
echo "$(tput setaf 5)******$(tput sgr 0) $(tput setaf 3)POST$(tput sgr 0)-$(tput setaf 5)Configuration ******$(tput sgr 0)"
echo
echo "Config $(tput setaf 1)*AFTER*$(tput sgr 0) host shaped by pi-ap scripts:"
echo
echo
echo "NETWORKING:"
echo "##########"
echo "$(tput setaf 9)eth0:$(tput sgr 0)"
ip addr list|grep eth0|awk 'FNR==2'|awk '{print $2}'
ip -6 addr list|grep eth0|awk 'FNR==2'|awk '{print $2}'
echo
echo "$(tput setaf 9)wlan0:$(tput sgr 0)"
ip addr list|grep wlan0|awk 'FNR==2'|awk '{print $2}'
ip -6 addr list|grep wlan0|awk 'FNR==2'|awk '{print $2}'
echo
echo "WIRELESS:"
echo "##########"
echo "Output of: $(tput setaf 9)iw dev wlan0 info$(tput sgr 0)"
iw dev wlan0 info
echo
echo "Output of: $(tput setaf 9)iwconfig wlan0$(tput sgr 0)"
iwconfig wlan0
echo
echo "Config Completed. Host will reboot now"
echo
systemctl reboot