forked from xtr4nge/FruityWifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-FruityWifi.sh
executable file
·254 lines (200 loc) · 6.78 KB
/
install-FruityWifi.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
#!/bin/bash
# CONFIG
# --------------------------------------------------------
# Setup 'sudo' or 'danger' (root exec).
# --------------------------------------------------------
fruitywifi_exec_mode="sudo"
# --------------------------------------------------------
# Setup log path. default=/usr/share/fruitywifi/logs
# --------------------------------------------------------
fruitywifi_log_path="/usr/share/fruitywifi/logs"
# --------------------------------------------------------
# danger: 'enable' or 'disabled' (Backward compatibility)
# --------------------------------------------------------
fruitywifi_danger="enabled"
# --------------------------------------------------------
# 'all' option installs nginx webserver on ports 80 | 443,
# and it also installs FruityWifi on ports 8000 | 8443.
# If 'all' is not specified then only installs 8000 | 8443
# --------------------------------------------------------
fruitywifi_webserver="all"
# --------------------------------------------------------
find FruityWifi -type d -exec chmod 755 {} \;
find FruityWifi -type f -exec chmod 644 {} \;
root_path=`pwd`
mkdir tmp-install
cd tmp-install
apt-get update
echo "--------------------------------"
echo "Creates user fruitywifi"
echo "--------------------------------"
adduser --disabled-password --quiet --system --home /var/run/fruitywifi --no-create-home --gecos "FruityWifi" --group fruitywifi
echo "[fruitywifi user has been created]"
echo
apt-get -y install gettext make intltool build-essential automake autoconf uuid uuid-dev php5-curl php5-cli dos2unix curl sudo unzip
cmd=`gcc --version|grep "4.7"`
if [[ $cmd == "" ]]
then
echo "--------------------------------"
echo "Installing gcc 4.7"
echo "--------------------------------"
apt-get -y install gcc-4.7
apt-get -y install g++-4.7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
echo "[gcc setup completed]"
else
echo "--------------------------------"
echo "gcc 4.7 already installed"
echo "--------------------------------"
echo
fi
echo
if [ ! -f "/usr/sbin/dnsmasq" ]
then
echo "--------------------------------"
echo "Installing dnsmasq"
echo "--------------------------------"
# INSTALL DNSMASQ
apt-get -y install dnsmasq
echo "[dnsmasq setup completed]"
else
echo "--------------------------------"
echo "dnsmasq already installed"
echo "--------------------------------"
echo
fi
echo
if [ ! -f "/usr/sbin/hostapd" ]
then
echo "--------------------------------"
echo "Installing hostapd"
echo "--------------------------------"
# INSTALL HOSTAPD
apt-get -y install hostapd
echo "[hostapd setup completed]"
else
echo "--------------------------------"
echo "hostapd already installed"
echo "--------------------------------"
echo
fi
echo
if [ ! -f "/usr/sbin/airmon-ng" ] && [ ! -f "/usr/local/sbin/airmon-ng" ]
then
echo "--------------------------------"
echo "Installing aircrack-ng"
echo "--------------------------------"
# INSTALL AIRCRACK-NG
apt-get -y install libssl-dev wireless-tools iw
wget http://download.aircrack-ng.org/aircrack-ng-1.2-beta1.tar.gz
tar -zxvf aircrack-ng-1.2-beta1.tar.gz
cd aircrack-ng-1.2-beta1
make
make install
ln -s /usr/local/sbin/airmon-ng /usr/sbin/airmon-ng
ln -s /usr/local/sbin/airbase-ng /usr/sbin/airbase-ng
cd ../
echo "[aircrack-ng setup completed]"
else
echo "--------------------------------"
echo "aircrack-ng already installed"
echo "--------------------------------"
echo
fi
echo
# BACK TO ROOT-INSTALL FOLDER
cd $root_path
echo "--------------------------------"
echo "Installing Nginx"
echo "--------------------------------"
# NGINX INSTALL
apt-get -y install nginx php5-fpm
echo
# SSL
echo "--------------------------------"
echo "Create Nginx ssl certificate"
echo "--------------------------------"
cd $root_path
mkdir /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
rm /etc/nginx/sites-enabled/default
cp nginx-setup/nginx.conf /etc/nginx/
cp nginx-setup/FruityWifi /etc/nginx/sites-enabled/
cp nginx-setup/fpm/8000.conf /etc/php5/fpm/pool.d/
cp nginx-setup/fpm/8443.conf /etc/php5/fpm/pool.d/
if [ $fruitywifi_webserver == "all" ]
then
mkdir /var/www/
echo "." >> /var/www/index.php
chown -R fruitywifi:fruitywifi /var/www/
cp nginx-setup/default /etc/nginx/sites-enabled/
cp nginx-setup/fpm/80.conf /etc/php5/fpm/pool.d/
cp nginx-setup/fpm/443.conf /etc/php5/fpm/pool.d/
fi
# RESTAR NGINX + PHP5-FPM
/etc/init.d/nginx restart
/etc/init.d/php5-fpm restart
echo "[nginx setup completed]"
echo
echo "--------------------------------"
echo "BACKUP"
echo "--------------------------------"
cmd=`date +"%Y-%m-%d-%k-%M-%S"`
mv /usr/share/fruitywifi fruitywifi.BAK.$cmd
echo
echo "--------------------------------"
echo "Setup FruityWifi"
echo "--------------------------------"
cd $root_path
echo "--------------------------------"
echo "Config log path"
echo "--------------------------------"
mkdir $fruitywifi_log_path
EXEC="s,^\$log_path=.*,\$log_path=\""$fruitywifi_log_path"\";,g"
sed -i $EXEC FruityWifi/www/config/config.php
EXEC="s,^log-facility=.*,log-facility="$fruitywifi_log_path"/dnsmasq.log,g"
sed -i $EXEC FruityWifi/conf/dnsmasq.conf
EXEC="s,^dhcp-leasefile=.*,dhcp-leasefile="$fruitywifi_log_path"/dhcp.leases,g"
sed -i $EXEC FruityWifi/conf/dnsmasq.conf
EXEC="s,^Defaults logfile =.*,Defaults logfile = "$fruitywifi_log_path"/sudo.log,g"
sed -i $EXEC sudo-setup/fruitywifi
echo "[logs setup completed]"
echo
echo "--------------------------------"
echo "Setup Sudo"
echo "--------------------------------"
cd $root_path
cp -a sudo-setup/fruitywifi /etc/sudoers.d/
echo "[sudo setup completed]"
echo
cp -a FruityWifi /usr/share/fruitywifi
ln -s $fruitywifi_log_path /usr/share/fruitywifi/www/logs
ln -s /usr/share/fruitywifi/ /usr/share/FruityWifi
#if [ $fruitywifi_exec_mode == "danger" ]
if [ $fruitywifi_danger == "enabled" ]
then
echo "--------------------------------"
echo "Installing danger"
echo "--------------------------------"
cd /usr/share/fruitywifi/bin/
gcc danger.c -o danger
chgrp fruitywifi /usr/share/fruitywifi/bin/danger
chmod 4750 /usr/share/fruitywifi/bin/danger
fi
echo
# START/STOP SERVICES
echo "--------------------------------"
echo "Start Services"
echo "--------------------------------"
update-rc.d ssh defaults
update-rc.d nginx defaults
update-rc.d php5-fpm defaults
update-rc.d ntp defaults
/etc/init.d/nginx restart
/etc/init.d/php5-fpm restart
apt-get -y remove ifplugd
echo
echo "GitHub: https://github.com/xtr4nge/FruityWifi"
echo "Twitter: @xtr4nge, @FruityWifi"
echo "ENJOY!"
echo ""