Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Support for duckdns #48

Merged
merged 3 commits into from
Sep 24, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions package/opt/hassbian/suites/install_duckdns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
function duckdns-show-short-info {
echo -e "Setup for Duck DNS auto renewal"
}

function duckdns-show-long-info {
echo -e "This script adds an cron job to auto uppdate you the WAN IP address for the defined domain."
}

function duckdns-show-copyright-info {
echo "Original consept by Ludeeus <https://github.com/ludeeus>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Concept

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

}

function duckdns-install-package {
duckdns-show-long-info
duckdns-show-copyright-info

echo
echo "Please take a moment to setup autorenewal of duckdns."
echo "If no choice is made the installation will exit."
echo
echo "(if your domain is 'example.duckdns.org' type example)"
echo -n "Domain: "
read domain
if [ ! "$domain" ]; then
exit
fi

echo -n "Token: "
read token
echo
if [ ! "$token" ]; then
exit
fi

echo "Changing back to homeassistant user..."
sudo -u homeassistant -H /bin/bash << EOF
cd

echo "Creating duckdns foler..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*folder

Copy link
Member Author

@ludeeus ludeeus Sep 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

mkdir duckdns
cd duckdns

echo "Creating a script file to be used by cron"
echo "echo url='https://www.duckdns.org/update?domains=$domain&token=$token&ip=' | curl -k -o ~/duckdns/duck.log -K -" > duck.sh

echo "Setting premissions..."
chmod 700 duck.sh

echo "Creating cron job..."
(crontab -l ; echo "*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1")| crontab -

echo "Changing back to root user..."
EOF

echo "Resarting cron service..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Restarting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

sudo systemctl restart cron.service

echo
echo "Installation done."
echo
echo "If you have issues with this script, please say something in the #Hassbian channel on Discord."
echo
return 0
}

# Make this script function as it always has if run standalone, rather than issue a warning and do nothing.
[[ $0 == "$BASH_SOURCE" ]] && duckdns-install-package