3
# automatic build (configure/make/package) script
4
# for NET-SNMP on Solaris
6
# 2004/11 Rewrite to strictly build the package jfrank@fastrieve.com
7
# 2002/11 Stefan.Radman@CTBTO.ORG
10
# If you define DEBUG, the script will be verbose, and we won't remove temporary files
13
if [ ! -z $DEBUG ]; then
17
# TMP is where we are temporarily installing the package to
20
# PKG is the internal and external name for the package
23
#PREFIX is the top level architecture dependent directory.
24
# This should be normally determined by configure
28
# VARDIR is the persistent dir from configure
31
expandedprefix=${TMP}/${prefix}
33
PERL=${PERL:=`which perl`}
34
MAKE=${MAKE:=`which make`}
36
if [ -d ${TMP} ]; then
40
# install to temporary package build root
43
$MAKE install prefix=${expandedprefix} exec_prefix=${expandedprefix} || exit 1
45
# We now have the main software installed, copy over the auxillary files
48
awk /^___snmpd-init.d/,/___EOF/ $0 | grep -v ^___ | sed "s,@prefix@,$prefix,g" >|snmpd-init.d
50
# create persistent directory if it does not exist
51
[ -d $TMP/$VARDIR ] || install -d -m 0755 $TMP/$VARDIR
54
LD_LIBRARY_PATH=$TMP$prefix/lib:$LD_LIBRARY_PATH $TMP/$prefix/bin/snmptranslate\
55
-M$TMP/$prefix/share/snmp/mibs -m SNMPv2-SMI .1 >&- || exit $? # create MIB index
58
version=`../../net-snmp-config --version`
63
groups | awk '{print $1}' | read group
66
NAME="net-snmp-$version"
68
VERSION="$version, $os $rel, `date +%Y.%m.%d.%H.%M.%S`"
70
DESC="The NET-SNMP Tools and Library"
71
VENDOR="http://net-snmp.sourceforge.net"
77
echo 'checking dependencies'
78
unset LD_LIBRARY_PATH # binaries and libraries should have RPATH now
79
./elfdepend.sh $TMP | grep -v "P *$PKG " >|depend # ignore own package
81
echo 'creating prototype file'
84
i copyright=../../COPYING
85
#i preinstall=./preinstall-postremove
86
#i postinstall=./preinstall-postremove
88
# set default mode, owner and group
89
! default 0775 root sys
90
d snmp /etc 0755 root sys
91
d snmp /etc/init.d 0755 root sys
92
f snmp /etc/init.d/snmpd=./snmpd-init.d 0755 root sys
93
#l snmp /etc/rc2.d/S76snmpd=/etc/init.d/snmpd # not yet
96
pkgproto -c snmp $TMP=/ |\
97
egrep -v '^d .* / |^d .* /var |^d .* /opt |^ .*perllocal.pod=' |\
98
sed -e "s/ $owner $group\$//" >> prototype || exit $?
99
# and ignore top level directories (must pre-exist)
101
echo 'creating package'
102
pkgmk -od . || exit $?
103
pkgtrans . $PKG-$version-$ARCH-$os$rel.pkg $PKG || exit $?
105
# We should really do some cleanup here
106
if [ -z $DEBUG ]; then
107
rm -rf snmpd-init.d $PKG $TMP pkginfo prototype depend
110
echo "build was successfull"
114
# This is packaged inside of buildpackage-solaris because we need to substitute
115
# in the actual server name.
120
# start/stop the NET-SNMP master agent (snmpd)
122
# Location: /etc/init.d/snmpd
123
# /etc/rc3.d/S??snmpd
125
name="NET-SNMP agent"
126
daemon=@prefix@/sbin/snmpd
130
[ ! -x $daemon ] && echo "ERROR: cannot start $name ($daemon)" && exit 1
131
echo "Starting $name ... \c"
133
if [ -z $PGREP ]; then
134
pid=`pgrep -fx $daemon`
136
pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'`
139
[ ! -z "$pid" ] && echo "already running with pid $pid." && exit 0
140
$daemon && echo "done."
143
echo "Stopping $name ... \c"
145
if [ -z $PGREP ]; then
146
pid=`pgrep -fx $daemon`
148
pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'`
150
[ ! -z "$pid" ] && (kill $pid && echo "done" ) || echo "not running"
156
if [ -z $PGREP ]; then
157
pid=`pgrep -fx $daemon`
159
pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'`
161
[ -z "$pid" ] && echo "not running" || echo "running with pid $pid"
167
echo "Re-initializing $name ...\c"
169
if [ -z $PGREP ]; then
170
pid=`pgrep -fx $daemon`
172
pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'`
174
[ ! -z "$pid" ] && (kill -HUP $pid && echo "done" ) || echo "not running"
177
echo "Usage: $0 { start | stop | status | restart | reload }"