ti_tftp by mforce

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.4 kB
7
Indexable
Never
#!/bin/sh

callprog=`ps|grep $$|grep -v grep|cut -c 27-52`
server=$1
shift

while getopts "vdcf:t:i:p:b:s:r:m:w:" options; do
  case $options in
    v ) prm=$prm" -v";;
    d ) prm=$prm" -d";;
    c ) prm=$prm" -c";;
    f ) fprm=$OPTARG;;
    t ) tprm=$OPTARG;;
    i ) iprm=$OPTARG;;
    p ) pprm=$OPTARG;;
    b ) bprm=$OPTARG;;
    s ) sprm=$OPTARG;;
    r ) rprm=$OPTARG;;
    m ) mprm=$OPTARG;;
    w ) wprm=$OPTARG;;
    * ) exit 1;;
  esac
done

if [ -n "$fprm" ]; then
	prm=$prm" -f "$fprm
fi
if [ -n "$tprm" ]; then
	prm=$prm" -t "$tprm
fi
if [ -n "$iprm" ]; then
	prm=$prm" -i "$iprm
fi
if [ -n "$pprm" ]; then
	prm=$prm" -p "$pprm
fi
if [ -n "$bprm" ]; then
	prm=$prm" -b "$bprm
fi
if [ -n "$sprm" ]; then
	prm=$prm" -s "$sprm
fi
if [ -n "$rprm" ]; then
	prm=$prm" -r "$rprm
fi
if [ -n "$mprm" ]; then
	prm=$prm" -m "$mprm
fi
if [ -n "$wprm" ]; then
	prm=$prm" -w "$wprm
fi

ps|grep $$|grep -v grep|cut -c 27- >> /var/tmp/ti_tftp.log
echo $prm >> /var/tmp/ti_tftp.log

if [ -n "`ps|grep [s]w_dl`" ]; then
    if test -f /nvram/enable_fw_update
    then
	/sbin/titftp $server$prm
    else
	exit 1
    fi
else
    /sbin/titftp $server$prm
    if test -f /nvram/config.cm
    then
	fprm=`echo $fprm|cut -d: -f2|cut -f 3 -d '/'`
	echo $fprm >> /var/tmp/ti_tftp.log
	cp /var/tmp/$fprm /var/tmp/$fprm".ISP"
	cp /nvram/config.cm /var/tmp/$fprm
    fi
fi

if test -f /nvram/kill_snmp
then
    kill $(ps|grep [s]nmp|cut -c 1-5)
fi
exit 0