#!/bin/sh # # $Id: net-snmp-config.in,v 5.43.2.2 2006/06/12 23:01:31 tanders Exp $ # # this shell script is designed to merely dump the configuration # information about how the net-snmp package was compiled. The # information is particularily useful for applications that need to # link against the net-snmp libraries and hence must know about any # other libraries that must be linked in as well. check_build_dir() { build_dir=$1 if test "x$build_dir" = "x" ; then echo "You must specify a build directory." exit 1 fi # is it the src dir? if test -f $build_dir/net-snmp-config.in ; then return fi # make sure we can find build dir if ! test -d $build_dir/snmplib/.libs ; then echo "$build_dir does not appear to be a build directory." exit 1 fi } prefix=/mnt/gmirror/ports/net-mgmt/net-snmp/work/net-snmp-5.3.1/ exec_prefix=/mnt/gmirror/ports/net-mgmt/net-snmp/work/net-snmp-5.3.1/ includedir=${prefix}/include libdir=${exec_prefix}/lib NSC_LDFLAGS=" -rpath=/usr/lib:/usr/local/lib" NSC_INCLUDEDIR=${includedir} NSC_LIBDIR=-L${libdir} NSC_LIBS="-lcrypto -lelf -lm " NSC_AGENTLIBS="-ldl -lkvm -lcrypto -lelf -lm " NSC_PREFIX=$prefix NSC_EXEC_PREFIX=$exec_prefix NSC_SRCDIR=. NSC_INCDIR=${NSC_PREFIX}/include NSC_BASE_SUBAGENT_LIBS="-lnetsnmpagent -lnetsnmphelpers -lnetsnmp" NSC_BASE_AGENT_LIBS="-lnetsnmpmibs -lnetsnmpagent -lnetsnmphelpers -lnetsnmp" NSC_SRC_LIBDIRS="agent/.libs snmplib/.libs agent/helpers/.libs" NSC_SRC_LIBDEPS="agent/.libs/libnetsnmpmibs.a agent/.libs/libnetsnmpagent.a agent/helpers/.libs/libnetsnmphelpers.a snmplib/.libs/libnetsnmp.a" if test "x$NSC_SRCDIR" = "x." ; then NSC_SRCDIR="NET-SNMP-SOURCE-DIR" fi if test "x$1" = "x"; then usage="yes" else while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do case "$1" in -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac case $1 in --prefix=*) prefix=$optarg NSC_PREFIX=${prefix} NSC_INCLUDEDIR=${prefix}/include NSC_LIBDIR=-L${prefix}/lib ;; --exec-prefix=*) exec_prefix=$optarg NSC_EXEC_PREFIX=${exec_prefix} NSC_LIBDIR=-L${exec_prefix}/lib ;; --debug-tokens|--deb*|--dbg*) echo "find $NSC_SRCDIR -name \"*.c\" -print | xargs grep DEBUGMSGT | grep \\\" | cut -f 2 -d\\\" | sort -u" if test "x$NSC_SRCDIR" != "xNET-SNMP-SOURCE-DIR" ; then /usr/bin/find $NSC_SRCDIR -name "*.c" -print | xargs grep DEBUGMSGT | grep \" | cut -f 2 -d\" | sort -u fi ;; --indent-options|--in*) echo "indent -orig -nbc -bap -nut -nfca `(cd $NSC_INCDIR/net-snmp; perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h)`" ;; --configure-options|--con*) echo " '--enable-shared' '--enable-internal-md5' '--with-mib-modules= host disman/event-mib smux mibII/mta_sendmail mibII/tcpTable ucd-snmp/diskio' '--with-default-snmp-version=3' '--with-sys-contact=nobody@nowhere.invalid' '--with-sys-location=somewhere' '--with-logfile=/var/log/snmpd.log' '--with-persistent-directory=/var/net-snmp' '--with-gnu-ld' '--with-libwrap' '--with-libs=-lkvm -ldevstat' '--with-dummy-values' '--enable-embedded-perl' '--with-perl-modules' '--enable-ipv6' '--prefix=/usr/local' 'i386-unknown-gnu' 'build_alias=i386-unknown-gnu' 'host_alias=i386-unknown-gnu' 'target_alias=i386-unknown-gnu' 'CC=cc' 'CFLAGS=-fno-common' 'LDFLAGS= -rpath=/usr/lib:/usr/local/lib' 'CXX=c++' 'CXXFLAGS=-fno-common'" ;; --snmpd-module-list|--mod*) echo mibII/system_mib mibII/sysORTable mibII/at mibII/ip mibII/snmp_mib mibII/tcp mibII/icmp mibII/udp mibII/vacm_vars mibII/setSerialNo ucd-snmp/proc ucd-snmp/versioninfo ucd-snmp/pass ucd-snmp/pass_persist ucd-snmp/disk ucd-snmp/loadave ucd-snmp/extensible agent/extend ucd-snmp/errormib ucd-snmp/file ucd-snmp/dlmod ucd-snmp/proxy ucd-snmp/logmatch snmpv3/snmpEngine snmpv3/snmpMPDStats snmpv3/usmStats snmpv3/usmConf snmpv3/usmUser notification/snmpNotifyTable notification/snmpNotifyFilterProfileTable notification-log-mib/notification_log target/snmpTargetAddrEntry target/snmpTargetParamsEntry target/target target/target_counters agent/nsTransactionTable agent/nsModuleTable agent/nsDebug agent/nsCache agent/nsLogging agentx/master agentx/subagent disman/schedule/schedCore disman/schedule/schedConf disman/schedule/schedTable utilities/override utilities/execute utilities/iquery util_funcs mibII/interfaces mibII/ipAddr mibII/var_route mibII/route_write mibII/tcpTable mibII/udpTable mibII/vacm_context mibII/vacm_conf header_complex snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable agentx/protocol agentx/client agentx/master_admin agentx/agentx_config disman/event/mteScalars disman/event/mteTrigger disman/event/mteTriggerTable disman/event/mteTriggerDeltaTable disman/event/mteTriggerExistenceTable disman/event/mteTriggerBooleanTable disman/event/mteTriggerThresholdTable disman/event/mteTriggerConf disman/event/mteEvent disman/event/mteEventTable disman/event/mteEventSetTable disman/event/mteEventNotificationTable disman/event/mteEventConf disman/event/mteObjects disman/event/mteObjectsTable disman/event/mteObjectsConf if-mib/data_access/interface snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_interface snmp-notification-mib/snmpNotifyFilterTable/snmpNotifyFilterTable_data_access ;; --default-mibs|--mibs|--MIBS) echo IP-MIB:IF-MIB:TCP-MIB:UDP-MIB:HOST-RESOURCES-MIB:SNMPv2-MIB:RFC1213-MIB:NOTIFICATION-LOG-MIB:DISMAN-EVENT-MIB:DISMAN-SCHEDULE-MIB:UCD-SNMP-MIB:UCD-DEMO-MIB:SNMP-TARGET-MIB:NET-SNMP-AGENT-MIB:SNMP-VIEW-BASED-ACM-MIB:SNMP-COMMUNITY-MIB:NET-SNMP-EXTEND-MIB:UCD-DLMOD-MIB:SNMP-FRAMEWORK-MIB:SNMP-MPD-MIB:SNMP-USER-BASED-SM-MIB:SNMP-NOTIFICATION-MIB:SNMPv2-TM ;; --default-mibdirs|--mibdirs|--MIBDIRS) echo $HOME/.snmp/mibs:/mnt/gmirror/ports/net-mgmt/net-snmp/work/net-snmp-5.3.1//share/snmp/mibs ;; --snmpconfpath|--SNMPCONFPATH) echo "/mnt/gmirror/ports/net-mgmt/net-snmp/work/net-snmp-5.3.1//etc/snmp:/mnt/gmirror/ports/net-mgmt/net-snmp/work/net-snmp-5.3.1//share/snmp:/mnt/gmirror/ports/net-mgmt/net-snmp/work/net-snmp-5.3.1//lib/snmp:$HOME/.snmp:/var/net-snmp" ;; --persistent-directory|--persistent-dir) echo /var/net-snmp ;; --perlprog|--perl) echo /usr/local/bin/perl ;; #################################################### compile --base-cflags) echo -fno-common -Dgnu -I${NSC_INCLUDEDIR} ;; --cflags|--cf*) echo -fno-common -Dgnu -I. -I${NSC_INCLUDEDIR} ;; --srcdir) echo $NSC_SRCDIR ;; #################################################### linking --libdir|--lib-dir) echo $NSC_LIBDIR ;; --ldflags|--ld*) echo $NSC_LDFLAGS ;; --build-lib-dirs) shift build_dir=$1 check_build_dir $build_dir for dir in $NSC_SRC_LIBDIRS; do result="$result -L$build_dir/$dir" done echo $result ;; --build-lib-deps) shift build_dir=$1 check_build_dir $build_dir for dir in $NSC_SRC_LIBDEPS; do result="$result $build_dir/$dir" done echo $result ;; --build-includes) shift build_dir=$1 check_build_dir $build_dir result="-I$build_dir/include" if test "$build_dir" != "$NSC_SRCDIR" -a "$NSC_SRCDIR" != "NET-SNMP-SOURCE-DIR" then result="$result -I$NSC_SRCDIR/include" fi echo $result ;; #################################################### client lib --libs) # use this one == --netsnmp-libs + --external-libs echo $NSC_LDFLAGS $NSC_LIBDIR -lnetsnmp $NSC_LIBS ;; --netsnmp-libs) echo $NSC_LIBDIR -lnetsnmp ;; --external-libs) echo $NSC_LDFLAGS $NSC_LIBS ;; #################################################### agent lib --base-agent-libs) echo $NSC_BASE_AGENT_LIBS ;; --base-subagent-libs) echo $NSC_BASE_SUBAGENT_LIBS ;; --agent-libs) # use this one == --netsnmp-agent-libs + --external-libs echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_BASE_AGENT_LIBS $NSC_AGENTLIBS ;; --netsnmp-agent-libs) echo $NSC_LIBDIR $NSC_BASE_AGENT_LIBS ;; --external-agent-libs) echo $NSC_LDFLAGS $NSC_AGENTLIBS ;; #################################################### --version|--ver*) echo 5.3.1 ;; --help) usage="yes" ;; --prefix|--pre*) echo $NSC_PREFIX ;; --exec-prefix) echo $NSC_EXEC_PREFIX ;; #################################################### --create-snmpv3-user) if /bin/ps acx | egrep ' snmpd *$' > /dev/null 2>&1 ; then echo "Apparently at least one snmpd demon is already running." echo "You must stop them in order to use this command." exit 1 fi Aalgorithm="MD5" Xalgorithm="DES" token=rwuser shift while test "x$done" = "x" -a "x$1" != "x" ; do case $1 in -A|-a) shift if test "x$1" = "x" ; then echo "You must specify an authentication algorithm or pass phrase" exit 1 fi case $1 in MD5|SHA) Aalgorithm=$1 shift ;; md5|sha) Aalgorithm=`echo $1 | tr a-z A-Z` shift ;; *) apassphrase=$1 shift ;; esac ;; -X|-x) shift if test "x$1" = "x" ; then echo "You must specify an encryption algorithm or pass phrase" exit 1 fi case $1 in DES|AES|AES128) Xalgorithm=$1 shift ;; des|aes|aes128) Xalgorithm=`echo $1 | tr a-z A-Z` shift ;; *) xpassphrase=$1 shift ;; esac ;; -ro) token="rouser" shift ;; -*) echo "unknown suboption to --create-snmpv3-user: $1" exit 1 ;; *) done=1 ;; esac done if test "x$1" = "x" ; then prompt=yes echo "Enter a SNMPv3 user name to create: " read user else user=$1 shift fi if test "x$user" = "x" ; then echo "You must specify a user name" exit 1 fi if test "x$apassphrase" = "x" ; then prompt=yes echo "Enter authentication pass-phrase: " read apassphrase fi if test "x$apassphrase" = "x" ; then echo "You must specify an authentication pass-phrase" exit 1 fi if test "x$prompt" = "xyes" -a "x$xpassphrase" = "x" ; then echo "Enter encryption pass-phrase: " echo " [press return to reuse the authentication pass-phrase]" read xpassphrase fi outdir="/var/net-snmp" outfile="$outdir/snmpd.conf" line="createUser $user $Aalgorithm \"$apassphrase\" $Xalgorithm $xpassphrase" echo "adding the following line to $outfile:" echo " " $line # in case it hasn't ever been started yet, start it. if ! test -d $outdir ; then mkdir $outdir fi if ! test -d $outfile ; then touch $outfile fi echo $line >> $outfile outfile="${prefix}/share/snmp/snmpd.conf" line="$token $user" echo "adding the following line to $outfile:" echo " " $line if ! test -d $outfile ; then touch $outfile fi echo $line >> $outfile ;; #################################################### --compile-subagent) shift while test "x$done" = "x" -a "x$1" != "x" ; do case $1 in --norm) norm=1 shift ;; --cflags) shift if test "x$1" = "x" ; then echo "You must specify the extra cflags" exit 1 fi cflags=$1 echo "setting extra cflags: $cflags" shift ;; --ldflags) shift if test "x$1" = "x" ; then echo "You must specify the extra ldflags" exit 1 fi ldflags=$1 echo "setting extra ldflags: $ldflags" shift ;; --*) echo "unknown suboption to --compile-subagent: $1" exit 1 ;; *) if test "x$outname" = "x"; then outname=$1 shift else done=1 fi ;; esac done tmpfile=netsnmptmp.$$.c if test -f $tmpfile; then echo "Ack. Can't create $tmpfile: already exists" exit 1 fi echo "generating the tmporary code file: $tmpfile" rm -f $tmpfile cat > $tmpfile < #ifdef HAVE_SIGNAL_H #include #endif /* HAVE_SIGNAL_H */ #include #include EOF # If we were only given a single filename # (and no explicit output name) # then use that as the base of the output name # # If we weren't even given that, then bomb out if test "x$1" = "x"; then if test "x$outname" = "x"; then echo "No MIB module codefile specified" rm -f $tmpfile exit 1 else cfiles=$outname outname=`basename $cfiles | sed 's/\.[co]$//'` if test -f $outname.h; then if grep "init_$outname" $outname.h; then echo " #include \"$outname.h\"" >> $tmpfile fi fi fi fi # add include files while test "$1" != ""; do cfiles="$cfiles $1" name=`basename $1 | sed 's/\.[co]$//'` if test -f $name.h; then if grep "init_$name" $name.h; then echo " #include \"$name.h\"" >> $tmpfile fi fi shift done cat >> $tmpfile <> $tmpfile fi shift done # finish file cat >> $tmpfile <