1use warnings; 2use strict; 3 4# If you change the class path take a look in get_defaults too, please! 5package Munin::Common::Defaults; 6 7use English qw(-no_match_vars); 8use File::Basename qw(dirname); 9 10# This file's package variables are changed during the build process. 11 12# This variable makes only sense in development environment 13my $COMPONENT_ROOT = dirname(__FILE__) . '/../../..'; 14 15 16our $DROPDOWNLIMIT = 1; 17 18our $MUNIN_PREFIX = ''; 19our $MUNIN_CONFDIR = "$COMPONENT_ROOT/t/config/"; 20our $MUNIN_BINDIR = ''; 21our $MUNIN_SBINDIR = ''; 22our $MUNIN_DOCDIR = ''; 23our $MUNIN_LIBDIR = ''; 24our $MUNIN_HTMLDIR = ''; 25our $MUNIN_CGIDIR = ''; 26our $MUNIN_CGITMPDIR = ''; 27our $MUNIN_DBDIR = ''; 28our $MUNIN_PLUGSTATE = ''; 29our $MUNIN_SPOOLDIR = ''; 30our $MUNIN_MANDIR = ''; 31our $MUNIN_LOGDIR = "$COMPONENT_ROOT/log/"; 32our $MUNIN_STATEDIR = ''; 33our $MUNIN_USER = getpwuid $UID; 34our $MUNIN_GROUP = getgrgid $GID; 35our $MUNIN_PLUGINUSER = getpwuid $UID; 36our $MUNIN_VERSION = 'svn'; 37our $MUNIN_PERL = '/usr/bin/perl'; 38our $MUNIN_PERLLIB = ''; 39our $MUNIN_GOODSH = ''; 40our $MUNIN_BASH = ''; 41our $MUNIN_PYTHON = ''; 42our $MUNIN_RUBY = ''; 43our $MUNIN_OSTYPE = ''; 44our $MUNIN_HOSTNAME = ''; 45our $MUNIN_MKTEMP = ''; 46our $MUNIN_HASSETR = ''; 47 48 49sub get_defaults { 50 my ($class) = @_; 51 52 ## no critic 53 54 no strict 'refs'; 55 my $defaults = {}; 56 for my $g (keys %{"Munin::Common::Defaults::"}) { 57 next unless $g =~ /MUNIN_/; 58 $defaults->{$g} = ${*$g{'SCALAR'}}; 59 } 60 61 ## use critic 62 63 return $defaults; 64} 65 66 67sub export_to_environment { 68 my ($class) = @_; 69 70 my %defaults = %{$class->get_defaults()}; 71 while (my ($k, $v) = each %defaults) { 72 $ENV{$k} = $v; 73 } 74 75 return 76} 77 78 791; 80 81 82__END__ 83 84 85=head1 NAME 86 87Munin::Common::Defaults - Default values defined by installation 88scripts. 89 90 91=head1 PACKAGE VARIABLES 92 93See L<http://munin-monitoring.org/wiki/MuninInstallProcedure> for 94more information on the variables provided by this package. 95 96 97=head1 METHODS 98 99=over 100 101=item B<get_defaults> 102 103 \%defaults = $class->get_defaults() 104 105Returns all the package variables as key value pairs in a hash. 106 107=item B<export_to_environment> 108 109 $class = $class->export_to_environment() 110 111Export all the package variables to the environment. 112 113=back 114 115