Skip to content

Commit

Permalink
Convert install.sh from bash to posix shell
Browse files Browse the repository at this point in the history
  • Loading branch information
memoz authored and felixonmars committed Oct 24, 2024
1 parent 1b6046f commit 201ebe0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash
#!/bin/sh
set -e

WORKDIR="$(mktemp -d)"
SERVERS=(114.114.114.114 114.114.115.115 223.5.5.5 119.29.29.29)
SERVERS="114.114.114.114 114.114.115.115 223.5.5.5 119.29.29.29"
# 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

CONF_WITH_SERVERS=(accelerated-domains.china google.china apple.china)
CONF_SIMPLE=(bogus-nxdomain.china)
CONF_WITH_SERVERS="accelerated-domains.china google.china apple.china"
CONF_SIMPLE="bogus-nxdomain.china"

echo "Downloading latest configurations..."
git clone --depth=1 https://gitee.com/felixonmars/dnsmasq-china-list.git "$WORKDIR"
Expand All @@ -21,17 +21,17 @@ 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_SIMPLE[@]}"; do
for _conf in $CONF_WITH_SERVERS $CONF_SIMPLE; do
rm -f /etc/dnsmasq.d/"$_conf"*.conf
done

echo "Installing new configurations..."
for _conf in "${CONF_SIMPLE[@]}"; do
for _conf in $CONF_SIMPLE; do
cp "$WORKDIR/$_conf.conf" "/etc/dnsmasq.d/$_conf.conf"
done

for _server in "${SERVERS[@]}"; do
for _conf in "${CONF_WITH_SERVERS[@]}"; do
for _server in $SERVERS; do
for _conf in $CONF_WITH_SERVERS; do
cp "$WORKDIR/$_conf.conf" "/etc/dnsmasq.d/$_conf.$_server.conf"
done

Expand All @@ -45,7 +45,7 @@ elif hash service 2>/dev/null; then
service dnsmasq restart
elif hash rc-service 2>/dev/null; then
rc-service dnsmasq restart
elif hash busybox 2>/dev/null && [[ -d "/etc/init.d" ]]; then
elif hash busybox 2>/dev/null && [ -d "/etc/init.d" ]; then
/etc/init.d/dnsmasq restart
else
echo "Now please restart dnsmasq since I don't know how to do it."
Expand Down

0 comments on commit 201ebe0

Please sign in to comment.