Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstratacast <courthicks1@gmail.com>2017-09-25 10:30:41 +0300
committernachoparker <nacho@ownyourbits.com>2017-09-27 02:09:10 +0300
commit6ded3469593107810681e23608afd9c2fbe46140 (patch)
tree2a57e245eaa92158dbd7c040396baeead87a43fc
parentcde18420186c3ebf2fc2c10997a043eceb521960 (diff)
Create nc-duckdns.sh
Add script to handle DuckDNS
-rw-r--r--etc/nextcloudpi-config.d/nc-duckdns.sh77
1 files changed, 77 insertions, 0 deletions
diff --git a/etc/nextcloudpi-config.d/nc-duckdns.sh b/etc/nextcloudpi-config.d/nc-duckdns.sh
new file mode 100644
index 00000000..c53f4e60
--- /dev/null
+++ b/etc/nextcloudpi-config.d/nc-duckdns.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+# DuckDNS installation on Raspbian for NextcloudPi
+#
+#
+# Copyleft 2017 by Courtney Hicks
+# GPL licensed (see end of file) * Use at your own risk!
+#
+
+ACTIVE_=no
+DOMAIN_=yourduckdnsdomain
+TOKEN_=your-duckdns-token
+INSTALLDIR=duckdns
+INSTALLPATH=/etc/$INSTALLDIR
+CRONFILE=/etc/cron.d/duckdns
+DESCRIPTION="Free Dynamic DNS provider (need account from https://duckdns.org)"
+
+install() { :; }
+
+
+configure()
+{
+
+ if [[ $ACTIVE_ == "yes" ]]; then
+ mkdir $INSTALLPATH 2> /dev/null
+ # Creates duck.sh script that checks for updates to DNS records
+ touch $INSTALLPATH/duck.sh
+ touch $INSTALLPATH/duck.log
+ echo -e "echo url=\"https://www.duckdns.org/update?domains=$DOMAIN_&token=$TOKEN_&ip=\" | curl -k -o $INSTALLPATH/duck.log -K -" > $INSTALLPATH/duck.sh
+
+ # Adds file to cron to run script for DNS record updates and change permissions
+ touch $CRONFILE
+ echo "*/5 * * * * $INSTALLPATH/duck.sh >/dev/null 2>&1" > $CRONFILE
+ chmod 700 $INSTALLPATH/duck.sh
+ chmod +x $CRONFILE
+
+ # First-time execution of duck script
+ $INSTALLPATH/duck.sh > /dev/null 2>&1
+
+ SUCCESS=`cat $INSTALLPATH/duck.log`
+
+ # Checks for successful run of duck.sh
+ if [[ $SUCCESS == "OK" ]]; then
+ echo "DuckDNS is enabled"
+ elif [[ $SUCCESS == "KO" ]]; then
+ echo "DuckDNS install failed, is your information correct?"
+ fi
+
+ # Removes config files and cron job if ACTIVE_ is set to no
+ elif [[ $ACTIVE_ == "no" ]]; then
+ rm $CRONFILE 2> /dev/null
+ rm $INSTALLPATH/duck.sh 2> /dev/null
+ rm $INSTALLPATH/duck.log 2> /dev/null
+ rmdir $INSTALLPATH 2> /dev/null
+ echo "DuckDNS is now disabled"
+ fi
+}
+
+
+cleanup() { :; }
+
+# License
+#
+# This script is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This script is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this script; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA