forked from curtbraz/WhosHere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL.sh
177 lines (98 loc) · 4.27 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
#!/bin/bash
## WELCOME LANGUAGE
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
echo "Initiating Install..";
sleep 2;
## UPDATES AND INSTALLS REQUIRED PACKAGES FROM DEBIAN BASED DISTROS
echo "Updating Repositories..";
sleep 2;
sudo apt-get update;
echo "Installing Required Packages.. You Will Have to Create a Database Password if Installing MySQL For the First Time..";
sleep 2;
sudo apt-get install apache2 php mariadb-client mariadb-server php-mysql python-mysqldb tshark python3-pymysql python-pip -y;
sudo pip install pymysql;
## SETS UP MONITORING WLAN INTERFACE
echo "Setting Up wlan Interface.. If you Haven't Already, Plug in Your WiFi Adapter Now and Hit Enter to Continue: ";
sed -i -e 's/disable_lua = false/disable_lua = true/g' /usr/share/wireshark/init.lua;
read Wait;
Interfaces=`iw dev |grep "Interface" |cut -d " " -f 2 |grep -v "mon0"`
InterfaceCount=`iw dev |grep "Interface" |grep -v "mon0" | wc -l`
if [ $InterfaceCount -gt 1 ]
then
echo "Which interface would you like to set up? The following wlan interfaces were detected: "$Interfaces
read SelectedInterface
fi
if [ $InterfaceCount -eq 1 ]
then
SelectedInterface=`iw dev |grep "Interface" |cut -d " " -f 2 |grep -v "mon0"`
fi
if [ $InterfaceCount -eq 0 ]
then
echo "No wireless adapters were detected! Please ensure the wireless adapter is set up and re-run the Install script."
exit 1
fi
if [ `iw dev |grep "Interface" |cut -d " " -f 2 |grep "mon0" | wc -l` -gt 0 ]
then
MonInterface=`iw dev |grep "Interface" |cut -d " " -f 2 |grep "mon0"`
iw dev $MonInterface del
fi
echo "Using Interface "$SelectedInterface"..";
sleep 2;
PhyDev="`iw dev |grep "$SelectedInterface" -B 1 |grep phy | sed 's/#//g'`"
PhyDevMonitorCheck="`iw "$PhyDev" info |grep monitor | wc -l`"
if [ $PhyDevMonitorCheck -eq 0 ]
then
echo "Error! "$SelectedInterface" does not support monitor mode. Is it possible the proper drivers are not installed for this Distribution or your wireless card simply does not support monitor mode?"
exit 1
fi
sed -i -e 's/PHY_DEVICE_HERE/'$PhyDev'/g' run.py;
## CONFIGURE CREDENTIALS
echo "Please enter your MySQL password..";
read MySQLPassword;
sed -i -e 's/PASSWORD_GOES_HERE/'$MySQLPassword'/g' run.py;
sed -i -e 's/PASSWORD_GOES_HERE/'$MySQLPassword'/g' dbconfig.php;
echo "This script uses IFTTT.com (If Then Then That) Incoming Webhooks for Slack/SMS/etc Notifications/Automation";
echo "What is your IFTTT.com Webhook URL? (Should look like https://maker.ifttt.com/trigger/WhosHere/with/key/IFTTT_WEBHOOK_GOES_HERE)"
read webhook
sed -i -e "s~IFTTT_WEBHOOK_GOES_HERE~$webhook~g" CheckAlerts.php;
## SETS UP APACHE AND COPIES PHP WEB FILES
echo "Setting Up the Web Server..";
sleep 2;
sudo service apache2 restart;
DIRECTORY='/var/www/html/'
if [ -d "$DIRECTORY" ]; then
mkdir /var/www/html/WhosHere/;
cp *.php /var/www/html/WhosHere/ && cp whoshere-logo.png /var/www/html/WhosHere/;
fi
if [ ! -d "$DIRECTORY" ]; then
mkdir /var/www/WhosHere/;
cp *.php /var/www/WhosHere/ && cp whoshere-logo.png /var/www/WhosHere/;
sed -i -e 's/html\///g' cron;
fi
## MODIFIES MYSQL CONFIGURATION SETTINGS FOR LOWER PERFORMANCE MACHINES (Raspberry Pi)
echo "Configuring MySQL Server and WhosHere Database..";
sleep 2;
sudo cp my.cnf /etc/mysql/ && sudo service mysql restart;
## IMPORTS MySQL SCHEMA AND STORED PROCEDURES
mysql -u root -p$MySQLPassword -h localhost < MySQLSchema.sql;
mysql -u root -p$MySQLPassword -e "CREATE USER 'whoshere' IDENTIFIED BY '$MySQLPassword';"
mysql -u root -p$MySQLPassword -e "GRANT ALL PRIVILEGES ON *.* TO 'whoshere' WITH GRANT OPTION;"
mysql -u root -p$MySQLPassword -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MySQLPassword';"
mysql -u root -p$MySQLPassword -e "FLUSH PRIVILEGES;"
## SETS UP CRON JOBS
echo "Setting up Scheduled Cron Jobs and Autostart Background Services..";
sleep 2;
crontab -l >> cron;
sudo crontab cron;
## INSTALLS SYSTEMD SERVICE
Path=`pwd`
sed -i -e "s~CHANGEME~$Path~g" whoshere.service;
sudo cp whoshere.service /lib/systemd/system/whoshere.service;
sudo systemctl daemon-reload
sudo systemctl enable whoshere.service
sudo systemctl start whoshere.service
## YOU'RE DONE!
echo "Installation Complete! Visit \"http://localhost/WhosHere\" to Begin!";