-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_ifilter.sh
74 lines (58 loc) · 1.77 KB
/
update_ifilter.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
#!/bin/bash
#setup variables
tempfolder=$HOME/Downloads
httpsite=http://www.bluetack.co.uk/config
httpfile=nipfilter.dat.gz
httpfileuncompressed=nipfilter.dat
blocklist=ipfilter.dat
echo.
echo -------------------------------------
echo qBittorrent Blocklist Updater
echo
echo version 1.0
echo Written by Craig M. Rosenblum
echo -------------------------------------
echo .
echo ::**:: Creating temp folder and removing files
#check if tempfolder exists if not create it
if [ ! -d "$tempfolder" ]; then
mkdir $tempfolder
fi
#delete existing httpfile and blocklist files
if [ -d "$tempfolder/$httpfile" ]; then
rm "$tempfolder/$httpfile"
fi
if [ -d "$tempfolder/$blocklist" ]; then
rm "$tempfolder/$blocklist"
fi
#download the ipfilter to a local folder
echo ::**:: Downloading the blocklist
wget --no-verbose --quiet "$httpsite/$httpfile" --no-cache -O "$tempfolder/$httpfile">/dev/null
#check for wget errors
if [ $? -ne 0 ]; then
echo ::**:: wget returned errorlevel: $?
echo ::**:: An error occured!
exit 1
fi
#delete previously unzipped ipfilter file
if [ -d "$tempfolder/nipfilter.dat" ]; then
rm "$tempfolder/nipfilter.dat"
fi
#unzip the downloaded file
echo ::**:: Uncompressing "$httpfile" to "$httpfileuncompressed"
gunzip -f "$tempfolder/$httpfile"
if [ $? -ne 0 ]; then
echo ::**:: gunzip returned errorlevel: $?
echo ::**:: An error occured!
exit 1
fi
#rename the downloaded blocklist file
echo ::**:: Moving and renaming the blocklist from "$httpfileuncompressed" to "$blocklist"
mv -f "$tempfolder/$httpfileuncompressed" "$HOME/.config/qBittorrent/$blocklist"
if [ $? -ne 0 ]; then
echo ::**:: rename returned errorlevel: $?
echo ::**:: An error occured!
exit 1
fi
echo ::**:: Update Complete!
exit 0