From 112ff52ad329d026e05ae1eedc8be2605ce129ff Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 12 May 2018 12:20:29 +0100 Subject: [PATCH] Move function into dns utils --- src/freedombone-ddns | 46 --------------------------------------- src/freedombone-utils-dns | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/freedombone-ddns b/src/freedombone-ddns index 2bc33908..0cd6d9f6 100755 --- a/src/freedombone-ddns +++ b/src/freedombone-ddns @@ -38,52 +38,6 @@ DDNS_PROVIDER="none" DDNS_USERNAME= DDNS_PASSWORD= -function update_inadyn_config { - if [ ! -f /etc/inadyn.conf ]; then - return - fi - - if [[ "$DDNS_PROVIDER" == *'freedns'* ]]; then - return - fi - - if ! grep -q "$DDNS_PROVIDER" /etc/inadyn.conf; then - # store any previous aliases - grep 'alias ' /etc/inadyn.conf > /tmp/inadyn_aliases - - # remove entry for any previous ddns - sed -i '/system /,$d' /etc/inadyn.conf - - # add the new provider - { echo ''; - echo "system $DDNS_PROVIDER"; - echo ' ssl'; - echo " checkip-url $GET_IP_ADDRESS_URL /"; } >> /etc/inadyn.conf - if [ "$DDNS_USERNAME" ]; then - echo " username $DDNS_USERNAME" >> /etc/inadyn.conf - fi - if [ "$DDNS_PASSWORD" ]; then - echo " password $DDNS_PASSWORD" >> /etc/inadyn.conf - fi - - if [ -f /tmp/inadyn_aliases ]; then - cat /tmp/inadyn_aliases >> /etc/inadyn.conf - rm /tmp/inadyn_aliases - fi - else - # change username/password for an existing provider - if [ "$DDNS_USERNAME" ]; then - sed -i "s| username .*| username $DDNS_USERNAME|g" /etc/inadyn.conf - fi - if [ "$DDNS_PASSWORD" ]; then - sed -i "s| password .*| password $DDNS_PASSWORD|g" /etc/inadyn.conf - fi - fi - - systemctl enable inadyn - systemctl restart inadyn -} - function dynamic_dns_setup { DDNS_PROVIDER='none' diff --git a/src/freedombone-utils-dns b/src/freedombone-utils-dns index f33a4292..642f6446 100755 --- a/src/freedombone-utils-dns +++ b/src/freedombone-utils-dns @@ -94,6 +94,52 @@ EXTERNAL_IP_SERVICES=( \ 'http://ipinfo.io/' \ 'http://httpbin.org/ip') +function update_inadyn_config { + if [ ! -f /etc/inadyn.conf ]; then + return + fi + + if [[ "$DDNS_PROVIDER" == *'freedns'* ]]; then + return + fi + + if ! grep -q "$DDNS_PROVIDER" /etc/inadyn.conf; then + # store any previous aliases + grep 'alias ' /etc/inadyn.conf > /tmp/inadyn_aliases + + # remove entry for any previous ddns + sed -i '/system /,$d' /etc/inadyn.conf + + # add the new provider + { echo ''; + echo "system $DDNS_PROVIDER"; + echo ' ssl'; + echo " checkip-url $GET_IP_ADDRESS_URL /"; } >> /etc/inadyn.conf + if [ "$DDNS_USERNAME" ]; then + echo " username $DDNS_USERNAME" >> /etc/inadyn.conf + fi + if [ "$DDNS_PASSWORD" ]; then + echo " password $DDNS_PASSWORD" >> /etc/inadyn.conf + fi + + if [ -f /tmp/inadyn_aliases ]; then + cat /tmp/inadyn_aliases >> /etc/inadyn.conf + rm /tmp/inadyn_aliases + fi + else + # change username/password for an existing provider + if [ "$DDNS_USERNAME" ]; then + sed -i "s| username .*| username $DDNS_USERNAME|g" /etc/inadyn.conf + fi + if [ "$DDNS_PASSWORD" ]; then + sed -i "s| password .*| password $DDNS_PASSWORD|g" /etc/inadyn.conf + fi + fi + + systemctl enable inadyn + systemctl restart inadyn +} + function create_freedns_updater { if [[ $ONION_ONLY != "no" ]]; then return