#!/bin/sh

process=update
if [ $# -gt 0 ]
then
	process=$1	
fi


log=update.log
pid=/tmp/$process.pid
result=0

if [ -f $pid ]
then
	kill -9 `cat $pid`
	echo "$$" >$pid
        killall wget
        killall $process
        killall sleep
        sleep 12 
else
	echo "$$" >$pid
fi

echo "####update log####" >>$log
date >>$log

cd /apps/update
./$process >>$log
result=$?
echo "$process result $result" >>$log

if [ -f $pid ]
then
	rm $pid
fi

exit $result

