1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tug's Uptime Project on E2000

Discussion in 'DD-WRT Firmware' started by TommyN, Dec 2, 2011.

  1. TommyN

    TommyN Network Guru Member

    I'm trying to run Tug's Uptime Project on my Linksys E2000 loaded with DD-WRT v24 SP2 16785.
    I put in this code in custom script:

    Code:
    #!/bin/sh
    # **************=====================**************
    #        Tugs Uptime Project
    #        http://www.uptimeprj.com
    #
    #        LHLC : Linux Hyper Light Client
    #        Developer : Sebastien TUGS
    #        Developer : Daniel RAG3RAC3R
    #        Version 1.2 - February 2009
    # **************=====================**************
    
    # ----------------------- CONFIGURATION
    TUP_USERNAME=""
    TUP_PASSWORD=""
    TUP_MACHINE=""
    
    # -- Network
    TUP_INTERFACE=""
    
    # -- Proxy
    TUP_USEPROXY="0"
    TUP_PROXYNAME="192.168.1.1"
    TUP_PROXYPORT="8080"
    
    # -- This should be the same for all systems, but if not this setting exists
    IFCONFIG="/sbin/ifconfig"
    
    # -- Send extended info, and output more info, requires more Disk I/O
    TUP_XTRA_INFO="0"
    
    # -- Debug
    TUP_GODEBUG="0"
    
    # --------------------- CODE : Don't Modify anything after this point
    [[ -z "$TUP_INTERFACE" ]] && { echo "Please specify an interface in the config."; exit 1; }
    TUP_LHLC_VERSION="LHLC 1.2"
    TUP_SERVER="update.uptimeprj.com"
    
    # -------- Get Global Info
    TUPMacAddress=`$IFCONFIG $TUP_INTERFACE | awk -F ' ' '/(HWaddr)/ {print tolower($5) }'`
    TUPMacAddressMD5=`echo -n $TUPMacAddress | sed -e 's/://g' | md5sum | awk -F ' ' '{print $1}'`
    TUPUptime=`cat /proc/uptime | awk -F ' ' '{printf "%.0f\n",$1}'`
    [[ "$TUP_XTRA_INFO" == "1" || "$TUP_GODEBUG" == "1" ]] && { TUPCnb=`cat /proc/cpuinfo | grep processor | wc -l`; }
    
    TUPPlatformVersion=`uname -smr | awk -F ' ' '{printf "%s+%s+(%s)",$1,$2,$3}'`
    TUPDebugOPT="-s"
    
    # -------- Identify platform
    [[ -r "/etc/openwrt_version" ]] && { TUPPlatformName="openwrt"; }
    [[ -r "/etc/debian_release" ]] && { TUPPlatformName="debian"; }
    [[ -r "/etc/debian_version" ]] && { TUPPlatformName="debian"; }
    [[ -r "/etc/lsb-release" ]] && { TUPPlatformName="ubuntu"; }
    [[ -r "/etc/SuSE-release" ]] && { TUPPlatformName="suse"; }
    [[ -r "/etc/UnitedLinux-release" ]] && { TUPPlatformName="suse"; }
    [[ -r "/etc/gentoo-release" ]] && { TUPPlatformName="gentoo"; }
    [[ -r "/etc/redhat-release" ]] && { TUPPlatformName="redhat"; }
    [[ -r "/etc/redhat_version" ]] && { TUPPlatformName="redhat"; }
    [[ -r "/etc/fedora-release" ]] && { TUPPlatformName="fedora"; }
    [[ -r "/etc/slackware-release" ]] && { TUPPlatformName="slackware"; }
    [[ -r "/etc/slackware-version" ]] && { TUPPlatformName="slackware"; }
    [[ -r "/etc/mandrake-release" ]] && { TUPPlatformName="mandrake"; }
    [[ -r "/etc/mandriva-release" ]] && { TUPPlatformName="mandriva"; }
    [[ -z "$TUPPlatformName" ]] && { TUPPlatformName="linux"; }
    
    # ----------------- Do POST
    lhlcPOSTInfo="username=$TUP_USERNAME&pass=$TUP_PASSWORD&uptime=$TUPUptime&os=$TUPPlatformVersion&mac=$TUPMacAddressMD5&distrib=$TUPPlatformName&machine=$TUP_MACHINE&"
    lhlcTUPUrl="http://$TUP_SERVER/update.php?username=$TUP_USERNAME"
    
    # -- If Debug
    if [ "$TUP_GODEBUG" == "1" ]; then
        #clear
        echo "******* Entering Debug Mode *******"
        echo " Mac To Send : $TUPMacAddress (MD5: $TUPMacAddressMD5 ) /"
        echo " No of CPUs : $TUPCnb /"
        echo " Platform | Plaform name : ( $TUPPlatformVersion | $TUPPlatformName) /"
        echo " Uptime : ( $TUPUptime )"
        echo ""
        TUPDebugOPT="-v -o HTTPResp.log"
    fi
    
    if [ "$TUP_XTRA_INFO" == "1" ]; then
        lhlcPOSTInfo="$lhlcPOSTInfo&cnb=$TUPCnb&"
        logger -p cron.info -t TUP-LHLC "Reported $TUPUptime, $TUPPlatformVersion, $TUPPlatformName to UptimePrj.com"
    else
        lhlcPOSTInfo="$lhlcPOSTInfo&cnb=1&"
    fi
    
    # -- Do Curl
    if [ "$TUP_USEPROXY" == "1" ]; then
        curl -x $TUP_PROXYNAME:$TUP_PROXYPORT --data-ascii "$lhlcPOSTInfo" -A "$TUP_LHLC_VERSION" -0 -H "TUPMinorVersion: $TUP_LHLC_VERSION" $TUPDebugOPT $lhlcTUPUrl >/dev/null 2>&1
    else
        curl --data-ascii "$lhlcPOSTInfo" -A "$TUP_LHLC_VERSION" -0 -H "TUPMinorVersion: $TUP_LHLC_VERSION" $TUPDebugOPT $lhlcTUPUrl >/dev/null 2>&1
    fi
    exit 0
    
    To run it, I've set up a cronjob like this:

    Code:
    37 * * * * root sh /tmp/custom.sh
    So far so good, but it doesn't look like it sends the uptime info to uptimeprj.com
    I'm running the same code on my Synology NAS and it works, but I can't get it to work on the router.
    Have any of you guys any idea why it won't run?
     

Share This Page