Net-FullAuto

 view release on metacpan or  search on metacpan

lib/Net/FullAuto/FA_Core.pm  view on Meta::CPAN

      } elsif (-1<index $srvout,'The specified service does not exist') {
         print "\n   FATAL ERROR! - The Cygwin cygserver service is NOT",
               " installed:\n\n   ${srvout}To install type:  ",
               "'/bin/cygserver-config'\n\n";
         exit;
      }
   }
   use IPC::Semaphore;
   use IPC::SysV qw(IPC_CREAT SEM_UNDO S_IRWXU);
   push @INC, substr($main::netfull,0,-3);

}

use warnings;
{
   no warnings;
   use Socket;
   require Exporter;
}

our @ISA     = qw(Exporter Net::Telnet Cwd);
our @EXPORT  = qw(%Hosts $localhost getpasswd
                  connect_host get_all_hosts die
                  $username connect_ftp $cron
                  connect_telnet connect_sftp log
                  send_email $log connect_ssh $prod
                  connect_shell connect_secure
                  connect_insecure connect_reverse
                  @invoked $cleanup pick Menu $quiet
                  $progname memnow acquire_semaphore
                  release_semaphore $savetran %hours
                  $increment %month ls_parse $batch
                  cleanup $dest_first_hash %days
                  test_file test_dir timelocal 
                  %GLOBAL @GLOBAL $LOG $fullauto
                  $funkyprompt handle_error @plans
                  $unattended %email_addresses
                  $adminmenu %email_defaults $proxy
                  $service $determine_password
                  persist_get persist_put cache
                  $berkeleydb %admin_menus $^O
                  $cache_root $cache_key username
                  acquire_fa_lock release_fa_lock
                  $choose_pass_expiration fetch
                  %monthconv %mimetypes %admin_menu
                  check_for_amazon_localhost $OUTPUT
                  get_amazon_external_ip $random
                  fa_welcome get_isets cmd_raw
                  connect_berkeleydb $dashboard
                  clean_filehandle);

{
   no warnings;
   use BerkeleyDB;
   use Sys::Hostname;
   our $local_hostname=&Sys::Hostname::hostname();
   use Data::Dump::Streamer;
   use Devel::StackTrace;
   use Time::Local;
   use Crypt::CBC;
   use Crypt::DES;
   use Cwd qw(getcwd);
   use Digest::MD5 qw(md5);
   use Digest::SHA qw(sha256_hex);
   use English;
   use Email::Sender::Simple qw(sendmail);
   use Email::Sender::Transport::SMTP qw();
   use Errno qw(EAGAIN EINTR EWOULDBLOCK);
   use File::HomeDir;
   use File::stat;
   use File::Copy;
   use MIME::Entity;
   use Module::Load::Conditional qw[can_load];
   use Net::Telnet;
   use Getopt::Long;
   use Pod::Usage;
   use Proc::ProcessTable;
   use Term::ReadKey;
   use Term::RawInput;
   use LWP::UserAgent ();
   use LWP::MediaTypes qw(guess_media_type media_suffix);
   use URI ();
   use HTTP::Date ();
   use IO::Handle;
   use IO::Select;
   use IO::Capture::Stderr;
   use Capture::Tiny;
   use String::Random;
   use Symbol qw(qualify_to_ref);
   use Tie::Cache;
   use IO::Pty;
   use POSIX qw(setsid uname getuid geteuid);
   use Want qw(howmany);

};

our $home_dir='~';
if (exists $ENV{HOME} && -d $ENV{HOME}) {
   $home_dir=$ENV{HOME};
} elsif (exists $ENV{USER} && $ENV{USER}) {
   if (-d "/home/$ENV{USER}") {
      $home_dir="/home/$ENV{USER}";
   } elsif (-d "/export/home/$ENV{USER}") {
      $home_dir="/export/home/$ENV{USER}";
   }
} elsif ((getpwuid($<))[7]) {
   $home_dir=(getpwuid($<))[7];
}

BEGIN {

   my $md_='';our $thismonth='';our $thisyear='';
   ($md_,$thismonth,$thisyear)=(localtime)[3,4,5];
   my $mo_=$thismonth;my $yr_=$thisyear;
   $md_="0$md_" if $md_<10;
   $mo_++;$mo_="0$mo_" if $mo_<10;
   my $yr__=sprintf("%02d",$yr_%100);
   my $yr____=(1900+$yr_);
   my $mdy="$mo_$md_$yr__";
   my $mdyyyy="$mo_$md_$yr____";
   my $tm=scalar localtime($^T);

lib/Net/FullAuto/FA_Core.pm  view on Meta::CPAN

      $Net::FullAuto::FA_Core::debug;
   print $Net::FullAuto::FA_Core::LOG
      "\nINFO: main::cmd_raw() (((((((CALLER))))))):\n       ",
      (join ' ',@topcaller),"\n\n"
      if $Net::FullAuto::FA_Core::log &&
      -1<index $Net::FullAuto::FA_Core::LOG,'*';
   my $self=$_[0];
   my $cmd=$_[1];
   my $delay=0;
   my $display=0;
   foreach my $item (@_) {
      if (-1<index $item, '__delay__') {
         if (-1<index $item, '__delay__=') {
            $item=~/__delay__[=](.*)$/;
            $delay=$1||20;
         } else {
            $delay='20';
         }
      } elsif (-1<index $item, '__display__') {
         $display=1;
      }
   }
   my $prompt=$self->prompt();
   $self->print($cmd);
   if ($delay) {
      $delay=$delay*.001;
      select(undef,undef,undef,$delay);
   }
   my $alloutput='';
   my $save='';
   while (1) {
      my $output='';
      ($output,$save)=fetch($self,$save);
      $alloutput.=$output;
      last if $output=~/$prompt/;
   }
   return $alloutput;

}

sub version
{

   can_load(modules => { "Net::FullAuto" => 0 });

my $version=<<VERSION;

This is Net::FullAuto©, v$Net::FullAuto::VERSION
(See  fullauto -V  or  fa -V  for more detail)

Copyright © 2000-2025, Brian M. Kelly  Brian.Kelly\@FullAuto.com

FullAuto© may be copied only under the terms of the GNU Affero General Public
License, which may be found in the FullAuto source distribution.

Complete documentation for FullAuto©, including FAQ lists, should be found on
this system using "man fullauto" or "perldoc fullauto".  If you have access
to the Internet, point your browser at http://www.FullAuto.com/, the
FullAuto© Home Page.

FullAuto© uses the Crypt::DES module which is software developed by
Systemics Ltd (http://www.systemics.com/)
FullAuto uses the Net::SSLeay module which is software developed by the 
OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
and includes cryptographic software written by Eric Young (eay\@cryptsoft.com)
and Tim Hudson (tjh\@cryptsoft.com)
VERSION

   print $version;
   exit;
}

sub users
{

   can_load(modules => { "Term::Menus" => 0 });
   can_load(modules => { "Net::FullAuto" => 0 });
   my $username=&Net::FullAuto::FA_Core::username();
   my $term_menus_path=
      substr($INC{'Term/Menus.pm'},0,
      (rindex $INC{'Term/Menus.pm'},'Term'));
   my $net_fulla_path=
      substr($INC{'Net/FullAuto.pm'},0,
      (rindex $INC{'Net/FullAuto.pm'},'Net'));
   $term_menus_path=~s/\/share\//\/lib\//
      if -1<index $term_menus_path,'share';
   my $o='';
   foreach my $p (@INC) {
      $o=$p;
      last if -1<index $o,$term_menus_path;
      last if "$o/" eq $term_menus_path;
   }
   my @tmlist=();
   if (-f $o.'/auto/Term/Menus/.packlist') {
      open (TH,"<$o/auto/Term/Menus/.packlist");
      while (my $f=<TH>) {
         chomp $f;
         push @tmlist,$f;
      }
      close(TH);
   }
   my @falist=();
   if (-f $o.'/auto/Net/FullAuto/.packlist') {
      open (PH,"<$o/auto/Net/FullAuto/.packlist");
      @falist=<PH>;
      close(PH);
   }
   my $checkpath='';
   foreach my $file (@falist) {
      if (-1<index $file,'Net/FullAuto/Custom') {
         $checkpath=substr($file,0,(index $file,'Net/FullAuto/Custom')+19);
         last;
      }
   }
   my $output=`ls -l $checkpath 2>&1`;
   my ($size,$timestampd,$dirname)=('','','');
   my @users=();
   my $nl=0;
   foreach my $line (split "\n", $output) {
      print "\n" if $nl==1;
      next unless $line=~/^d/;



( run in 2.285 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )