-
Notifications
You must be signed in to change notification settings - Fork 0
/
pihole-change-queries-number.bash
72 lines (60 loc) · 1.99 KB
/
pihole-change-queries-number.bash
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
#!/bin/bash
A="/var/www/html/admin/scripts/pi-hole/js/index.js"
valori() {
echo
sed -i 's/topItems/topItems='$f'/' $A
sed -i 's/getQuerySources\&topClientsBlocked/getQuerySources='$t'\&topClientsBlocked='$b'/' $A
echo "Now queries number are:"
echo " $f 'Top Permitted Domains' and 'Top Blocked Domains'"
echo " $t 'Top Clients (total)'"
echo " $b 'Top Clients (blocked only)'"
echo
echo "Please refresh pihole web page from your browser!"
echo
}
tput clear
# ROOT CHECK
if [[ ! "${EUID}" -eq 0 ]]; then
echo && echo "Sorry but this script requires elevated privileges to run."
echo "Please restart as root user or with sudo command." && echo
sleep 1 && exit 1
fi
echo
echo "********************* Hello $USER! *********************"
echo
echo "This script changes queries number shown in pihole."
echo "Resetting to default value (10)..."
sed -i 's/getQuerySources=[0-9][0-9]\&topClientsBlocked=[0-9][0-9]/getQuerySources\&topClientsBlocked/' $A
sed -i 's/getQuerySources=&topClientsBlocked=/getQuerySources\&topClientsBlocked/' $A
sed -i 's/topItems=[0-9][0-9]/topItems/' $A
sed -i 's/topItems=/topItems/' $A
echo
read -p "Do you want to continue? (Y/n) " -n 1 -r -s
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo && echo && exit 1
fi
echo && echo
read -p "Do you want to load optimal values for medium pihole server? (Y/n) " -n 1 -r -s
if ! [[ $REPLY =~ ^[Nn]$ ]]; then
f=15 && t=30 && b=$t
echo && valori && exit 0
fi
echo && echo
echo "Please write 'Top Permitted Domains' and 'Top Blocked Domains' queries number (from 10 to 99):"
read f
if [ "$f" -gt 99 ] || [ "$f" -lt 10 ]; then
echo "Value not correct!" && echo && exit 1
fi
echo
echo "Please write 'Top Clients (total)' queries number (from 10 to 99):"
read t
if [ "$t" -gt 99 ] || [ "$t" -lt 10 ]; then
echo "Value not correct!" && echo && exit 1
fi
echo
echo "Please write 'Top Clients (blocked only)' queries number (from 10 to 99):"
read b
if [ "$b" -gt 99 ] || [ "$b" -lt 10 ]; then
echo "Value not correct!" && echo && exit 1
fi
valori && echo && exit 0