#!/bin/sh #--------------------------------------------------------------------------- # /etc/rc.d/rc540.dyndns - write config for dyndns # part of Package DYNDNS __FLI4LVER__, see documentation for licence # # Copyright (c) 2001-2002 - Thomas Mueller # Copyright (c) 2002-2003 - Tobias Gruetzmacher # Copyright (c) 2003-2016 - fli4l-Team # # Created by: Thomas Mueller # Last change: $Id$ #---------------------------------------------------------------------------- case $OPT_DYNDNS in yes) begin_script DYNDNS "Setting up dynamic hostname configuration ..." [ "$DYNDNS_ALLOW_SSL" = yes ] && > /etc/dyndns/allow_ssl [ "$DYNDNS_DEBUG_PROVIDER" = yes ] && > /etc/dyndns/debug_provider [ "$DYNDNS_LOOKUP_NAMES" = yes ] && > /etc/dyndns/lookup_names # Write config > /etc/dyndns/dyndns.conf # Make the config (with the passwords!) only readable by root chmod 600 /etc/dyndns/dyndns.conf add_dyndns_crontab_entry= [ 0$DYNDNS_N -eq 0 ] || for idx in `seq 1 $DYNDNS_N`; do # get config entries for provider idx eval provider='$DYNDNS_'$idx'_PROVIDER' eval user='$DYNDNS_'$idx'_USER' eval pass='$DYNDNS_'$idx'_PASSWORD' eval host='$DYNDNS_'$idx'_HOSTNAME' eval circ='$DYNDNS_'$idx'_CIRCUIT' eval renew='$DYNDNS_'$idx'_RENEW' eval extip='$DYNDNS_'$idx'_EXT_IP' eval updatehost='$DYNDNS_'$idx'_UPDATEHOST' eval login='$DYNDNS_'$idx'_LOGIN' : ${extip:=no} : ${renew:=-} : ${login:=no} provider_file=/etc/dyndns/provider.$provider if [ ! -f $provider_file ]; then log_error "Invalid provider $provider: $provider_file is missing" continue fi sep= circuits= for c in $circ; do if [ -f /var/run/circuit-$c ]; then circuits="$circuits$sep$c" sep=, elif [ "static" = "$c" ]; then dev=`ip r s | sed -ne 's/^default[[:space:]].*\ /var/run/circuit-static circuits="static" else log_error "Invalid circuit '$c' for $host (DYNDNS_$idx), ignoring circuit" fi done if [ "$circuits" ]; then echo "$host $provider $circuits $user $pass $extip $renew $updatehost" >> /etc/dyndns/dyndns.conf else log_error "No valid circuit for $host (DYNDNS_$idx), ignoring entry" fi if [ "$login" = "yes" -a -z "$crontab_entry_added" ] then add_dyndns_crontab_entry=yes fi done if [ "$add_dyndns_crontab_entry" = "yes" -a -f /usr/local/bin/dyndns-login.sh ]; then add_crontab_entry "$DYNDNS_LOGINTIME" "/usr/local/bin/dyndns-login.sh" fi # Create directories for logging, history and registered IPs mkdir -p /var/log/dyndns /var/log/dyndns/history /var/run/dyndns chmod a+r /var/log/dyndns /var/log/dyndns/history if [ "$OPT_HTTPD$DYNDNS_SAVE_OUTPUT" = 'yesyes' ]; then httpd-menu.sh add -p 900 status_dyndns.cgi "DynDNS" '$_MT_stat' dyndns [ "$DYNDNS_DEBUG_PROVIDER" = yes ] && httpd-menu.sh add -p 910 'status_dyndns.cgi?action=debug_provider' "DynDNS-Debug" Debug dyndns fi end_script ;; esac