OpenWrt‎ > ‎

upgrade.sh

This script makes it easy to upload the openwrt firmware via TFTP
You can cut & past it or download from the link below

#!/bin/sh

TFTP="tftp"

usage()
{
echo
  echo "usage: `basename $0` <target ip address> file name/path"
  echo "       `basename $0` -h  - displays this message"
  echo
  exit 1
}

[ "$1" = "-h" ] && usage
[ "$#" != "2" ] && usage

target=$1
filename=$2

# does the filename exist
[ ! -r "${filename}" ] &&
{
  echo
  echo Please specify a valid filename/path
  usage
  exit 1
}

# extract the path bits
DIR=`dirname ${filename}`
FILE=`basename ${filename}`

# verify we have access to the tftp command
type ${TFTP} >/dev/null 2>&1
[ "$?" != 0 ] &&
{
  echo
  echo The tftp commad cannot be found - please install tftp
  echo if debian run \"sudo apt-get install tftp\"
    echo
  exit 1
}

# All good so now do it
cd ${DIR}

echo "Restart you device - you have 60 seconds ..."

{
#  echo verbose
  echo rexmt 1
  echo timeout 60
  echo binary
  echo trace
  echo put ${FILE}
  echo quit
} | tftp ${target}


ċ
upload.sh
(1k)
Chris Martin,
3 Jun 2010, 20:50