usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / snmp / net-snmp-config
blob5135454accb15b074aec22ab2c2a150e3842fa91
1 #!/bin/sh
3 # this shell script is designed to merely dump the configuration
4 # information about how the net-snmp package was compiled. The
5 # information is particularily useful for applications that need to
6 # link against the net-snmp libraries and hence must know about any
7 # other libraries that must be linked in as well.
9 NSC_BASE_AGENT_LIBS="-lnetsnmpagent -lnetsnmpmibs -lnetsnmphelpers -lnetsnmp"
11 if test "x$1" = "x"; then
12 usage="yes"
13 else
14 exec_prefix=/usr
15 prefix=/usr
16 case $1 in
17 --debug-tokens)
18 echo "find NET-SNMP-SOURCE-DIR -name \"*.c\" -print | xargs grep DEBUGMSGT | grep \\\" | cut -f 2 -d\\\" | sort -u"
20 --indent-options)
21 echo "indent -orig -nbc -bap -nut -nfca `(cd NET-SNMP-INCLUDE-DIR; perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h)`"
23 --configure-options)
24 echo " --host=mipsel-linux --build=x86_64-linux-gnu --prefix=/usr --with-endianness=little --enable-mini-agent --disable-debugging --disable-privacy --without-opaque-special-types --with-persistent-directory=/tmp/snmp-persist --with-default-snmp-version=3 --with-sys-contact=root --with-sys-location=Unknown --with-logfile=/dev/null --with-out-transports=UDPIPv6,TCPIPv6,AAL5PVC,IPX,TCP,Unix --enable-shared=no --enable-static --with-gnu-ld --enable-internal-md5 --with-copy-persistent-files=no --without-openssl -sysconfdir=/tmp --with-mib-modules=mibII,host,mibII/ip,mibII/tcp,mibII/udp,mibII/icmp,mibII/var_route,mibII/kernel_linux,qos,ucd_snmp --with-out-mib-modules=snmpv3mibs,agent_mips,agentx,notification,utilities,target --disable-ipv6 --with-defaults --without-efence --without-rsaref --without-kmem-usage --without-rpm --without-dmalloc"
26 --snmpd-module-list)
27 echo mibII/snmp_mib mibII/system_mib mibII/sysORTable mibII/vacm_vars mibII/ip mibII/tcp mibII/udp mibII/icmp mibII/var_route mibII/kernel_linux qos util_funcs mibII/vacm_context host/hr_system host/hr_storage host/hr_device host/hr_other host/hr_proc host/hr_network host/hr_print host/hr_disk host/hr_partition host/hr_filesys host/hr_swrun host/hr_swinst mibII/interfaces mibII/ipAddr mibII/at mibII/route_write mibII/tcpTable mibII/udpTable qos_access qos_checkfns ucd-snmp/memory ucd-snmp/vmstat ucd-snmp/proc ucd-snmp/versioninfo ucd-snmp/pass ucd-snmp/pass_persist ucd-snmp/disk ucd-snmp/loadave ucd-snmp/extensible ucd-snmp/errormib ucd-snmp/file ucd-snmp/dlmod ucd-snmp/proxy qos_checkfns_local
29 --base-cflags)
30 echo -Os -Wall -DLINUX26 -DCONFIG_BCMWL5 -pipe -DBCMWPA2 -funit-at-a-time -Wno-pointer-sign -mtune=mips32 -mips32 -Dlinux -I${prefix}/include
32 --cflags)
33 echo -Os -Wall -DLINUX26 -DCONFIG_BCMWL5 -pipe -DBCMWPA2 -funit-at-a-time -Wno-pointer-sign -mtune=mips32 -mips32 -Dlinux -I. -I${prefix}/include
35 --agent-libs)
36 # use this one == --netsnmp-agent-libs + --external-libs
37 echo -L${exec_prefix}/lib $NSC_BASE_AGENT_LIBS -ldl -lm
39 --libs)
40 # use this one == --netsnmp-libs + --external-libs
41 echo -L${exec_prefix}/lib -lnetsnmp -lm
43 --external-libs)
44 echo -lm
46 --external-agent-libs)
47 echo -ldl -lm
49 --netsnmp-libs)
50 echo -L${exec_prefix}/lib -lnetsnmp
52 --netsnmp-agent-libs)
53 echo -L${exec_prefix}/lib $NSC_BASE_AGENT_LIBS
55 --version)
56 echo 5.0.9
58 --help)
59 usage="yes"
61 --prefix)
62 echo /usr
64 --exec-prefix)
65 echo /usr
67 --create-snmpv3-user)
68 if /bin/ps -e | egrep ' snmpd *$' > /dev/null 2>&1 ; then
69 echo "Apparently at least one snmpd demon is already running."
70 echo "You must stop them in order to use this command."
71 exit 1
74 Aalgorithm="MD5"
75 Xalgorithm="DES"
76 token=rwuser
77 shift
78 arg=$1
79 shift
80 while test "x$done" = "x" -a "x$arg" != "x" ; do
81 case $arg in
82 -A)
83 Aalgorithm=$1
84 shift
86 -X)
87 Xalgorithm=$1
88 shift
90 -a)
91 apassphrase=$1
92 shift
94 -x)
95 xpassphrase=$1
96 shift
98 -ro)
99 token="rouser"
102 echo "unknown suboption to --create-snmpv3-user: $arg"
103 exit 1
106 done=1
108 esac
109 if test "x$done" = "x" ; then
110 arg=$1
111 shift
113 done
115 user=$arg
116 if test "x$user" = "x" ; then
117 prompt=yes
118 echo "Enter a SNMPv3 user name to create: "
119 read user
121 if test "x$user" = "x" ; then
122 echo "You must specify a user name"
123 exit 1
126 if test "x$apassphrase" = "x" ; then
127 prompt=yes
128 echo "Enter authentication pass-phrase: "
129 read apassphrase
130 else
131 shift
133 if test "x$apassphrase" = "x" ; then
134 echo "You must specify an authentication pass-phrase"
135 exit 1
138 if test "x$prompt" = "xyes" -a "x$xpassphrase" = "x" ; then
139 echo "Enter encryption pass-phrase: "
140 echo " [press return to reuse the authentication pass-phrase]"
141 read xpassphrase
144 outfile="/tmp/snmp-persist/snmpd.conf"
145 line="createUser $user $Aalgorithm \"$apassphrase\" $Xalgorithm $xpassphrase"
146 echo "adding the following line to $outfile:"
147 echo " " $line
148 echo $line >> $outfile
150 outfile="${prefix}/share/snmp/snmpd.conf"
151 line="$token $user"
152 echo "adding the following line to $outfile:"
153 echo " " $line
154 echo $line >> $outfile
157 --compile-subagent)
158 shift
159 outname=$1
160 shift
161 if test $1 = "--norm" ; then
162 norm=1
163 shift
165 if test $1 = "--cflags" ; then
166 shift
167 cflags=$1
168 echo "setting extra cflags: $cflags"
169 shift
171 if test $1 = "--ldflags" ; then
172 shift
173 ldflags=$1
174 echo "setting extra ldflags: $ldflags"
175 shift
177 tmpfile=netsnmptmp.$$.c
178 if test -f $tmpfile; then
179 echo "Ack. Can't create $tmpfile: already exists"
180 exit 1
182 echo "generating the tmporary code file: $tmpfile"
183 rm -f $tmp
184 cat > $tmpfile <<EOF
185 /* generated from net-snmp-config */
186 #include <net-snmp/net-snmp-config.h>
187 #ifdef HAVE_SIGNAL_H
188 #include <signal.h>
189 #endif /* HAVE_SIGNAL_H */
190 #include <net-snmp/net-snmp-includes.h>
191 #include <net-snmp/agent/net-snmp-agent-includes.h>
194 # add include files
195 while test "$1" != ""; do
196 cfiles="$cfiles $1"
197 name=`basename $1 | sed 's/\.[co]$/.h/'`
198 if test -f $name.h; then
199 if grep "init_$name" $name; then
200 echo " #include\"$name\"" >> $tmpfile
203 shift
204 done
206 cat >> $tmpfile <<EOF
207 static int keep_running;
209 RETSIGTYPE
210 stop_server(int a) {
211 keep_running = 0;
215 main (int argc, char **argv) {
216 /* print log errors to stderr */
217 snmp_enable_stderrlog();
218 /* we are a subagent */
219 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
221 /* initialize the agent library */
222 init_agent("$outname");
224 /* initialize your mib code here */
227 # add init routines
228 for i in $cfiles ; do
229 name=`basename $i | sed 's/\.[co]$//'`
230 echo checking for init_$name in $i
231 if grep "init_$name" $i ; then
232 echo " init_${name}();" >> $tmpfile
234 shift
235 done
237 # finish file
238 cat >> $tmpfile <<EOF
240 /* ustMain will be used to read ustMain.conf files. */
241 init_snmp("$outname");
243 /* In case we recevie a request to stop (kill -TERM or kill -INT) */
244 keep_running = 1;
245 #ifdef SIGTERM
246 signal(SIGTERM, stop_server);
247 #endif
248 #ifdef SIGINT
249 signal(SIGINT, stop_server);
250 #endif
252 /* main loop here... */
253 while(keep_running) {
254 agent_check_and_process(1);
257 /* at shutdown time */
258 snmp_shutdown("$outname");
259 exit(0);
263 if test "$?" != 0 -o ! -f "$tmpfile" ; then
264 echo "Ack. Can't create $tmpfile."
265 exit 1
267 prefix=/usr
268 cmd="mipsel-uclibc-gcc $cflags -Os -Wall -DLINUX26 -DCONFIG_BCMWL5 -pipe -DBCMWPA2 -funit-at-a-time -Wno-pointer-sign -mtune=mips32 -mips32 -Dlinux -I. -I${prefix}/include -o $outname $tmpfile $cfiles -L/usr/lib -lnetsnmpagent -lnetsnmphelpers -lnetsnmpmibs -lnetsnmp -ldl -lm $ldflags"
269 echo "running: $cmd"
270 `$cmd`
271 if test "x$norm" != "x1" ; then
272 echo "removing the tmporary code file: $tmpfile"
273 rm -f $tmpfile
274 else
275 echo "leaving the tmporary code file: $tmpfile"
277 if test -f $outname ; then
278 echo "subagent program $outname created"
283 echo "unknown option $1"
284 usage="yes"
286 esac
289 if test "x$usage" = "xyes"; then
290 echo ""
291 echo "Usage:"
292 echo " net-snmp-config [--cflags] [--agent-libs] [--libs] [--version]"
293 echo " ... [see below for complete flag list]"
294 echo ""
295 echo " --version displays the net-snmp version number"
296 echo " --indent-options displays the indent options from the Coding Style"
297 echo " --debug-tokens displays a example command line to search to source"
298 echo " code for a list of available debug tokens"
299 echo ""
300 echo " SNMP Setup commands:"
301 echo ""
302 echo " --create-snmpv3-user [-ro] [-a authpass] [-x privpass] [-X DES]"
303 echo " [-A MD5|SHA] [username]"
304 echo ""
305 echo " These options produce the various compilation flags needed when"
306 echo " building external SNMP applications:"
307 echo ""
308 echo " --base-cflags lists additional compilation flags needed"
309 echo " for external applications (excludes -I. and"
310 echo " extra developer warning flags, if any)"
311 echo " --cflags lists additional compilation flags needed"
312 echo " --libs lists libraries needed for building applications"
313 echo " --agent-libs lists libraries needed for building subagents"
314 echo ""
315 echo " --netsnmp-libs lists netsnmp specific libraries"
316 echo " --external-libs lists libraries needed by netsnmp libs"
317 echo " --netsnmp-agent-libs lists netsnmp specific agent libraries"
318 echo " --external-agent-libs lists libraries needed by netsnmp libs"
319 echo ""
320 echo " Automatted subagent building (produces an OUTPUTNAME binary file):"
321 echo " [this feature has not been tested very well yet. use at your risk.]"
322 echo ""
323 echo " --compile-subagent OUTPUTNAME [--norm] [--cflags flags]"
324 echo " [--ldflags flags] mibmodule1.c [...]]"
325 echo ""
326 echo " --norm leave the generated .c file around to read."
327 echo " --cflags flags extra cflags to use (e.g. -I...)."
328 echo " --ldflags flags extra ld flags to use (e.g. -L... -l...)."
329 echo ""
330 echo " Details on how the net-nsmp package was compiled:"
331 echo ""
332 echo " --configure-options Display original configure arguments"
333 echo " --snmpd-module-list Display the modules compiled into the agent"
334 echo " --prefix Display the installation prefix"
335 echo ""
336 exit