Best directory for this script

View: New views
1 Messages — Rating Filter:   Alert me  

Best directory for this script

by David-153 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello folks,

I would like to know where I should place the script file seen at the
bottom page of this link

http://www.nslu2-linux.org/wiki/HowTo/SetUpYourOwnStaticLinkToYourSiteAtADynamicIP

here is the script
========================================================================
SRS 07/06/2008

#!/bin/ash

# Stan's UpDate IP to server remote Client for the Slug
# created by STAN, a variation of the 'DynDNSupdate' dnsupd script
# Use NO variables the same as the 'DynDNSupdate' dnsupd script
--important if might use the  'DynDNSupdate' script sometime(s)
# Version: 05/29/2008 SRS

# Look for ipnerr.ip
if [ ! -f /var/tmp/ipnerr.ip ]
then
# On ipnerr.ip not found.
  # Set up ipnerr.ip for error logging.
  echo "off" > /var/tmp/ipnerr.ip
fi
# Fetch current IP Address.
# can use any ip displayer site you please, -  http://....
/opt/bin/wget --quiet http://checkip.dyndns.com/ --timeout=3
--output-document=/var/tmp/ip.html;
# wget (line above) timeout to recieve site set to 3 seconds, change
if problems, originaly not in script line;not specified
# Verify the data is good.
# may need to alter or eliminate INPAT lines below if change
http://.... line above
IPNPAT='Current IP Address: *[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'
# TRY:  -         IPNPAT='[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' for line
above for a different http://.... site
#NOTE: the string IPNPAT='*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' does NOT
seem to work when tried with http://ipinfo.info
# (not advised) OR maybe use: -  if [ -f /var/tmp/ip.html ]  - for
line below if ELIMINATE both INPAT lines
if grep -q "$IPNPAT" /var/tmp/ip.html;
then
# On good IP data.
  # Check for IP history.
  if [ -f /var/tmp/ipnold.ip ]
  then
  # On history found.
    if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]
    then
      echo "`date +%Y%m%d.%H%M%S` - not updated: Network connection
restored." >> /var/log/ipnip_hist.log;
      # Turn ipnerr.ip Off
      echo "off" > /var/tmp/ipnerr.ip
    fi
    # Check for IP Change
    if [ "`cat /var/tmp/ip.html`" = "`cat /var/tmp/ipnold.ip`" ]
    then
    # On no IP change
      #

        # Check for Next day.
        if [ ! "`cat /var/tmp/ipnday.ip`" = "`date +%x`" ]
        then
        # On day change
          # Log entry
          echo "`date +%Y%m%d.%H%M%S` - No update -" >>
/var/log/ipnip_hist.log;
          echo "`date +%x`" > /var/tmp/ipnday.ip;
        fi

    else
    # On IP change
      # Update server with a new ip.
      ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com"
/"optionalsubdirectory(s)"/ /var/tmp/ip.html;
      # Log the IP change and notify user.
      echo "`date +%Y%m%d.%H%M%S` - update -" >> /var/log/ipnip_hist.log;
      echo "`date +%x`" > /var/tmp/ipnday.ip;
      rm -f /var/tmp/ipnold.ip;
      cp /var/tmp/ip.html /var/tmp/ipnold.ip;
#     Set_Led beep1
#     Set_Led beep1
#     Set_Led beep1
    fi
  else
  # On No History
    # Initialize client and Update IP to server.
    # Check ipnerr.ip status
    if [ "`cat /var/tmp/ipnerr.ip`" = "on" ]
    then
    # Log Service Restoral.
      echo "`date +%Y%m%d.%H%M%S` - not updated: Network connection
restored." >> /var/log/ipnip_hist.log;
    fi
    # Set ipnerr.ip off
    echo "off" > /var/tmp/ipnerr.ip
    ncftpput -u "yourusername" -p "yourpassword" "yourwebsite.com"
/"optionalsubdirectory(s)"/ /var/tmp/ip.html;
    echo "`date +%Y%m%d.%H%M%S` - initialization -" >>
/var/log/ipnip_hist.log;
    echo "`date +%x`" > /var/tmp/ipnday.ip;
    cp /var/tmp/ip.html /var/tmp/ipnold.ip;
  fi
else
# On IP read error
  # Check ipnerr.ip status
  if [ ! "`cat /var/tmp/ipnerr.ip`" = "on" ]
  then
  # On ipnerr.ip = off - Log read error.
    echo "`date +%Y%m%d.%H%M%S` - not updated: read error on ip fetch"
>> /var/log/ipnip_hist.log;
  fi
  # Set ipnerr.ip = On to allow only one error log on next run.
  echo "on" > /var/tmp/ipnerr.ip
  # Notify user.
# Set_Led beep2
fi
# end
# Set the interval of the next IP check using a crontab entry.
# Once every 15 minutes is good for a home server.


SRS 07/06/2008
==========================================================
Any help appreciated.

Regards,

David.


LightInTheBox - Buy quality products at wholesale price!