Move function into dns utils

This commit is contained in:
Bob Mottram 2018-05-12 12:20:29 +01:00
parent 5ddf572037
commit 112ff52ad3
2 changed files with 46 additions and 46 deletions

View File

@ -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'

View File

@ -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