Talk DDNSupdater Fehlermeldung

Dieses Thema im Forum "Alles rund um Dyndns" wurde erstellt von kirseb, 26. September 2012.

  1. kirseb
    Offline

    kirseb Ist oft hier

    Registriert:
    2. April 2011
    Beiträge:
    138
    Zustimmungen:
    56
    Punkte für Erfolge:
    28
    Hallo,

    möchte auf meinem Debian 2 dyndns einrichten mit no-ip

    bekomme folgende Fehlermeldung mit ddns help:
    /sbin/ddns: Zeile 92: Syntaxfehler beim unerwarteten Wort `('
    /sbin/ddns: Zeile 92: `ReturnCodes["badagent"]="The user agent was not sent or HTTP method is not permitted (we recommend use of GET request method)."'

    meine DDNSupdater2.sh
    #!/bin/bash
    #
    # DynamicDNSupdater - supports: DynDNS.org, NO-IP.com, DYNServ.ca and IPActive.de
    #
    # Es koennen auch verschiedene Dienste genutzt werden um mehrere DNS-Hosts zu nutzen...
    #
    # Sonderzeichen im Password werden nun auch supported (danke IDDQD)
    #
    # credits: Didge2002, SnowHead, r00t, rj.2001, IDDQD
    #
    ### CONFIG - START

    # Zugangsdaten...
    # es koennen mehrere accounts geupdated werden... (rest auskommentieren)
    USERNAME["1"]="user1" # DDNS Benutzername1
    PASSWORD["1"]="pw1" # DDNS Passwort1
    DDNSHOST["1"]="xxx1.xxx1.xxx1.com # DDNS Hostname1

    USERNAME["2"]="user2" # DDNS Benutzername2
    PASSWORD["2"]="pw2" # DDNS Passwort2
    DDNSHOST["2"]="xxx2.xxx2.xxx2.com" # DDNS Hostname2

    #USERNAME["3"]="benutzer3" # DDNS Benutzername3
    #PASSWORD["3"]="password3" # DDNS Passwort3
    #DDNSHOST["3"]="host3.dyndns.org" # DDNS Hostname3
    #

    # Provider URL's - pro DDNSHOST muss wie oben ein dazu passendes URL["<zahl>"] angelegt werden!
    # (beliebig erweiterbar)
    #
    # $USERNAME , $PASSWORD , $DDNSHOST werden innerhalb der URL mit %USER% , %PASS% , %HOST% angegeben!
    #
    URL["1"]="http://dynupdate.no-ip.com/dns?username=%USER%&password=%PASS%&hostname=%HOST%"
    URL["2"]="http://dynupdate.no-ip.com/dns?username=%USER%&password=%PASS%&hostname=%HOST%"
    #URL["3"]="http://%USER%:%PASS%@members.dyndns.org/nic/update?hostname=%HOST%"
    #
    # BEISPIEL URL's
    #
    # DynDNS.org: "http://%USER%:%PASS%@members.dyndns.org/nic/update?hostname=%HOST%"
    # No-IP.com: "http://dynupdate.no-ip.com/dns?username=%USER%&password=%PASS%&hostname=%HOST%"
    # DYNServ.ca: "http://dynserv.ca/dyn/dynengine.cgi?name=%USER%&pass=%PASS%&func=set&domain=%HOST%"
    # IPActive.de: "http://logon.ipactive.de/cgi-bin/logon_off.pl?V=2.1&B=%USER%&P=%PASS%&IP=%HOST%&F=1"
    # two-dns.de: "http://%USER%:%PASS%@update.two-dns.de/update?hostname=%HOST%"

    EVERY="300" # Zeit in Sekunden zwischen den Abfragen
    LOG="1" # Erstelle Logfile vom update? [0=nein; 1=ja]

    # Verschicke EMail bei Problemen? [no=nein; yes=ja]
    # ( benoetigt: apt-get install sendEmail )
    EMAIL="no"
    EMAILFROM="`hostname`@fqdn.net"
    EMAILTO='admin@fqdn.net'
    EMAILSERVER='mail.fqdn.net'
    EMAILUSER=''
    EMAILPASS=''


    ### CONFIG - END

    # -------------------------------------------------------------- #
    # >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
    # -------------------------------------------------------------- #


    # required system cmd's:
    # basename cat cut date echo expr killall ping rm sed sleep wget

    Osrcn="DDNSupdater2.sh"
    srcn=$(basename $0)
    srcv="2.25"
    srccfg="config.$Osrcn"
    LOGFILE="/var/log/log.$Osrcn"
    CHKFILE="/tmp/.$Osrcn"
    PiDFILE="/tmp/.pid.$Osrcn"
    OnlinePing="google.de"
    ProfileSwitchSleep=2
    IPCcfgdir="/var/emu/conf"
    IPCfunctions="/var/emu/script/functions.sh"
    IPCddnssrc="/var/emu/script/$Osrcn"
    IPCddnslinkname="ddns"

    C="\033[";Ca="${C}0;33m";Cb="${C}1;33m";Cn="${C}0m";ROT="${C}1;31m";GRUEN="${C}1;32m";BOLD="${C}1;37m"
    Bo="${C}1m";Bc="${C}21m"; Ro="${C}3m";Rc="${C}23m"; Uo="${C}4m";Uc="${C}24m"
    Blo="${C}5m";Blc="${C}25m"; Io="${C}7m";Ic="${C}27m"

    ## Return Codes
    declare -A ReturnCodes
    ReturnCodes["good"]="DNS hostname update successful."
    ReturnCodes["nochg"]="IP address is current, no update performed."
    ReturnCodes["nohost"]="Hostname supplied does not exist under specified account."
    ReturnCodes["badauth"]="Invalid username password combination."
    ReturnCodes["badagent"]="The user agent was not sent or HTTP method is not permitted (we recommend use of GET request method)."
    ReturnCodes["!donator"]="An option available only to credited users (such as offline URL) was specified, but the user is not a credited user."
    ReturnCodes["abuse"]="The hostname specified is blocked for update abuse."
    ReturnCodes["911"]="A fatal error on our side such as a database outage. Retry the update no sooner 30 minutes."
    ReturnCodes["notfqdn"]="The hostname specified is not a fully-qualified domain name (not in the form hostname.dyndns.org or domain.com)."
    ReturnCodes["0"]="IP address is current, no update performed."
    ReturnCodes["1"]="Update successful."
    ReturnCodes["2"]="Hostname supplied does not exist under specified account."
    ReturnCodes["3"]="Invalid password."
    ReturnCodes["4"]="Invalid username."

    function AddonInstalled () {
    [ ! -z "$AddOnInfos" ] && echo "ok" > /tmp/.AddonInstalled_$(basename $0)
    }

    function remove_addon () {
    #onlinescript als addon entfernen
    if [ ! -z "$AddOnInfos" ]&&[ -f "$AddOnInfos" ]; then
    Anum=$(sed -ne "/^$(basename $0).*/=" $AddOnInfos)
    [ ! -z "$Anum" ] && sed -i -e "$Anum d" $AddOnInfos
    fi
    }

    if [ -f "$IPCfunctions" -a ! -f "/sbin/$IPCddnslinkname" ]; then
    echo ".. $srcn v$srcv .."
    echo "Erstbenutzung dieses Scripts? IPC erkannt... kopiere Script $srcn..."
    cp -f $0 $IPCddnssrc ; chmod 755 $IPCddnssrc >/dev/null 2>&1
    echo -e "\nErstelle Symlink fuer ${Ro}$IPCddnslinkname${Rc} auf $IPCddnssrc"
    ln -sf $IPCddnssrc /sbin/$IPCddnslinkname
    echo -e "Nun muss noch der ${Ro}CONFIG${Rc} Abschnitt in dem Script $srcn angepasst werden!"
    sleep 3
    nano -R $IPCddnssrc
    #[ ! -f "$IPCcfgdir/$srccfg" ] && proc_Create_Script_CFG "$IPCcfgdir/$srccfg"
    echo -e "Fertig! Das Script kann kuenftig ueber den Befehl ${Ro}$IPCddnslinkname${Rc} ausgefuehrt werden"
    AddonInstalled
    $IPCddnssrc help
    exit
    fi

    # load script config?
    [ -d "$IPCcfgdir" -a -f "$IPCcfgdir/$srccfg" ] && source $IPCcfgdir/$srccfg
    [ ! -d "$IPCcfgdir" -a -f "$srccfg" ] && source $srccfg

    # Verschicke EMail..
    function send_EMail() {
    MESSAGE=$1
    SUBJECT="$Osrcn"
    if [ $EMAIL = "yes" -o $EMAIL = "1" ]; then
    echo "Verschicke EMail.."
    sendEmail -f $EMAILFROM -t $EMAILTO -u "$SUBJECT" -m "$MESSAGE" -s $EMAILSERVER -xu "$EMAILUSER" -xp "$EMAILPASS"
    fi
    }

    # Simple URL encoding
    function proc_url_encode() {
    out=${1//%/%25}; out=${out//\{/%7B}; out=${out//\}/%7D}; out=${out//|/%7C};
    out=${out//\\/%5C}; out=${out//^/%5E}; out=${out//~/%7E}; out=${out//[/%5B};
    out=${out//]/%5D}; out=${out//\`/%60}; out=${out//#/%23}; out=${out//>/%3E};
    out=${out//\$/%24}; out=${out//&/%26}; out=${out//+/%2B}; out=${out//,/%2C};
    out=${out//\//%2F}; out=${out//:/%3A}; out=${out//;/%3B}; out=${out//=/%3B};
    out=${out//\?/%3F}; out=${out// /%20}; out=${out//</%3C};
    out=${out//\!/%21}; out=${out//\"/%22}; out=${out//\@/%40}; out=${out//\'/%27};
    out=${out//\(/%28}; out=${out//\)/%29}; out=${out//\*/%2A}; out=${out//\-/%2D};
    out=${out//\_/%5F}; out=${out//\./%2E}; out=${out//\€/%80};
    echo $out
    }

    function LOG_msg() {
    message=$1
    if [ $LOG = "1" ]; then
    _DT=$(date +"%d.%m.%Y %H:%M:%S")
    echo "$_DT: $message" >> $LOGFILE
    fi
    }

    function ReturnCode () {
    for index in ${!ReturnCodes
    [*]}; do
    [ "$index" == "$1" ] && echo "${ReturnCodes[$1]}" && break
    done
    }

    function abuse_check() {
    index=$1
    answer=$(cat ${CHKFILE}_answer_$index)
    MSG=""
    if [ "$answer" = "abuse" ]; then
    MSG="WARNING!! You abused the DNS update function! You must Unlock your hostname: ${DDNSHOST[$index]} !"
    fi
    [ "$answer" = "nohost" ] && MSG="ERROR: Unknown host ${DDNSHOST[$index]} !"
    [ "$answer" = "badauth" ] && MSG="ERROR: Bad auth! Check USERNAME and PASSWORD setting for ${DDNSHOST[$index]} !"
    if [ ! -z "$MSG" ]; then
    echo "$MSG"
    LOG_msg "$MSG"
    send_EMail "$MSG"
    fi
    }

    function get_IPs() {
    CURRENTIP=""
    # get current internet ip
    CURRENTIP=$(wget -q -O - Du mußt dich Registrieren um diesen Link sehen zu können. Hier klicken und kostenlos Registrieren)
    if [ -z "$CURRENTIP" -o "$CURRENTIP" = " *" -o "$CURRENTIP" = "*1.0 *" ]; then
    CURRENTIP=$(wget -q -O - Du mußt dich Registrieren um diesen Link sehen zu können. Hier klicken und kostenlos Registrieren)
    fi
    if [ -z "$CURRENTIP" -o "$CURRENTIP" = " *" -o "$CURRENTIP" = "*1.0 *" ]; then
    CURRENTIP=$(wget -q -O - Du mußt dich Registrieren um diesen Link sehen zu können. Hier klicken und kostenlos Registrieren | grep "IP Address" | cut -d ' ' -f4 | sed -e 's/\$//g' -e 's/\\r//g')
    fi
    if [ -z "$CURRENTIP" -o "$CURRENTIP" = " *" -o "$CURRENTIP" = "*1.0 *" ]; then
    CURRENTIP=$(wget -q -O - Du mußt dich Registrieren um diesen Link sehen zu können. Hier klicken und kostenlos Registrieren | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>')
    fi
    if [ -z "$CURRENTIP" -o "$CURRENTIP" = " *" -o "$CURRENTIP" = "*1.0 *" ]; then
    CURRENTIP=$(wget -q -O - Du mußt dich Registrieren um diesen Link sehen zu können. Hier klicken und kostenlos Registrieren | sed s/[^0-9.]//g)
    fi
    if [ -z "$CURRENTIP" -o "$CURRENTIP" = " *" -o "$CURRENTIP" = "*1.0 *" ]; then
    CURRENTIP=$(wget -q -O - Du mußt dich Registrieren um diesen Link sehen zu können. Hier klicken und kostenlos Registrieren | grep "IP Address" | cut -d ' ' -f4 | sed -e 's/\$//g' -e 's/\\r//g')
    fi
    if [ -z "$CURRENTIP" ]; then
    eRROR["0"]="Cant get current internet ip"
    else
    # get current dyndns ip
    for index in ${!DDNSHOST
    [*]}; do
    #DYNIP[$index]=$(nslookup ${DDNSHOST[$index]} | tail -n2 | grep A | sed s/[^0-9.]//g)
    DYNIP[$index]=$(ping -c1 "${DDNSHOST[$index]}" | sed -n 1p | sed -e 's/(//g' -e 's/)//g' | cut -d " " -f3 | sed -e 's/\://g')
    [ -z "${DYNIP[$index]}" ] && eRROR[$index]="Cant get IP of DDNSHOST: ${DDNSHOST[$index]}"
    done
    fi
    }

    # answer return codes: 1=ip.updated ; 3=wrong.pwd ; 4=wrong.username
    function do_update() {
    index=$1
    # Replace %USER% , %PASS% , %HOST%
    URL=${URL[$index]}
    URL=${URL//%USER%/`proc_url_encode "${USERNAME[$index]}"`}
    URL=${URL//%PASS%/`proc_url_encode "${PASSWORD[$index]}"`}
    URL=${URL//%HOST%/${DDNSHOST[$index]}}
    wget -q -O ${CHKFILE}_answer_$index $URL
    answer=$(cat ${CHKFILE}_answer_$index)
    echo "DDNSHOST: ${DDNSHOST[$index]} - DYNIP: ${DYNIP[$index]} - CURRENTIP: $CURRENTIP - answer: $answer"
    LOG_msg "DDNSHOST: ${DDNSHOST[$index]} - DYNIP: ${DYNIP[$index]} - CURRENTIP: $CURRENTIP - answer: $answer"
    }

    # fuer jedes "profil" (DDNSHOST) die jeweilige "action" abarbeiten (function-names)
    function check_profils() {
    ACTION=$1
    eRROR=""
    get_IPs
    for index in ${!DDNSHOST
    [*]}; do
    if [ -z "$eRROR" ]; then
    # for each $ACTION...
    if [ ! -z "$ACTION" ]; then
    for actionfunction in $ACTION; do
    $actionfunction "$index"
    done
    fi
    fi
    sleep $ProfileSwitchSleep
    done
    [ ! -z "$eRROR" ] && for Eidx in ${!eRROR
    [*]}; do echo "${eRROR[$Eidx]}"; done
    }

    function update_interval() {
    PiDs="$$ $!"
    echo $PiDs > $PiDFILE
    echo "Running Script in Background with PID(s): $PiDs"
    while true; do
    [ ! -f "$PiDFILE" ] && echo "$srcn: Interval stopped" && break
    # check if online...
    ONLINE=0
    [ "$(ping -c1 "$OnlinePing" | grep -c "seq")" -eq 1 ] && ONLINE=1
    # if online, check each DDNSHOST (array)...
    if [ "$ONLINE" ]; then
    get_IPs
    for index in ${!DDNSHOST
    [*]}; do
    [ "${DYNIP[$index]}" != "$CURRENTIP" ] && do_update "$index" && abuse_check "$index"
    done
    fi
    if [ ! -z "$eRROR" ]; then
    Error=""
    for Eidx in ${!eRROR
    [*]}; do
    Error="$Error ${eRROR[$Eidx]}\n"
    done
    echo -e "$Error" && LOG_msg "$Error" && send_EMail "$Error"
    eRROR=""
    fi
    sleep $EVERY
    done
    }

    function show_status() {
    get_IPs
    for index in ${!DDNSHOST
    [*]}; do
    if [ "${DYNIP[$index]}" != "$CURRENTIP" ]; then
    echo "The IP of ${DDNSHOST[$index]} (${DYNIP[$index]}) does NOT match your current Internet-IP: $CURRENTIP"
    echo "You should update immediately! (with: $0 now)"
    else
    echo "Your host ${DDNSHOST[$index]} with IP ${DYNIP[$index]} is still up to date: $CURRENTIP"
    if [ -f "${CHKFILE}_answer_$index" ]; then
    answer=$(cat ${CHKFILE}_answer_$index)
    echo -e "Last Answer was: $answer \t $(ReturnCode "$(echo $answer|sed -e s/.*://)")"
    fi
    fi
    echo " "
    done
    [ -f "$PiDFILE" ] && echo "Script seems to run in background with PID(s): $(cat $PiDFILE)"
    }

    function kill_script() {
    counter="5"
    [ -f "$PiDFILE" ] && PID=$(cat $PiDFILE)
    #[ -z "$PID" ] && PID="$$ $!"
    if [ ! -z "$PID" ]; then
    echo "PID(s): $PID"
    echo -n "Stopping Script"
    if ( kill -TERM $PID 2> /dev/null ); then
    c=1
    while [ "$c" -le 300 ]; do
    if ( kill -0 $PID 2> /dev/null ); then
    echo -n "."
    sleep 1
    else
    break
    fi
    c=$((++c))
    done
    fi
    if ( kill -0 $PID 2> /dev/null ); then
    echo -e "\rScript is not shutting down cleanly - killing"
    kill -KILL $PID
    else
    echo " done"
    fi
    #for P in $PID; do
    # kill -9 $P >/dev/null 2>&1
    # echo "Killed PID $P"
    #done
    killall -9 $IPCddnslinkname $srcn >/dev/null 2>&1
    else
    echo "Nothing to $1!"
    fi
    rm -f $PiDFILE
    }

    function echo_PIDs() {
    [ -f "$PiDFILE" ] && PID=$(cat $PiDFILE)
    [ -z "$PID" ] && PID="$$ $!"
    if [ -z "$PID" ]; then
    echo "Seems script isnt running in background"
    else
    echo "Scripts currently ProcessIDs: $PID"
    fi
    }


    if [ -f "$IPCfunctions" -a -f "$IPCddnssrc" ]; then
    linkname=$IPCddnslinkname
    else
    linkname=$0
    fi

    case "$1" in
    "")
    update_interval &
    ;;
    [aA][uU][tT][oO]|[sS][tT][aA][rR][tT])
    bash $0 & >/dev/null 2>&1
    ;;
    [kK][iI][lL][lL]|[sS][tT][oO][pP])
    kill_script $1
    ;;
    [nN][oO][wW])
    check_profils "do_update abuse_check"
    ;;
    [pP][iI][dD]*)
    echo_PIDs
    ;;
    [sS][tT][aA][tT][uU][sS])
    show_status
    ;;
    [hH][eE][lL][pP]|[hH][iI][lL][fF][eE]|?)
    echo "Usage: $linkname [now|auto|kill|status|pid|help]"
    echo "$linkname now -> Force to update DDNSHOST immediately (erzwinge sofortiges updaten von DDNSHOST)"
    echo "$linkname auto -> Checks/updates DDNSHOST every $EVERY seconds (Ueberprueft/updated DDNSHOST alle $EVERY Sekunden)"
    echo "$linkname kill -> Kills running script (Script wird beendet)"
    echo "$linkname status -> Show current DDNSHOSTs status (Zeigt den aktuellen Status, ob ein update noetig ist)"
    echo "$linkname pid -> Show Process IDs (Zeigt die verwendeten ProzessIDs dieses Scripts)"
    echo "$linkname deinstall -> Deinstalls Script (Deinstalliert das Script)"
    echo "$linkname help -> This help... (Zeigt diese Hilfe...)"
    ;;
    [dD][eE][iI][nN][sS]*)
    rm -f $IPCddnssrc /sbin/$IPCddnslinkname
    remove_addon
    echo "Script deinstalled!"
    ;;
    *)
    echo "Usage: $linkname [now|auto|kill|status|pid|help]"
    ;;
    esac

    exit 0
     
    #1

Diese Seite empfehlen

OK Mehr information

Diese Seite verwendet Cookies. Mit Ihrem Klick auf OK stimmen Sie der Verwendung von Cookies zu. Andernfalls ist die Funktionalität dieser Website beschränkt.