App-Netdisco

 view release on metacpan or  search on metacpan

bin/netdisco-backend  view on Meta::CPAN

use strict;
use warnings;

our $home;

BEGIN {
  use FindBin;
  FindBin::again();

  my $me = File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript);
  my $uid = (stat($me))[4] || 0;

  $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});

  # try to find a localenv if one isn't already in place.
  if (!exists $ENV{PERL_LOCAL_LIB_ROOT}) {
      use File::Spec;
      my $localenv = File::Spec->catfile($FindBin::Bin, 'localenv');
      exec($localenv, $0, @ARGV) if -f $localenv;
      $localenv = File::Spec->catfile($home, 'perl5', 'bin', 'localenv');
      exec($localenv, $0, @ARGV) if -f $localenv;

bin/netdisco-backend  view on Meta::CPAN

  die "error: cannot find Netdisco config at $template_config or $app_config\n";
}

my $netdisco = file($FindBin::RealBin, 'netdisco-backend-fg');
my @args = (scalar @ARGV > 1 ? @ARGV[1 .. $#ARGV] : ());

my $log_dir = dir($home, 'logs');
mkdir $log_dir if ! -d $log_dir;
my $log_file = file($log_dir, 'netdisco-backend.log');

my $uid = (stat($netdisco->stringify))[4] || 0;
my $gid = (stat($netdisco->stringify))[5] || 0;

my $old_pid = file($home, 'netdisco-daemon.pid');
my $new_pid = file($home, 'netdisco-backend.pid');
if (-f $old_pid) { File::Copy::move( $old_pid, $new_pid ) }

Daemon::Control->new({
  name => 'Netdisco Backend',
  program  => \&restarter,
  program_args => [@args],
  pid_file => $new_pid,

bin/netdisco-daemon  view on Meta::CPAN

use warnings;

use FindBin;
FindBin::again();

use File::Spec;
use Cwd 'realpath';
use File::Copy 'move';

my $me = realpath(File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript));
my $uid = (stat($me))[4] || 0;
my $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});

my $old_pid = File::Spec->catfile($home, 'netdisco-daemon.pid');
my $new_pid = File::Spec->catfile($home, 'netdisco-backend.pid');
if (-f $old_pid) { move( $old_pid, $new_pid ) }

my $backend =
  File::Spec->catfile((File::Spec->splitpath( $me ))[1], 'netdisco-backend');
exec {$backend} 'netdisco-backend', @ARGV;

bin/netdisco-daemon-fg  view on Meta::CPAN

use strict;
use warnings;

use FindBin;
FindBin::again();

use File::Spec;
use Cwd 'realpath';

my $me = realpath(File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript));
my $uid = (stat($me))[4] || 0;
my $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});

my $backend =
  File::Spec->catfile((File::Spec->splitpath( $me ))[1], 'netdisco-backend-fg');
exec {$backend} 'netdisco-backend-fg', @ARGV;

bin/netdisco-web  view on Meta::CPAN

use strict;
use warnings;

our $home;

BEGIN {
  use FindBin;
  FindBin::again();

  my $me = File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript);
  my $uid = (stat($me))[4] || 0;

  $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});

  # try to find a localenv if one isn't already in place.
  if (!exists $ENV{PERL_LOCAL_LIB_ROOT}) {
      use File::Spec;
      my $localenv = File::Spec->catfile($FindBin::Bin, 'localenv');
      exec($localenv, $0, @ARGV) if -f $localenv;
      $localenv = File::Spec->catfile($home, 'perl5', 'bin', 'localenv');
      exec($localenv, $0, @ARGV) if -f $localenv;

bin/netdisco-web  view on Meta::CPAN

  die "error: cannot find Netdisco config at $template_config or $app_config\n";
}

my $netdisco = file($FindBin::RealBin, 'netdisco-web-fg');
my @args = (scalar @ARGV > 1 ? @ARGV[1 .. $#ARGV] : ());

if (exists $ENV{PORT} and 0 == scalar grep { $_ =~ m/port/ } @args) {
    push @args, "--port=$ENV{PORT}";
}

my $uid = (stat($netdisco->stringify))[4] || 0;
my $gid = (stat($netdisco->stringify))[5] || 0;

my $log_dir = dir($home, 'logs');
mkdir $log_dir if ! -d $log_dir;
chown $uid, $gid, $log_dir;

my $pid_file = file($home, 'netdisco-web.pid');
my $log_file = file($log_dir, 'netdisco-web.log');

# change ownership of key files to be netdisco user
foreach my $file ($pid_file, $log_file) {

lib/App/Netdisco/AnyEvent/Nbtstat.pm  view on Meta::CPAN

App::Netdisco::AnyEvent::Nbtstat - Request NetBIOS node status with AnyEvent

=head1 SYNOPSIS

    use App::Netdisco::AnyEvent::Nbtstat;;

    my $request = App::Netdisco::AnyEvent::Nbtstat->new();

    my $cv = AE::cv;

    $request->nbtstat(
        '127.0.0.1',
        sub {
            my $result = shift;
            print "MAC: ", $result->{'mac_address'} || '', " ";
            print "Status: ", $result->{'status'}, "\n";
            printf '%3s %-18s %4s %-18s', '', 'Name', '', 'Type'
                if ( $result->{'status'} eq 'OK' );
            print "\n";
            for my $rr ( @{ $result->{'names'} } ) {
                printf '%3s %-18s <%02s> %-18s', '', $rr->{'name'},

lib/App/Netdisco/AnyEvent/Nbtstat.pm  view on Meta::CPAN

    $request->timeout(2);

Maximum request response time, defaults to 0.5 seconds.

=head1 METHODS

L<App::Netdisco::AnyEvent::Nbtstat> implements the following methods.

=head2 C<nbtstat>

    $request->nbtstat($ip, sub {
        my $result = shift;
    });

Perform a NetBIOS node status request of $ip.

=head1 SEE ALSO

L<AnyEvent>

=cut

lib/App/Netdisco/Environment.pm  view on Meta::CPAN

use File::ShareDir 'dist_dir';
use Path::Class;
use FindBin;

BEGIN {
  if (not ($ENV{DANCER_APPDIR} || '')
      or not -f file($ENV{DANCER_APPDIR}, 'config.yml')) {

      FindBin::again();
      my $me = File::Spec->catfile($FindBin::RealBin, $FindBin::RealScript);
      my $uid = (stat($me))[4] || 0;
      my $home = ($ENV{NETDISCO_HOME} || (getpwuid($uid))[7] || $ENV{HOME});
      $ENV{NETDISCO_HOME} ||= $home;

      my $auto = dir(dist_dir('App-Netdisco'))->absolute;

      $ENV{DANCER_APPDIR}  ||= $auto->stringify;
      $ENV{DANCER_CONFDIR} ||= $auto->stringify;

      my $test_envdir = dir($home, 'environments')->stringify;
      $ENV{DANCER_ENVDIR} ||= (-d $test_envdir

lib/App/Netdisco/Util/Nbtstat.pm  view on Meta::CPAN

        interval => $interval
    );

    # Set up the condvar
    my $cv = AE::cv;
    $cv->begin( sub { shift->send } );

    foreach my $hash_ref (@$ips) {
        my $ip = $hash_ref->{'ip'};
        $cv->begin;
        $stater->nbtstat(
            $ip,
            sub {
                my $res = shift;
                _filter_nbname( $ip, $hash_ref, $res );
                $cv->end;
            }
        );
    }

    # Decrement the cv counter to cancel out the send declaration



( run in 1.073 second using v1.01-cache-2.11-cpan-49f99fa48dc )