condTimedWait fixed
[public/netxms.git] / contrib / installAgent.sh
CommitLineData
ed73635e
AK
1#!/bin/sh
2
3prefix=/opt/netxms
4configureAdd=
5
6##example #if [ `hostname --fqdn` = "host1.domain.tld" ]; then
7# prefix=/opt/nagios
8# configureAdd=--with-nice-option
9#fi
10
11###############################################################################
12#
13# Main code
14#
15
16case `uname -s` in
17 Linux)
18 pkill=killall
19 make=make
20 ;;
21 *BSD)
22 pkill=killall
23 make=gmake
24 ;;
25 *)
26 pkill=pkill
27 make=gmake
28 ;;
29esac
30
31cd `dirname $0`
32name=`ls netxms-*.tar.gz 2>/dev/null|sed s',\.tar\.gz$,,'`
33if [ "x$name" = "x" ]; then
34 echo invalid package
35 exit 1
36fi
37
38tar zxf $name.tar.gz 2>/dev/null
39if [ $? != 0 ]; then
40 echo invalid package
41 exit 2
42fi
43cd $name
44if [ $? != 0 ]; then
45 echo invalid package
46 exit 3
47fi
48
49# do configure
1216cc73 50./configure --prefix=$prefix --with-agent $configureAdd 2>/dev/null >/dev/null
ed73635e
AK
51if [ $? != 0 ]; then
52 echo configure failed, duh
53 exit 4
54fi
55
56# build
57$make >/dev/null 2>/dev/null
58if [ $? != 0 ]; then
59 echo build failed, duh
60 exit 4
61fi
62
63# ask nxagentd gently
64$pkill nxagentd 2>/dev/null
65# wait a few seconds and smash it down
66sleep 1 && $pkill -9 nxagentd 2>/dev/null
67
68# now we can insall it...
69$make install >/dev/null 2>/dev/null
70if [ $? != 0 ]; then
71 echo install failed
72 exit 5
73fi
74
75# and restart
76$prefix/bin/nxagentd -d >/dev/null 2>/dev/null
77if [ $? != 0 ]; then
78 echo nxagentd not started
79 exit 5
80fi