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 fi
if ! grep -q "$DDNS_PROVIDER" /etc/inadyn.conf; then 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 '';
echo "system $DDNS_PROVIDER"; echo "system $DDNS_PROVIDER";
echo ' ssl'; echo ' ssl';
@ -58,6 +62,7 @@ function update_inadyn_config {
echo " password $DDNS_PASSWORD" >> /etc/inadyn.conf echo " password $DDNS_PASSWORD" >> /etc/inadyn.conf
fi fi
else else
# change username/password for an existing provider
if [ "$DDNS_USERNAME" ]; then if [ "$DDNS_USERNAME" ]; then
sed -i "s| username .*| username $DDNS_USERNAME|g" /etc/inadyn.conf sed -i "s| username .*| username $DDNS_USERNAME|g" /etc/inadyn.conf
fi fi
@ -65,6 +70,7 @@ function update_inadyn_config {
sed -i "s| password .*| password $DDNS_PASSWORD|g" /etc/inadyn.conf sed -i "s| password .*| password $DDNS_PASSWORD|g" /etc/inadyn.conf
fi fi
fi fi
systemctl enable inadyn systemctl enable inadyn
systemctl restart inadyn systemctl restart inadyn
} }