~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to net-snmp-config.in

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-12-08 14:59:50 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071208145950-u1tykhpw56nyzqik
Tags: 5.4.1~dfsg-4ubuntu1
* Merge from debian unstable.
* Remaining Ubuntu changes:
  - Remove stop links from rc0 and rc6
  - Munge Maintainer field as per spec.
* Ubuntu changes dropped:
  - Symlink common files between the packages, CDBS ought to handle that
    for us automatically.
* The latest Debian changes has dropped history from the changelog. Slot in
  the Ubuntu changes as best I can. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
#
3
 
# $Id: net-snmp-config.in,v 5.43.2.2 2006/06/12 23:01:31 tanders Exp $
 
3
# $Id: net-snmp-config.in 16569 2007-06-29 22:18:27Z tanders $
4
4
#
5
5
# this shell script is designed to merely dump the configuration
6
6
# information about how the net-snmp package was compiled.  The
21
21
         return
22
22
      fi
23
23
      # make sure we can find build dir
24
 
      if ! test -d $build_dir/snmplib/.libs ; then
 
24
      if test ! -d $build_dir/snmplib/.libs ; then
25
25
         echo "$build_dir does not appear to be a build directory."
26
26
         exit 1
27
27
      fi
34
34
NSC_LDFLAGS="@LDFLAGS@"
35
35
NSC_INCLUDEDIR=${includedir}
36
36
NSC_LIBDIR=-L${libdir}
37
 
NSC_LIBS="@LIBS@ @WRAPLIBS@"
38
 
NSC_AGENTLIBS="@AGENTLIBS@ @WRAPLIBS@ @PERLLDOPTS@"
 
37
NSC_LIBS="@LIBS@"
 
38
NSC_AGENTLIBS="@AGENTLIBS@ @PERLLDOPTS_FOR_APPS@"
39
39
NSC_PREFIX=$prefix
40
40
NSC_EXEC_PREFIX=$exec_prefix
41
41
NSC_SRCDIR=@srcdir@
85
85
      echo @CONFIGURE_OPTIONS@
86
86
      ;;
87
87
    --snmpd-module-list|--mod*)
88
 
      echo @MODULE_LIST@
 
88
      @MODULE_LIST@
89
89
      ;;
90
90
    --default-mibs|--mibs|--MIBS)
91
 
      echo @DEFAULT_MIBS@
 
91
      echo @NETSNMP_DEFAULT_MIBS@
92
92
      ;;
93
93
    --default-mibdirs|--mibdirs|--MIBDIRS)
94
 
      echo @DEFAULT_MIBDIRS@
 
94
      echo @NETSNMP_DEFAULT_MIBDIRS@
95
95
      ;;
96
96
    --snmpconfpath|--SNMPCONFPATH)
97
97
      echo "@SNMPCONFPATH@@ENV_SEPARATOR@@SNMPSHAREPATH@@ENV_SEPARATOR@@SNMPLIBPATH@@ENV_SEPARATOR@$HOME/.snmp@ENV_SEPARATOR@@PERSISTENT_DIRECTORY@"
294
294
      echo "adding the following line to $outfile:"
295
295
      echo "  " $line
296
296
      # in case it hasn't ever been started yet, start it.
297
 
      if ! test -d $outdir ; then
 
297
      if test ! -d $outdir ; then
298
298
          mkdir $outdir
299
299
      fi
300
 
      if ! test -d $outfile ; then
 
300
      if test ! -d $outfile ; then
301
301
          touch $outfile
302
302
      fi
303
303
      echo $line >> $outfile
306
306
      line="$token $user"
307
307
      echo "adding the following line to $outfile:"
308
308
      echo "  " $line
309
 
      if ! test -d $outfile ; then
 
309
      if test ! -d $outfile ; then
310
310
          touch $outfile
311
311
      fi
312
312
      echo $line >> $outfile
365
365
      cat > $tmpfile <<EOF
366
366
/* generated from net-snmp-config */
367
367
#include <net-snmp/net-snmp-config.h>
368
 
#ifdef HAVE_SIGNAL_H
 
368
#ifdef HAVE_SIGNAL
369
369
#include <signal.h>
370
 
#endif /* HAVE_SIGNAL_H */
 
370
#endif /* HAVE_SIGNAL */
371
371
#include <net-snmp/net-snmp-includes.h>
372
372
#include <net-snmp/agent/net-snmp-agent-includes.h>
373
373
EOF
406
406
    done
407
407
 
408
408
      cat >> $tmpfile <<EOF
 
409
const char *app_name = "$outname";
 
410
 
409
411
extern int netsnmp_running;
410
412
 
 
413
#ifdef __GNUC__
 
414
#define UNUSED __attribute__((unused))
 
415
#else
 
416
#define UNUSED
 
417
#endif
 
418
 
411
419
RETSIGTYPE
412
 
stop_server(int a) {
 
420
stop_server(UNUSED int a) {
413
421
    netsnmp_running = 0;
414
422
}
415
423
 
 
424
static void
 
425
usage(const char *prog)
 
426
{
 
427
    fprintf(stderr,
 
428
            "USAGE: %s [OPTIONS]\n"
 
429
            "\n"
 
430
            "OPTIONS:\n", prog);
 
431
 
 
432
    fprintf(stderr,
 
433
            "  -d\t\t\tdump all traffic\n"
 
434
            "  -D TOKEN[,...]\tturn on debugging output for the specified "
 
435
            "TOKENs\n"
 
436
            "\t\t\t   (ALL gives extremely verbose debugging output)\n"
 
437
            "  -f\t\t\tDo not fork() from the calling shell.\n"
 
438
            "  -h\t\t\tdisplay this help message\n"
 
439
            "  -H\t\t\tdisplay a list of configuration file directives\n"
 
440
            "  -L LOGOPTS\t\tToggle various defaults controlling logging:\n");
 
441
    snmp_log_options_usage("\t\t\t  ", stderr);
 
442
#ifndef DISABLE_MIB_LOADING
 
443
    fprintf(stderr,
 
444
            "  -m MIB[:...]\t\tload given list of MIBs (ALL loads "
 
445
            "everything)\n"
 
446
            "  -M DIR[:...]\t\tlook in given list of directories for MIBs\n");
 
447
#endif /* DISABLE_MIB_LOADING */
 
448
#ifndef DISABLE_MIB_LOADING
 
449
    fprintf(stderr,
 
450
            "  -P MIBOPTS\t\tToggle various defaults controlling mib "
 
451
            "parsing:\n");
 
452
    snmp_mib_toggle_options_usage("\t\t\t  ", stderr);
 
453
#endif /* DISABLE_MIB_LOADING */
 
454
    fprintf(stderr,
 
455
            "  -v\t\t\tdisplay package version number\n"
 
456
            "  -x TRANSPORT\tconnect to master agent using TRANSPORT\n");
 
457
    exit(1);
 
458
}
 
459
 
 
460
static void
 
461
version(void)
 
462
{
 
463
    fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
 
464
    exit(0);
 
465
}
 
466
 
416
467
int
417
 
main (int argc, char **argv) {
418
 
  /* print log errors to stderr */
419
 
  snmp_enable_stderrlog();
420
 
 /* we are a subagent */
421
 
  netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
422
 
 
423
 
  /* initialize tcpip, if necessary */
424
 
  SOCK_STARTUP;
 
468
main (int argc, char **argv)
 
469
{
 
470
  int arg;
 
471
  char* cp = NULL;
 
472
  int dont_fork = 0, do_help = 0;
 
473
 
 
474
  while ((arg = getopt(argc, argv, "dD:fhHL:"
 
475
#ifndef DISABLE_MIB_LOADING
 
476
                       "m:M:"
 
477
#endif /* DISABLE_MIB_LOADING */
 
478
                       "n:"
 
479
#ifndef DISABLE_MIB_LOADING
 
480
                       "P:"
 
481
#endif /* DISABLE_MIB_LOADING */
 
482
                       "vx:")) != EOF) {
 
483
    switch (arg) {
 
484
    case 'd':
 
485
      netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
 
486
                             NETSNMP_DS_LIB_DUMP_PACKET, 1);
 
487
      break;
 
488
 
 
489
    case 'D':
 
490
      debug_register_tokens(optarg);
 
491
      snmp_set_do_debugging(1);
 
492
      break;
 
493
 
 
494
    case 'f':
 
495
      dont_fork = 1;
 
496
      break;
 
497
 
 
498
    case 'h':
 
499
      usage(argv[0]);
 
500
      break;
 
501
 
 
502
    case 'H':
 
503
      do_help = 1;
 
504
      break;
 
505
 
 
506
    case 'L':
 
507
      if (snmp_log_options(optarg, argc, argv) < 0) {
 
508
        exit(1);
 
509
      }
 
510
      break;
 
511
 
 
512
#ifndef DISABLE_MIB_LOADING
 
513
    case 'm':
 
514
      if (optarg != NULL) {
 
515
        setenv("MIBS", optarg, 1);
 
516
      } else {
 
517
        usage(argv[0]);
 
518
      }
 
519
      break;
 
520
 
 
521
    case 'M':
 
522
      if (optarg != NULL) {
 
523
        setenv("MIBDIRS", optarg, 1);
 
524
      } else {
 
525
        usage(argv[0]);
 
526
      }
 
527
      break;
 
528
#endif /* DISABLE_MIB_LOADING */
 
529
 
 
530
    case 'n':
 
531
      if (optarg != NULL) {
 
532
        app_name = optarg;
 
533
        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
 
534
                              NETSNMP_DS_LIB_APPTYPE, app_name);
 
535
      } else {
 
536
        usage(argv[0]);
 
537
      }
 
538
      break;
 
539
 
 
540
#ifndef DISABLE_MIB_LOADING
 
541
    case 'P':
 
542
      cp = snmp_mib_toggle_options(optarg);
 
543
      if (cp != NULL) {
 
544
        fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
 
545
        usage(argv[0]);
 
546
      }
 
547
      break;
 
548
#endif /* DISABLE_MIB_LOADING */
 
549
 
 
550
    case 'v':
 
551
      version();
 
552
      break;
 
553
 
 
554
    case 'x':
 
555
      if (optarg != NULL) {
 
556
        netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
 
557
                              NETSNMP_DS_AGENT_X_SOCKET, optarg);
 
558
      } else {
 
559
        usage(argv[0]);
 
560
      }
 
561
      break;
 
562
 
 
563
    default:
 
564
      fprintf(stderr, "invalid option: -%c\n", arg);
 
565
      usage(argv[0]);
 
566
      break;
 
567
    }
 
568
  }
 
569
 
 
570
  if (do_help) {
 
571
    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
 
572
                           NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
 
573
  } else {
 
574
    /* we are a subagent */
 
575
    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
 
576
                           NETSNMP_DS_AGENT_ROLE, 1);
 
577
 
 
578
    if (!dont_fork) {
 
579
      if (netsnmp_daemonize(1, snmp_stderrlog_status()) != 0)
 
580
        exit(1);
 
581
    }
 
582
 
 
583
    /* initialize tcpip, if necessary */
 
584
    SOCK_STARTUP;
 
585
  }
425
586
 
426
587
  /* initialize the agent library */
427
 
  init_agent("$outname");
 
588
  init_agent(app_name);
428
589
 
429
590
  /* initialize your mib code here */
430
591
EOF
445
606
  /* $outname will be used to read $outname.conf files. */
446
607
  init_snmp("$outname");
447
608
 
 
609
  if (do_help) {
 
610
    fprintf(stderr, "Configuration directives understood:\n");
 
611
    read_config_print_usage("  ");
 
612
    exit(0);
 
613
  }
 
614
 
448
615
  /* In case we received a request to stop (kill -TERM or kill -INT) */
449
616
  netsnmp_running = 1;
450
617
#ifdef SIGTERM
460
627
  }
461
628
 
462
629
  /* at shutdown time */
463
 
  snmp_shutdown("$outname");
 
630
  snmp_shutdown(app_name);
464
631
  SOCK_CLEANUP;
465
632
  exit(0);
466
633
}