mirror of
https://gitee.com/callmer/pve_toss_notes.git
synced 2026-08-31 05:52:52 +08:00
优化 SmartDNS 插件脚本兼容性
This commit is contained in:
+2
-2
@@ -270,7 +270,7 @@ $ sudo chmod +x /usr/local/bin/smartdns-plugin.sh
|
||||
$ sudo chattr +i /usr/local/bin/smartdns-plugin.sh
|
||||
|
||||
## 执行脚本
|
||||
$ sudo bash /usr/local/bin/smartdns-plugin.sh
|
||||
$ sudo /usr/local/bin/smartdns-plugin.sh
|
||||
```
|
||||
|
||||
### 6.2.定时任务
|
||||
@@ -300,7 +300,7 @@ $ sudo crontab -e
|
||||
|
||||
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
|
||||
|
||||
30 9 * * * /usr/bin/bash /usr/local/bin/smartdns-plugin.sh
|
||||
30 9 * * * /usr/local/bin/smartdns-plugin.sh
|
||||
```
|
||||
|
||||
### 6.3. SmartDNS 主配置
|
||||
|
||||
@@ -8,11 +8,11 @@ $ sudo chmod +x /usr/local/bin/dnsmasq-plugin.sh
|
||||
$ sudo chattr +i /usr/local/bin/dnsmasq-plugin.sh
|
||||
|
||||
## 执行脚本
|
||||
$ sudo bash /usr/local/bin/dnsmasq-plugin.sh
|
||||
$ sudo /usr/local/bin/dnsmasq-plugin.sh
|
||||
|
||||
## 设置 crontab
|
||||
|
||||
25 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/dnsmasq.d/anti-ad.dnsmasq.conf https://anti-ad.net/anti-ad-for-dnsmasq.conf
|
||||
|
||||
35 9 * * * /usr/bin/bash /usr/local/bin/dnsmasq-plugin.sh
|
||||
35 9 * * * /usr/local/bin/dnsmasq-plugin.sh
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
|
||||
20 9 * * * /usr/bin/curl --retry-connrefused --retry 5 --retry-delay 5 --retry-max-time 60 -fsSLR -o /etc/smartdns.d/anti-ad.smartdns.conf https://anti-ad.net/anti-ad-for-smartdns.conf
|
||||
|
||||
30 9 * * * /usr/bin/bash /usr/local/bin/smartdns-plugin.sh
|
||||
30 9 * * * /usr/local/bin/smartdns-plugin.sh
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ echo "Checking whether the configuration folder exists..."
|
||||
[ -d "$CONFDIR" ] || mkdir -p "$CONFDIR"
|
||||
|
||||
echo "Downloading latest configurations..."
|
||||
git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
|
||||
git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKDIR" || { echo "Git clone failed"; rm -rf "$WORKDIR"; exit 1; }
|
||||
#git clone --depth=1 https://pagure.io/dnsmasq-china-list.git "$WORKDIR"
|
||||
#git clone --depth=1 https://github.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
|
||||
#git clone --depth=1 https://bitbucket.org/felixonmars/dnsmasq-china-list.git "$WORKDIR"
|
||||
@@ -35,29 +35,23 @@ done
|
||||
echo "Installing new configurations..."
|
||||
for _conf in $CONF_WITH_SERVERS $CONF_WITH_GROUP $CONF_SIMPLE; do
|
||||
|
||||
case "$CONF_WITH_SERVERS" in
|
||||
*"$_conf"*)
|
||||
if echo " $CONF_WITH_SERVERS " | grep -q " $_conf "; then
|
||||
sed -n 's/^server=\/\([^\/]*\)\/114.114.114.114$/\1/p' "$WORKDIR/$_conf.conf" | grep -v '^#' > "$WORKDIR/$_conf.step1.raw"
|
||||
sed -e "s/.*/nameserver \/&\/$GROUP/" "$WORKDIR/$_conf.step1.raw" > "$WORKDIR/$_conf.step2.raw"
|
||||
cp "$WORKDIR/$_conf.step2.raw" "$CONFDIR/$_conf.smartdns.conf"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$CONF_WITH_GROUP" in
|
||||
*"$_conf"*)
|
||||
if echo " $CONF_WITH_GROUP " | grep -q " $_conf "; then
|
||||
for _server in $SERVERS; do
|
||||
echo "server $_server -group $GROUP -exclude-default-group" >> "$WORKDIR/$_conf.raw"
|
||||
done
|
||||
cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.smartdns.conf"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$CONF_SIMPLE" in
|
||||
*"$_conf"*)
|
||||
if echo " $CONF_SIMPLE " | grep -q " $_conf "; then
|
||||
sed -e "s/=/ /" "$WORKDIR/$_conf.conf" > "$WORKDIR/$_conf.raw"
|
||||
cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.smartdns.conf"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
@@ -68,12 +62,12 @@ elif command -v service >/dev/null 2>&1; then
|
||||
service smartdns restart
|
||||
elif command -v rc-service >/dev/null 2>&1; then
|
||||
rc-service smartdns restart
|
||||
elif command -v busybox >/dev/null 2>&1 && [ -d "/etc/init.d" ]; then
|
||||
elif [ -x "/etc/init.d/smartdns" ]; then
|
||||
/etc/init.d/smartdns restart
|
||||
else
|
||||
echo "Now please restart smartdns since I don't know how to do it."
|
||||
echo "Now please restart smartdns manually."
|
||||
fi
|
||||
|
||||
echo "Cleaning up..."
|
||||
rm -r "$WORKDIR"
|
||||
rm -rf "$WORKDIR"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user