更新脚本变量

This commit is contained in:
CallMeR
2023-12-09 20:58:20 +08:00
parent 1e5a55de64
commit b347128ec5
+14 -14
View File
@@ -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