Remove existing ddns provider when changing ddns settings

This commit is contained in:
Bob Mottram 2018-05-12 12:10:08 +01:00
parent a99c7200af
commit 9af6ffe895
1 changed files with 6 additions and 0 deletions

View File

@ -47,6 +47,10 @@ function update_inadyn_config {
fi
if ! grep -q "$DDNS_PROVIDER" /etc/inadyn.conf; then
# remove entry for any previous ddns
sed -i '/^system $/,$d' /etc/inadyn.conf
# add the new provider
{ echo '';
echo "system $DDNS_PROVIDER";
echo ' ssl';
@ -58,6 +62,7 @@ function update_inadyn_config {
echo " password $DDNS_PASSWORD" >> /etc/inadyn.conf
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
@ -65,6 +70,7 @@ function update_inadyn_config {
sed -i "s| password .*| password $DDNS_PASSWORD|g" /etc/inadyn.conf
fi
fi
systemctl enable inadyn
systemctl restart inadyn
}