diff --git a/src/debian/debian_dns_smartdns_plugin.conf b/src/debian/debian_dns_smartdns_plugin.conf index 6803690..4f0a171 100644 --- a/src/debian/debian_dns_smartdns_plugin.conf +++ b/src/debian/debian_dns_smartdns_plugin.conf @@ -2,9 +2,9 @@ set -e WORKDIR="$(mktemp -d)" -CONFIG_DIR="/etc/smartdns.d" +CONFDIR="/etc/smartdns.d" SERVERS=(223.5.5.5 119.29.29.29 114.114.114.114 114.114.115.115) -SERVERS_GROUP=(accelerate) +GROUP=(accelerate) # Others: 223.6.6.6 119.28.28.28 # Not using best possible CDN pop: 1.2.4.8 210.2.4.8 # Broken?: 180.76.76.76 @@ -14,8 +14,8 @@ CONF_WITH_GROUP=(server-group.china) CONF_SIMPLE=(bogus-nxdomain.china) echo "Checking whether the configuration folder exists..." -if [ ! -d "$CONFIG_DIR" ]; then - mkdir -p "$CONFIG_DIR" +if [ ! -d "$CONFDIR" ]; then + mkdir -p "$CONFDIR" fi echo "Downloading latest configurations..." @@ -30,27 +30,27 @@ git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKD echo "Removing old configurations..." for _conf in "${CONF_WITH_SERVERS[@]}" "${CONF_WITH_GROUP[@]}" "${CONF_SIMPLE[@]}"; do - rm -f "$CONFIG_DIR/$_conf"*.conf + rm -f "$CONFDIR/$_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" "$CONFIG_DIR/$_conf.${SERVERS_GROUP[@]}.conf" + sed -En "s/(.*)/nameserver \\/\\1\\/${GROUP[@]}/p" "$WORKDIR/$_conf.step1.raw" > "$WORKDIR/$_conf.step2.raw" + cp "$WORKDIR/$_conf.step2.raw" "$CONFDIR/$_conf.${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" + echo "server $_server -group ${GROUP[@]} -exclude-default-group" >> "$WORKDIR/$_conf.raw" done - cp "$WORKDIR/$_conf.raw" "$CONFIG_DIR/${CONF_WITH_GROUP[@]}.${SERVERS_GROUP[@]}.conf" + cp "$WORKDIR/$_conf.raw" "$CONFDIR/${CONF_WITH_GROUP[@]}.${GROUP[@]}.conf" fi if [[ "${CONF_SIMPLE[@]}" =~ $_conf ]]; then sed -e "s|=| |" "$WORKDIR/$_conf.conf" > "$WORKDIR/$_conf.raw" - cp "$WORKDIR/$_conf.raw" "$CONFIG_DIR/$_conf.${SERVERS_GROUP[@]}.conf" + cp "$WORKDIR/$_conf.raw" "$CONFDIR/$_conf.${GROUP[@]}.conf" fi done