From b347128ec569d57b25176c4625458b6fe4ad4845 Mon Sep 17 00:00:00 2001 From: CallMeR <9463297+callmer@user.noreply.gitee.com> Date: Sat, 9 Dec 2023 20:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/debian/debian_dns_smartdns_plugin.conf | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/debian/debian_dns_smartdns_plugin.conf b/src/debian/debian_dns_smartdns_plugin.conf index 35509c5..aa643cd 100644 --- a/src/debian/debian_dns_smartdns_plugin.conf +++ b/src/debian/debian_dns_smartdns_plugin.conf @@ -29,28 +29,28 @@ git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKD #git clone --depth=1 http://repo.or.cz/dnsmasq-china-list.git "$WORKDIR" echo "Removing old configurations..." -for conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do - rm -f /etc/smartdns.d/"$conf"*.conf +for _conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do + rm -f "$CONFIG_DIR"/"$_conf"*.conf done echo "Installing new configurations..." -for conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do - if [[ "${CONF_WITH_SERVERS[@]}" =~ $conf ]]; then - sed -En 's|^server=/([^/]*)/114.114.114.114$|\1|p' "$WORKDIR/$conf.conf" | grep -Ev '^#' > "$WORKDIR/$conf.step1.raw" - sed -En "s/(.*)/nameserver \\/\\1\\/${SERVERS_GROUP[@]}/p" "$WORKDIR/$conf.step1.raw" > "$WORKDIR/$conf.step2.raw" - cp "$WORKDIR/$conf.step2.raw" "/etc/smartdns.d/$conf.${SERVERS_GROUP[@]}.conf" +for _conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do + if [[ "${CONF_WITH_SERVERS[@]}" =~ $_conf ]]; then + sed -En 's|^server=/([^/]*)/114.114.114.114$|\1|p' "$WORKDIR/$_conf.conf" | grep -Ev '^#' > "$WORKDIR/$_conf.step1.raw" + sed -En "s/(.*)/nameserver \\/\\1\\/${SERVERS_GROUP[@]}/p" "$WORKDIR/$_conf.step1.raw" > "$WORKDIR/$_conf.step2.raw" + cp "$WORKDIR/$_conf.step2.raw" "$CONFIG_DIR/$_conf.${SERVERS_GROUP[@]}.conf" fi - if [[ "${CONF_WITH_GROUP[@]}" =~ $conf ]]; then - for server in "${SERVERS[@]}"; do - echo "server $server -group ${SERVERS_GROUP[@]} -exclude-default-group" >> "$WORKDIR/$conf.raw" + if [[ "${CONF_WITH_GROUP[@]}" =~ $_conf ]]; then + for _server in "${SERVERS[@]}"; do + echo "server $_server -group ${SERVERS_GROUP[@]} -exclude-default-group" >> "$WORKDIR/$_conf.raw" done - cp "$WORKDIR/$conf.raw" "/etc/smartdns.d/${CONF_WITH_GROUP[@]}.${SERVERS_GROUP[@]}.conf" + cp "$WORKDIR/$_conf.raw" "$CONFIG_DIR/${CONF_WITH_GROUP[@]}.${SERVERS_GROUP[@]}.conf" fi - if [[ "${CONF_SIMPLE[@]}" =~ $conf ]]; then - sed -e "s|=| |" "$WORKDIR/$conf.conf" > "$WORKDIR/$conf.raw" - cp "$WORKDIR/$conf.raw" "/etc/smartdns.d/$conf.${SERVERS_GROUP[@]}.conf" + if [[ "${CONF_SIMPLE[@]}" =~ $_conf ]]; then + sed -e "s|=| |" "$WORKDIR/$_conf.conf" > "$WORKDIR/$_conf.raw" + cp "$WORKDIR/$_conf.raw" "$CONFIG_DIR/$_conf.${SERVERS_GROUP[@]}.conf" fi done