diff options
| author | Stuart Cardall <developer@it-offshore.co.uk> | 2016-01-22 03:12:56 +0000 |
|---|---|---|
| committer | Natanael Copa <ncopa@alpinelinux.org> | 2016-01-22 19:18:59 +0000 |
| commit | 0c36c24fe36254f81d79e90c5025c801458ccef4 (patch) | |
| tree | 71464e18c826e300e57f86a4eea2ca2625419688 /testing/dnscrypt-proxy/dnscrypt-proxy.setup | |
| parent | 3d541bc87eb551bcfa738fdf8251faa91a494a3a (diff) | |
| download | aports-0c36c24fe36254f81d79e90c5025c801458ccef4.tar.bz2 aports-0c36c24fe36254f81d79e90c5025c801458ccef4.tar.xz | |
testing/dnscrypt-proxy: fix /sbin/setup-dnscrypt
small fix for tail in coreutils + clean some whitespace.
Diffstat (limited to 'testing/dnscrypt-proxy/dnscrypt-proxy.setup')
| -rw-r--r-- | testing/dnscrypt-proxy/dnscrypt-proxy.setup | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/testing/dnscrypt-proxy/dnscrypt-proxy.setup b/testing/dnscrypt-proxy/dnscrypt-proxy.setup index 9bb0e72b36..c1a028c3d3 100644 --- a/testing/dnscrypt-proxy/dnscrypt-proxy.setup +++ b/testing/dnscrypt-proxy/dnscrypt-proxy.setup @@ -53,10 +53,10 @@ do export RESTART_CLEAN="`echo "${RESTART}" | tr -cd '[:[alnum]:]'`" if [ ! $RESTART ] ;then - RESTART_CLEAN=eth0 + RESTART_CLEAN=eth0 fi - # tr will strip invalid input to nothing which passes grep + # tr will strip invalid input to nothing which passes grep if [ "$RESTART_CLEAN" != "" ] && echo "$INTERFACES" | grep -e "$RESTART_CLEAN" 1>/dev/null; then break else @@ -111,14 +111,14 @@ do # Sanitize input to an integer and assign to new variable export DNSPORT_CLEAN="`echo "${DNSPORT}" | tr -cd '[:[0-9]:]'`" if [ ! $DNSPORT ]; then - DNSPORT_CLEAN=$defaultport + DNSPORT_CLEAN=$defaultport fi if [ $DNSPORT_CLEAN -gt 0 2>/dev/null ] && [ $DNSPORT_CLEAN -le 65535 2>/dev/null ]; then print_green "\nPort: $DNSPORT_CLEAN Selected"; break else #move the cursor & clear the line - echo -en "\033[1A\033[39C\033[K" + echo -en "\033[1A\033[39C\033[K" fi done } @@ -220,33 +220,31 @@ output='/tmp/dnscrypt.list' echo -e "Retrieving current list of free DNS Resolvers\n" wget -q --no-check-certificate $url -O $output +sed -i 's|\"||g' $output -totalservers=$(cat $output | tail +2 | wc -l) +totalservers=$(cat $output | tail -n +2 | wc -l) if [ $totalservers = 0 ]; then die "Could not contact $url" fi -#clear - # colour table ################################################################################## -colourheading=$(awk 'BEGIN { format = "%-8s%-40s%-18s%-10s%-10s%-10s%-25s\n" +colourheading=$(awk 'BEGIN { format = "%-8s%-35s%-30s%-10s%-10s%-10s%-25s\n" printf format, "#", "Name", "Location", "DNSSEC", "No Logs", "Namecoin", "Resolver Address" }') -colourline=$(awk 'BEGIN { format = "%-8s%-40s%-18s%-10s%-10s%-10s%-25s\n" - printf format, "---", "----------------------------------------", "------------------", "----------",\ - "----------", "----------", "------------------------------------------" }') +colourline=$(awk 'BEGIN { format = "%-8s%-35s%-30s%-10s%-10s%-10s%-25s\n" + printf format, "----", "----------------------------------------", "------------------------------", "----------",\ + "----------", "----------", "-----------------------------------" }') print_green "$colourheading" print_green "$colourline" -sed -i -e "s/..$//g" $output tmpfile=$(mktemp) -cat $output | awk 'BEGIN{FS=""}{gsub(/,\ /,"\ "); print}'|tail +2 > $tmpfile +cat $output | awk 'BEGIN{FS=""}{gsub(/,\ /,"\ "); print}' | tail -n +2 > $tmpfile -awk -F"\," 'BEGIN {format="%-8s%-40s%-18s%-10s%-10s%-10s%-25s\n"}{ printf format, "\["NR"\]",$1,$4,$8,$9,$10,$11}' $tmpfile +awk -F"\," 'BEGIN {format="%-8s%-35s%-30s%-10s%-10s%-10s%-25s\n"}{ printf format, "\["NR"\]",$1,$4,$8,$9,$10,$11}' $tmpfile print_green "$colourline" print_question "Please choose a DNS Resolver for dnscrypt-proxy to query:" "[1 - $totalservers]" @@ -255,19 +253,16 @@ print_question "Please choose a DNS Resolver for dnscrypt-proxy to query:" "[1 - while : do + read DNS + # Sanitize input to an integer + export DNS_CLEAN="`echo "${DNS}" | tr -cd '[:[0-9]:]'`" -read DNS - -# Sanitize input to an integer -export DNS_CLEAN="`echo "${DNS}" | tr -cd '[:[0-9]:]'`" - -if [ $DNS_CLEAN -gt 0 2>/dev/null ] && [ $DNS_CLEAN -le $totalservers 2>/dev/null ]; then - break -else - #move the cursor & clear the line - echo -en "\033[1A\033[67C\033[K" -fi - + if [ $DNS_CLEAN -gt 0 2>/dev/null ] && [ $DNS_CLEAN -le $totalservers 2>/dev/null ]; then + break + else + #move the cursor & clear the line + echo -en "\033[1A\033[67C\033[K" + fi done RESOLVER=$(cat $tmpfile | tr -d "\"" | tr "," ";" | sed -n "$DNS_CLEAN"p |awk -F';' '{print $11}') @@ -284,7 +279,7 @@ fi # remove existing Resolver config if grep "RESOLVER" $config 1> /dev/null; then - sed -e '/RESOLVER/d' -e '/PROVIDER/d' -e '/PUBKEY/d' $config -i + sed -e '/RESOLVER/d' -e '/PROVIDER/d' -e '/PUBKEY/d' $config -i fi # update Resolver config @@ -301,13 +296,13 @@ print_green "------------------------------------------------------------------- # install unbound if ! which unbound 1> /dev/null; then - print_question "Install Unbound (Caching DNS Server)" "[ Y / N: Default ]" - read installsrv - if [ "$(echo $installsrv | tr '[A-Z]' '[a-z]')" = "y" ]; then - apk add -q unbound - else - echo "nameserver 127.0.0.1" > /etc/resolv.conf - fi + print_question "Install Unbound (Caching DNS Server)" "[ Y / N: Default ]" + read installsrv + if [ "$(echo $installsrv | tr '[A-Z]' '[a-z]')" = "y" ]; then + apk add -q unbound + else + echo "nameserver 127.0.0.1" > /etc/resolv.conf + fi fi # check for / setup secondary loopback for dns caching @@ -321,7 +316,7 @@ if which unbound 1> /dev/null && ! grep "address 127.0.0.2" /etc/network/interfa ifconfig lo:1 $IP up fi -# modify caching +# modify caching if grep "address 127.0.0.2" /etc/network/interfaces 1> /dev/null && [ ! $installsrv ]; then print_question "\nRemove DNS Caching (Unbound) / Secondary loopback device ?" "[ Y / N: Default ]"; read removecache if [ "$(echo $removecache | tr '[A-Z]' '[a-z]')" = "y" ]; then @@ -356,3 +351,4 @@ fi restart_services exit 0 + |
