-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsmartpi.sh
203 lines (175 loc) · 5.16 KB
/
smartpi.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
#!/bin/bash
blue(){
echo -e "\033[34m\033[01m$1\033[0m"
}
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
red(){
echo -e "\033[31m\033[01m$1\033[0m"
}
yellow(){
echo -e "\033[33m\033[01m$1\033[0m"
}
bred(){
echo -e "\033[31m\033[01m\033[05m$1\033[0m"
}
byellow(){
echo -e "\033[33m\033[01m\033[05m$1\033[0m"
}
architecture=""
case $(uname -m) in
x86_64) architecture="amd64" ;;
aarch64) architecture="arm64" ;;
esac
function install_smartpi(){
if [[ $architecture = "amd64" ]]; then
cp /etc/apt/sources.list /etc/apt/sources.list.bak
rm -rf /etc/apt/sources.list
cat > /etc/apt/sources.list << EOF
deb http://mirrors.163.com/debian buster main
deb-src http://mirrors.163.com/debian buster main
deb http://mirrors.163.com/debian-security/ buster/updates main
deb-src http://mirrors.163.com/debian-security/ buster/updates main
deb http://mirrors.163.com/debian buster-updates main
deb-src http://mirrors.163.com/debian buster-updates main
EOF
fi
apt-get -y update
apt -y install curl
wget https://github.com/pymumu/smartdns/releases/download/Release28/smartdns.1.2019.12.15-1028.x86_64-linux-all.tar.gz
tar zxf smartdns.1.2019.12.15-1028.x86_64-linux-all.tar.gz
cd smartdns
chmod +x ./install
./install -i
rm -rf /etc/smartdns/smartdns.conf
cat > /etc/smartdns/smartdns.conf <<-EOF
bind [::]:5599
cache-size 512
prefetch-domain yes
rr-ttl 300
rr-ttl-min 60
rr-ttl-max 86400
log-level info
log-file /var/log/smartdns.log
log-size 128k
log-num 2
server 202.141.162.123
server 202.141.176.93
server-tcp 202.141.162.123
server-tcp 202.141.176.93
server-tcp 114.114.114.114
server-tls 8.8.8.8
server-tls 8.8.4.4
EOF
cp /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak
systemctl enable smartdns
systemctl start smartdns
curl -sSL https://install.pi-hole.net | bash
sed -i '/PIHOLE_DNS/d' /etc/pihole/setupVars.conf
sed -i '$a PIHOLE_DNS_1=127.0.0.1#5599' /etc/pihole/setupVars.conf
sed -i '/DNSMASQ_LISTENING/d' /etc/pihole/setupVars.conf
sed -i '$a DNSMASQ_LISTENING=local' /etc/pihole/setupVars.conf
rm -rf /etc/resolv.conf
cat > /etc/resolv.conf << EOF
nameserver 119.29.29.29
nameserver 119.28.28.28
nameserver 223.5.5.5
nameserver 223.6.6.6
EOF
pihole restartdns > /dev/null 2>&1
green " ===========================请重启debian系统=============================="
green " SmartPi安装完成"
green " 系统:>=debian9"
green " Youtube:米月"
green " 电报群:https://t.me/mi_yue"
green " Youtube频道地址:https://www.youtube.com/channel/UCr4HCEgaZ0cN5_7tLHS_xAg"
green " ===========================请重启debian系统=============================="
}
function update_smartdns(){
if test -s /etc/smartdns/smartdns.conf.bak; then
rm -rf /etc/smartdns/smartdns.conf.bak
cp /etc/smartdns/smartdns.conf /etc/smartdns/smartdns.conf.bak
./install -u
rm -rf /root/smartdns*
fi
wget https://github.com/pymumu/smartdns/releases/download/Release28/smartdns.1.2019.12.15-1028.x86_64-linux-all.tar.gz
tar zxf smartdns.1.2019.12.15-1028.x86_64-linux-all.tar.gz
cd smartdns
chmod +x ./install
./install -i
if test -s /etc/smartdns/smartdns.conf.bak; then
rm -rf /etc/smartdns/smartdns.conf
cp /etc/smartdns/smartdns.conf.bak /etc/smartdns/smartdns.conf
fi
systemctl enable smartdns
systemctl restart smartdns
pihole restartdns
green " ===========================请重启debian系统=============================="
green " SmartPi更新完成"
green " 系统:>=debian9"
green " Youtube:米月"
green " 电报群:https://t.me/mi_yue"
green " Youtube频道地址:https://www.youtube.com/channel/UCr4HCEgaZ0cN5_7tLHS_xAg"
green " ===========================请重启debian系统=============================="
}
function m_pass(){
red " =================================="
red " 修改pi-hole密码"
red " =================================="
pihole -a -p
red " =================================="
red " pi-hole密码修改完成"
red " =================================="
}
function rebuil_pi-hole(){
green " ================================"
green " 开始重新安装pi-hole"
green " ================================"
pihole -r
green " ================================"
green " pi-hole安装完成"
green " ================================"
}
start_menu(){
clear
green " ========================================================================"
green " 简介:debian一键安装SmartPi"
green " 系统:>=debian9"
green " Youtube:米月"
green " 电报群:https://t.me/mi_yue"
green " Youtube频道地址:https://www.youtube.com/channel/UCr4HCEgaZ0cN5_7tLHS_xAg"
green " ========================================================================"
echo
green " 1. 一键安装SmartPi"
green " 2. 一键更新SmartPi"
green " 3. 重新安装pi-hole"
green " 4. 更改pi-hole密码"
yellow " 0. 退出脚本"
echo
read -p " 请输入数字:" num
case "$num" in
1)
install_smartpi
;;
2)
update_smartdns
;;
3)
rebuil_pi-hole
;;
4)
m_pass
;;
0)
exit 1
;;
*)
clear
red "输入的数字不正确,请重新输入"
sleep 1s
start_menu
;;
esac
}
start_menu