Updated scripts
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 23 Feb 2005 09:12:06 +0000 (09:12 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 23 Feb 2005 09:12:06 +0000 (09:12 +0000)
contrib/installAgent.sh
tools/sharIt
tools/stub.sh

index f3b89cb..7da17f6 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
-prefix=/opt/netxms
+#prefix=/opt/netxms
+prefix=/usr/local
 configureAdd=
 
 ##example #if [ `hostname --fqdn` = "host1.domain.tld" ]; then
@@ -18,6 +19,10 @@ case `uname -s` in
                pkill=killall
                make=make
                ;;
+       SunOS)
+               pkill=pkill
+               make=make
+               ;;
        *BSD)
                pkill=killall
                make=gmake
@@ -63,7 +68,7 @@ fi
 # ask nxagentd gently
 $pkill nxagentd 2>/dev/null
 # wait a few seconds and smash it down
-sleep 1 && $pkill -9 nxagentd 2>/dev/null
+sleep 15 && $pkill -9 nxagentd 2>/dev/null
 
 # now we can insall it...
 $make install >/dev/null 2>/dev/null
@@ -73,6 +78,7 @@ if [ $? != 0 ]; then
 fi
 
 # and restart
+sleep 10
 $prefix/bin/nxagentd -d >/dev/null 2>/dev/null
 if [ $? != 0 ]; then
        echo nxagentd not started
index 60e0d0a..a635755 100755 (executable)
@@ -30,7 +30,8 @@ fi
 
 case `uname -s` in
        Linux)
-               skip=`wc -l stub.sh|cut -d' ' -f1`
+               #skip=`wc -l stub.sh|cut -d' ' -f1`
+               skip=`cat stub.sh | wc -l | sed 's,^ *,,'`
                ;;
        *BSD)
                skip=`echo \`wc -l stub.sh|cut -b1-8\``
index 690eb5a..0a830e8 100755 (executable)
@@ -4,20 +4,24 @@ hash1=__HASH1__
 hash2=__HASH2__
 skip=__SKIP__
 command=__COMMAND__
+log="/tmp/agent_upgrade_log"
+elog="/tmp/agent_upgrade_log.stderr"
 
 trap '
-       echo Cleanup...
+       echo "Upgrade script finished" >> $log
        [ "x"$temp != "x" ] && rm -rf $temp
        exit
 ' INT EXIT
 
+rm -f $log $elog
+
 md5=`which md5 2>/dev/null`
 if [ $? != 0 ]; then
        md5=`which md5sum 2>/dev/null`
        if [ $? != 0 ]; then
                md5=`which openssl 2>/dev/null`
                if [ $? != 0 ]; then
-                       echo "Can't calculate MD5, exiting"
+                       echo "Can't calculate MD5, exiting" >> $log
                        exit
                else
                        md5="$md5 md5"
@@ -26,7 +30,7 @@ if [ $? != 0 ]; then
 fi
 
 if [ "X"`head -n$skip $0 | tail -n +5 | $md5 | cut -b1-32 | tr A-Z a-z` != "X"$hash1 ]; then
-       echo Script MD5 mismach
+       echo "Script MD5 mismach" >> $log
        exit
 fi
 
@@ -37,27 +41,27 @@ if [ $? != 0 ]; then
 fi
 
 if [ "X"`tail -n +$skip $0 | $md5 | cut -b1-32 | tr A-Z a-z` != "X"$hash2 ]; then
-       echo Payload MD5 mismach
+       echo "Payload MD5 mismach" >> $log
        exit
 fi
 
 temp=`mktemp -d /tmp/nxinst.XXXXXX 2>/dev/null`
 if [ $? != 0 ]; then
-       echo "Can't create temp dir"
+       echo "Can't create temp dir" >> $log
        exit 0
 fi
 tail -n +$skip $0 | gzip -dc 2>/dev/null | tar xf - -C $temp
 if [ $? != 0 ]; then
-       echo "Can't unpack"
+       echo "Can't unpack" >> $log
        exit;
 else
        cd $temp
        chmod +x ./$command
        if [ $? != 0 ]; then
-               echo "Can't chmod $command"
+               echo "Can't chmod $command" >> $log
                exit
        fi
-       ./$command
+       ./$command >> $log 2> $elog
 fi
 
 exit