From f2c2dfc38a609cb87256688ff8b7dcf008a61f03 Mon Sep 17 00:00:00 2001 From: jonathan Date: Wed, 20 Nov 2019 07:39:19 +0000 Subject: [PATCH] First commit --- lp-ddns/usr/local/bin/lp-ddns | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 lp-ddns/usr/local/bin/lp-ddns diff --git a/lp-ddns/usr/local/bin/lp-ddns b/lp-ddns/usr/local/bin/lp-ddns new file mode 100755 index 0000000..20af78c --- /dev/null +++ b/lp-ddns/usr/local/bin/lp-ddns @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + + +RECORDID="28378" +PASSWORD="pass123" +DOMAIN="test.jonathanselea.se" + + + +# DO NOT MODIFY # +IP="$(curl -s ipv4.is)" +CURRENTIP="$(dig ${DOMAIN} +short)" +APIURL="https://freedns.linux.pizza/api/v1/remote/updatepw?record=${RECORDID}&password=${PASSWORD}&content=${IP}" +# Making stuff fancy +NC='\033[0m' +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +LCYAN='\033[0;37m' +YELLOW='\033[1;33m' +# END + + +echo -e "The current external IP is ${YELLOW}${IP}${NC}" + +if [ "${IP}" == "${CURRENTIP}" ]; +then + echo -e "${GREEN}The current IP matches the record, no need to update.${NC}" +else + echo -e "${RED}Current IP does not match the record ${CURRENTIP} updating...${NC}" + curl ${APIURL} +fi + +logger +sleep 300 + + +exit 0