Skip to content
Snippets Groups Projects
Commit 112ff52a authored by Bob Mottram's avatar Bob Mottram
Browse files

Move function into dns utils

parent 5ddf5720
No related branches found
No related tags found
No related merge requests found
......@@ -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'
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment