View difference between Paste ID: 7WHh7Pd3 and ugtzaxYp
SHOW: | | - or go back to the newest paste.
1
mkdir /temp
2
cd /temp
3
touch lusca_install.sh
4
chmod +x lusca_install.sh
5
nano lusca_install.sh
6
7
and paste the following code . . .
8
9
#!/bin/bash
10
# Version 1.0 / 2nd July, 2014
11
# LUSCA r14942 Automated Installation Script for Ubuntu flavor / asd
12
#KALTERSIA
13
 
14
# Setting Variables . . . [asd]
15
16
URL=http://wifismartzone.com/files/linux_related/lusca
17
SQUID_DIR="/etc/squid"
18
CACHE_DIR="/cache-1"
19
pid=`pidof squid`
20
osver=`cat /etc/issue |awk '{print $1}'`
21
squidlabel="LUSCA_HEAD-r14942"
22
 
23
# Colors Config  . . . [[ asd . . . ]]
24
ESC_SEQ="\x1b["
25
COL_RESET=$ESC_SEQ"39;49;00m"
26
COL_RED=$ESC_SEQ"31;01m"
27
COL_GREEN=$ESC_SEQ"32;01m"
28
 
29
# OS checkup for UBUNTU
30
echo -e "$COL_GREEN Lusca r14942 Automated Installation Script ver 1.0 for Ubuntu . . .$COL_RESET"
31
echo -e "$COL_GREEN Checking OS version, as it must be Ubuntu in order to Continue . . .$COL_RESET"
32
if [[ $osver == Ubuntu ]]; then
33
echo
34
echo -e "$COL_GREEN Ubuntu is installed with following information fetched. $COL_RESET"
35
lsb_release -a
36
sleep 3
37
else
38
echo -e "$COL_RED Sorry, it seems your Linux Distribution is not UBUNTU . Exiting ...$COL_RESET"
39
exit 1
40
fi
41
 
42
# Make sure only root can run our script / Checking if user is root, otherwise exit with error [[asd]]
43
echo
44
echo -e "$COL_GREEN Verifying if you are logged in with root privileges  . . .$COL_RESET" 1>&2
45
FILE="/tmp/out.$$"
46
GREP="/bin/grep"
47
if [ "$(id -u)" != "0" ]; then
48
echo
49
echo -e "$COL_RED This script must be run as root, switch to root now . . .$COL_RESET" 1>&2
50
exit 1
51
fi
52
 
53
# Clearing previous download if any in /tmp folder
54
echo
55
echo -e "$COL_GREEN Clearing previous downloads if any in /tmp folder to avoid duplication$COL_RESET"
56
sleep 3
57
 
58
rm -fr /tmp/squid.conf
59
rm -fr /tmp/storeurl.txt
60
rm -fr /tmp/storeurl.pl
61
rm -fr /tmp/LUSCA_HEAD-r14942*
62
 
63
# Checking IF $URL is accessible m if YES then continue further , otherwise EXIT the script with ERROR ! [[ asd .. . .]]
64
echo
65
echo -e "$COL_GREEN Checking if $URL is accessible in order to proceed further. . .!! $COL_RESET"
66
cd /tmp
67
wget -q $URL/squid.conf
68
{
69
if [ ! -f /tmp/squid.conf ]; then
70
echo
71
echo -e "$COL_RED ERROR: Unable to contact $URL, or possibly internet is not working or your IP is in black list at destination server  !! $COL_RESET"
72
echo -e "$COL_RED ERROR: Please check manual if $URL is accessible or not or if it have required files, asd  !! $COL_RESET"
73
exit 0
74
fi
75
}
76
rm -fr /tmp/squid.conf
77
sleep 6
78
# Moving further . . .
79
 
80
clear
81
echo -e "$COL_GREEN You are logged in with root ID, Ok to proceed further . . .!! $COL_RESET"
82
echo
83
 
84
################################################################## [zaib]
85
echo
86
echo -e "$COL_GREEN Updating Ubuntu first . . . !! $COL_RESET"
87
apt-get update
88
echo
89
echo
90
echo -e "$COL_GREEN Installing required components . . . !! $COL_RESET"
91
sleep 3
92
apt-get install  -y gcc  build-essential   libstdc++6   unzip    bzip2   sharutils  ccze  libzip-dev  automake1.9  libfile-readbackwards-perl  dnsmasq
93
 
94
# Clearing OLD data files . . .
95
{
96
if [ -f $SQUID_DIR/squid.conf ]; then
97
echo
98
echo
99
echo -e "$COL_RED Previous SQUID configuration file found in $SQUID_DIR ! renaming it for backup purpose . . . $COL_RESET"
100
mv $SQUID_DIR/squid.conf $SQUID_DIR/squid.conf.old
101
else
102
echo
103
echo
104
echo -e "$COL_GREEN No Previous Squid configuration have been found in $SQUID_DIR. Proceeding further $COL_RESET"
105
fi
106
}
107
 
108
# Checking SQUID status if its already running - check by PID
109
if [ "$pid" == "" ]; then
110
echo
111
echo
112
echo -e "$COL_GREEN No SQUID instance found in memory , so it seems we are good to GO !!! $COL_RESET"
113
else
114
echo
115
echo -e "$COL_RED SQUID is already running, probably you have some previous copy of SQUID installation, Better to stop and remove all previous squid installation !! $COL_RESET"
116
echo
117
echo -e "$COL_RED KILLING PREVIOUS SQUID INSTANCE by killall -9 squid command  !! $COL_RESET"
118
killall -9 squid
119
sleep 3
120
fi
121
 
122
# Downloading Squid source package [zaib]
123
echo
124
echo
125
echo -e "$COL_GREEN Downloading SQUID source package in /tmp folder. . . !! $COL_RESET"
126
sleep 3
127
 
128
# Checking if /tmp folder is previously present or not . . .
129
{
130
if [ ! -d "/tmp" ]; then
131
echo
132
echo
133
echo -e "$COL_RED /tmp folder not found, Creating it so all downloads will be placed here  . . . $COL_RESET"
134
mkdir /tmp
135
else
136
echo
137
echo -e "$COL_GREEN /tmp folder is already present , so no need to create it, Proceeding further . . . $COL_RESET"
138
fi
139
}
140
 
141
cd /tmp
142
 
143
# Checking IF LUSCA_HEAD-r14942.tar.gz  installation file have been ALREADY downloaded in /tmp to avoid duplication! [[ asd .. . .]]
144
{
145
if [ -f /tmp/LUSCA_HEAD-r14942.tar.gz ]; then
146
rm -fr /tmp/LUSCA_HEAD-r14942.tar.gz
147
fi
148
}
149
 
150
wget -c http://wifismartzone.com/files/linux_related/lusca/LUSCA_HEAD-r14942.tar.gz
151
 
152
# Checking IF LUSCA_HEAD-r14942 installation file have been downloaded properly. if YEs continue further , otherwise EXIT the script with ERROR ! [[ asd .. . .]]
153
{
154
if [ ! -f /tmp/LUSCA_HEAD-r14942.tar.gz ]; then
155
echo
156
echo
157
 
158
echo -e "$COL_RED ERROR: SQUID source code package File could not be download or not found in /tmp/ !! $COL_RESET"
159
exit 0
160
fi
161
}
162
echo
163
echo
164
 
165
echo -e "$COL_GREEN Extracting Squid from tar archive. . . !! $COL_RESET"
166
sleep 3
167
tar zxvf LUSCA_HEAD-r14942.tar.gz
168
cd LUSCA_HEAD-r14942/
169
mkdir /etc/squid
170
 
171
echo -e "$COL_GREEN Executing $squidlabel Compiler [asd] . . . !! $COL_RESET"
172
echo
173
cd /tmp/LUSCA_HEAD-r14942
174
./configure --prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid --localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-async-io=24 --with-aufs-threads=24 --with-pthreads --enable-storeio=aufs --enable-linux-netfilter --enable-arp-acl --enable-epoll --enable-removal-policies=heap --with-aio --with-dl --enable-snmp --enable-delay-pools --enable-htcp --enable-cache-digests --disable-unlinkd --enable-large-cache-files --with-large-files --enable-err-languages=English --enable-default-err-language=English --enable-referer-log --with-maxfd=65536
175
echo
176
echo -e "$COL_GREEN Executing MAKE and MAKE INSTALL commands . . . !! $COL_RESET"
177
sleep 3
178
make
179
make install
180
echo
181
echo
182
echo -e "$COL_GREEN Creating SQUID LOGS folder and assiging permissions . . . !! $COL_RESET"
183
sleep 3
184
 
185
# Checking if log folder is previously present or not . . .
186
{
187
if [ -d "/var/log/squid" ]; then
188
echo
189
echo
190
echo -e "$COL_GREEN LOGS folder found. No need to create, proceeding Further . . . $COL_RESET"
191
else
192
echo
193
echo
194
echo -e "$COL_GREEN Creating LOG Folder in /var/log/squid and setting permissions accordingly (to user proxy) $COL_RESET"
195
mkdir /var/log/squid
196
fi
197
}
198
chown proxy:proxy /var/log/squid
199
## ** DOWNLOAD SQUID.CONF
200
echo
201
echo
202
echo -e "$COL_GREEN Downloading SQUID.CONF file from $URL and copy it to $SQUID_DIR. . . !! $COL_RESET"
203
sleep 3
204
 
205
# Checking IF SQUID.CONF File have been ALREADY downloaded in /tmp to avoid duplication! [[ asd .. . .]]
206
{
207
if [ -f /tmp/squid.conf ]; then
208
rm -fr /tmp/squid.conf
209
fi
210
}
211
 
212
cd /tmp
213
wget $URL/squid.conf
214
 
215
# Checking IF SQUID.CONF file have been downloaded. if YEs continue further , otherwise EXIT the script with ERROR ! [[ asd .. . .]]
216
{
217
if [ ! -f /tmp/squid.conf ]; then
218
echo
219
echo
220
echo -e "$COL_RED ERROR: SQUID.CONF File could not be download or not found in /tmp/ !! $COL_RESET"
221
exit 0
222
fi
223
}
224
cp -fr squid.conf $SQUID_DIR
225
 
226
## ** DOWNLOAD SQUID.CONF
227
echo
228
echo
229
echo -e "$COL_GREEN Downloading STOREURL.PL file from $URL and copy it to $SQUID_DIR. . . !! $COL_RESET"
230
sleep 3
231
cd /tmp
232
 
233
{
234
if [ -f /tmp/storeurl.txt ]; then
235
rm -fr /tmp/storeurl.txt
236
fi
237
}
238
 
239
wget $URL/storeurl.txt
240
 
241
{
242
if [ -f /tmp/storeurl.pl ]; then
243
rm -fr /tmp/storeurl.pl
244
fi
245
}
246
 
247
mv storeurl.txt storeurl.pl
248
 
249
# Checking IF STOREURL.PL file have been downloaded. if YEs continue further , otherwise EXIT the script with ERROR ! [[ asd .. . .]]
250
{
251
if [ ! -f /tmp/storeurl.pl ]; then
252
echo
253
echo
254
echo -e "$COL_RED ERROR: STOREURL.PL File could not be download or not found in /tmp/ !! $COL_RESET"
255
exit 0
256
fi
257
}
258
cp -fr storeurl.pl $SQUID_DIR
259
 
260
echo
261
echo
262
echo -e "$COL_GREEN Setting EXECUTE permission for storeurl.pl . . . !! $COL_RESET"
263
chmod +x $SQUID_DIR/storeurl.pl
264
 
265
# Creating CACHE folders
266
echo
267
echo
268
echo -e "$COL_GREEN Creating CACHE directory in $CACHE_DIR , in this example,I used 5GB for cache for test ,Adjust it accordingly  . . . !! $COL_RESET"
269
sleep 3
270
 
271
# Checking if /cache-1 folder exist  . . .
272
{
273
if [ ! -d "$CACHE_DIR" ]; then
274
echo
275
echo
276
echo -e "$COL_GREEN Creating cache folder in $CACHE_DIR , Default size is 5GB, you should set it accordingly to your requirements  . . . $COL_RESET"
277
mkdir $CACHE_DIR
278
chown proxy:proxy $CACHE_DIR
279
chmod 777 -R $CACHE_DIR
280
squid -z
281
else
282
echo
283
echo -e "$COL_RED $CACHE_DIR folder already exists , Clearing it before proceeding. . . $COL_RESET"
284
rm -fr $CACHE_DIR/*
285
chown proxy:proxy $CACHE_DIR
286
echo -e "$COL_GREEN $CACHE_DIR Initializing Cache Directories as per the config  . . . $COL_RESET"
287
echo
288
squid -z
289
chmod 777 -R $CACHE_DIR
290
fi
291
}
292
 
293
echo
294
echo
295
echo -e "$COL_GREEN Adding squid in /etc/rc.local for auto startup . . . !! $COL_RESET"
296
sed -i '/exit/d' /etc/rc.local
297
sed -i '/[/usr\/sbin\/squid]/d' /etc/rc.local
298
echo /usr/sbin/squid >> /etc/rc.local
299
echo exit 0 >> /etc/rc.local
300
echo
301
echo -e "$COL_GREEN Starting SQUID (and adding 10 seconds Pause for proper initialization). . . !! $COL_RESET"
302
squid
303
sleep 5
304
 
305
# Checking SQUID status via PID [zaib]
306
#if [ "$pid" == "" ]; then
307
#echo
308
#echo -e "$COL_RED ERROR: UNABLE to start SQUID, try to run with -d1N syntax and see where its showing error !! $COL_RESET"
309
#else
310
ps aux |grep squid
311
echo
312-
echo
312+
313
echo
314
echo To view squid web access activity log, use command
315
echo -e "$COL_GREEN tail -f /var/log/squid/access.log $COL_RESET"
316
echo OR
317
echo -e "$COL_GREEN tail -f /var/log/squid/access.log |ccze $COL_RESET"
318
echo
319
echo -e "$COL_GREEN Regard's / KALTERSIA . . . !! $COL_RESET"
320
echo
321
# END
322
323
now execute the script by running
324
/lusca_install.sh