Various fixes
[public/netxms.git] / tools / stub.sh
CommitLineData
b78936e5
AK
1#!/bin/sh
2
3hash1=__HASH1__
4hash2=__HASH2__
5skip=__SKIP__
3e80aa9c 6skip1=__SKIP1__
b78936e5 7command=__COMMAND__
5e43ae16 8log=/tmp/nxagentupdate.log
b78936e5 9
3e80aa9c
AK
10wd=`pwd -P`
11
b78936e5 12trap '
861fb447 13 echo "Upgrade script finished" >> $log
3e80aa9c 14 cd $wd
2dad1e4c 15 [ "x"$temp != "x" ] && rm -rf $temp
b78936e5
AK
16 exit
17' INT EXIT
18
5e43ae16 19rm -f $log
2f06a66e 20echo "WD = $wd" >> $log
861fb447 21
39cc66bb
VK
22mktemp() {
23 d=/tmp/nxupdate.$$.UniQ
24 mkdir $d && echo $d || false
25}
b78936e5
AK
26
27temp=`mktemp -d /tmp/nxinst.XXXXXX 2>/dev/null`
28if [ $? != 0 ]; then
861fb447 29 echo "Can't create temp dir" >> $log
b78936e5
AK
30 exit 0
31fi
3e80aa9c 32cd $temp
39cc66bb 33tail +$skip1 $wd/$0 | gzip -dc 2>/dev/null | tar xf -
b78936e5 34if [ $? != 0 ]; then
861fb447 35 echo "Can't unpack" >> $log
b78936e5
AK
36 exit;
37else
2dad1e4c
AK
38 chmod +x ./$command
39 if [ $? != 0 ]; then
861fb447 40 echo "Can't chmod $command" >> $log
2dad1e4c
AK
41 exit
42 fi
de31a623
AK
43 echo Starting $command $*... >> $log
44 ./$command $* 2>&1 >> $log
b78936e5
AK
45fi
46
47exit
48###################################