Merged MAPS2.0
authorAndrew DeFaria <Andrew@DeFaria.com>
Thu, 4 Nov 2021 22:17:11 +0000 (15:17 -0700)
committerAndrew DeFaria <Andrew@DeFaria.com>
Thu, 4 Nov 2021 22:17:11 +0000 (15:17 -0700)
bin/announceEmail
bin/announceEmail.pl
bin/raid
etc/raid.conf [new file with mode: 0644]
maps/bin/display.cgi
maps/lib/MAPS.pm
rc/bash_login
rc/system

index d992d89..b775335 100755 (executable)
@@ -6,11 +6,6 @@ case $1 in
     # IMAP server. So instead we use this cheap method of sleeping for a while
     # as the network should be back by then. A better method would be to poll
     # looking for the network to come back up but that's tricker to implement.
-    #
-    # Seems like one kill is not enough. Try 2 - spaced a minute apart
-    /usr/local/bin/setsound.sh 35
-    sleep 60
-    killall -USR2 announceEmail.pl
     sleep 60
     killall -USR2 announceEmail.pl
     ;;
index df5aa91..073e039 100755 (executable)
@@ -366,7 +366,7 @@ if ($opts{username} =~ /(.*)\@/) {
 
 my $msg = "Now monitoring email for $opts{user}\@$opts{name}";
 
-speak $msg if $opts{announce};
+speak $msg, $log if $opts{announce};
 
 $log->msg($msg);
 
index 3e630c6..6889331 100755 (executable)
--- a/bin/raid
+++ b/bin/raid
@@ -255,13 +255,14 @@ my $VERSION  = '$Revision: 1.1 $';
 
 my (%opts, %funcs, %allcmds, %modules, $debugshVer);
 
-%opts = GetConfig "$FindBin::Bin/etc/$FindBin::Script.conf";
+%opts = GetConfig "$FindBin::Bin/../etc/$FindBin::Script.conf";
 
 my $debugshPid;
 my $name = 'RAiD';
 
-error "$name is not supported on 64 bit versions of Perl", 1
-  if $Config{archname} =~ /64/;
+# Not sure why this was not supported on 64 bit Perls...
+#error "$name is not supported on 64 bit versions of Perl", 1
+#  if $Config{archname} =~ /64/;
 
 my %raidCmds = (
   appiddisplay  => {
@@ -419,16 +420,16 @@ sub parseh ($) {
       # does not previously appear, even if abbreviated. So we can't have say
       # a new command - "my command" - when we already had a command such as
       # "my command is nice".
-      foreach (keys %funcs) {
+      for (keys %funcs) {
         error "Ambiguous command \"$userinput\" & \"$_\" found in $h", 1
           if /^$userinput /;
-      } # foreach
+      } # for
 
       # Now test for the other way where we already have "my command" in %funcs
       # and we are trying to add "my command is nice".
       my $str;
 
-      foreach my $word (split /\s+/, $userinput) {
+      for my $word (split /\s+/, $userinput) {
         if ($str) {
           $str .= " $word";
         } else {
@@ -438,7 +439,7 @@ sub parseh ($) {
         # See if this exactly matches any existing key
         error "Ambiguous command \"$userinput\" & \"$_\" found in $h", 1
           if $funcs{$str};
-      } # foreach
+      } # for
 
       $funcs{$userinput}{funcname}    = $funcname;    undef $funcname;
       $funcs{$userinput}{help}        = $help;        undef $help;
@@ -541,23 +542,23 @@ sub loadModules ($) {
 
   closedir $rc;
 
-  foreach (@modules) {
+  for (@modules) {
     my $moduleFile = "$rcdir/$_";
     my $module     = moduleName $moduleFile;
     my %funcs      = parseh $moduleFile; 
 
-    foreach (keys %funcs) {
+    for (keys %funcs) {
       error "Duplicate definition $_ found in $moduleFile", 1
         if defined $moduleFuncs{$_};
 
       $moduleFuncs{$_} = $funcs{$_};
-    } # foreach
+    } # for
 
     $modules{$module} = {
       moduleFile => $moduleFile,
       loaded     => 0,
     };
-  } # foreach
+  } # for
 
   return %moduleFuncs;
 } # loadModules
@@ -569,13 +570,13 @@ sub modules () {
 @<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<
 $moduleName,$moduleStatus
 .
-  foreach $moduleName (sort keys %modules) {
+  for $moduleName (sort keys %modules) {
     next if $moduleName eq 'DbgSh';
 
     $moduleStatus = ($modules{$moduleName}{loaded}) ? 'loaded' : 'not loaded';
 
     write;
-  } # foreach
+  } # for
 
   return;
 } # modules
@@ -689,7 +690,7 @@ sub load ($;$) {
   # Rebuild %allcmds
   %allcmds = %raidCmds;
 
-  $allcmds{$_} = $funcs{$_} foreach (keys %funcs);
+  $allcmds{$_} = $funcs{$_} for (keys %funcs);
 
   # Set cmds
   $CmdLine::cmdline->set_cmds (%allcmds);
@@ -836,7 +837,7 @@ sub init () {
   } # if 
 
   # Load commands from config file (Type 2 commands)
-  foreach (keys %opts) {
+  for (keys %opts) {
     my $cmd;
 
     if (/^type2_(\S+)/) {
@@ -852,16 +853,16 @@ sub init () {
       prototype => "$cmd <cmd>",
       help      => "Send <cmd> (AppID $opts{$_}) to debugsh",
     };
-  } # foreach
+  } # for
 
   # Now combine %funcs, which contain all type 1 and type 2 commands, and
   # %raidCmds, which contain raid commands like load, unload, perl, restart,
   # etc.
   %allcmds = %raidCmds;
 
-  foreach (keys %funcs) {
+  for (keys %funcs) {
     $allcmds{$_} = $funcs{$_};
-  } # foreach
+  } # for
 
   # Initialize debugsh
   my $result = debugshInit;
@@ -920,7 +921,7 @@ sub cmds ($%) {
       $searchStr = $1;
     } # if
 
-    foreach (sort {
+    for (sort {
       $funcs{$a}{type} <=> $funcs{$b}{type} ||
              $a        cmp        $b
     } keys %funcs) {
@@ -957,7 +958,7 @@ sub cmds ($%) {
          $line .= " - $funcs{$_}{help}" if $funcs{$_}{help};
 
       push @output, $line;
-    } # foreach
+    } # for
 
     $CmdLine::cmdline->handleOutput ('', @output);
   } # if
@@ -1009,14 +1010,14 @@ sub callc ($@) {
   # Check to see if we know about this $cmd
   my $found;
 
-  foreach (keys %funcs) {
+  for (keys %funcs) {
     next unless /^$cmd$/i;
 
     if ($cmd eq $_) {
       $found = 1;
       last;
     } # if
-  } # foreach
+  } # for
 
   unless ($found) {
     error "Unknown command: $cmd";
@@ -1223,7 +1224,7 @@ sub evaluate ($) {
     } # if
 
     # Process parms
-    foreach my $parm (@parms) {
+    for my $parm (@parms) {
       # Strip () if they are there
       $parm =~ s/^\s*\(//;
       $parm =~ s/\)\s*$//;
@@ -1233,7 +1234,7 @@ sub evaluate ($) {
       $parm =~ s/\s+$//;
 
       $parm = oct ($parm) if $parm =~ /^0/;
-    } # foreach
+    } # for
 
     $result = callc $userinput, @parms;
   } else {
@@ -1328,16 +1329,16 @@ $CmdLine::cmdline->set_prompt (set_prompt);
 $CmdLine::cmdline->set_cmds (%allcmds);
 $CmdLine::cmdline->set_eval (\&evaluate);
 
-while ((($line, $result) = $CmdLine::cmdline->get)) {
-  last unless defined $line;
+while (($line, $result) = $CmdLine::cmdline->get) {
+  last unless $line;
   next if $line =~ /^\s*($|\#)/;
-  
+
   $result = evaluate $line;
 
-  if (defined $result) {
+  if ($result) {
     if (ref \$result eq 'SCALAR') {
       if ($line =~ /^\s*(\S+)/) {
-  $cmd = $1;
+        $cmd = $1;
       } # if
 
       # We used to output only for raidcmds...
diff --git a/etc/raid.conf b/etc/raid.conf
new file mode 100644 (file)
index 0000000..e69de29
index a8dc765..0a0cfcd 100755 (executable)
@@ -84,6 +84,8 @@ sub Body($) {
 
   my $parser = MIME::Parser->new();
 
+  # For some strange reason MIME::Parser has started having some problems
+  # with writing out tmp files...
   $parser->output_to_core(1);
   $parser->tmp_to_core(1);
 
index 793f015..9627612 100644 (file)
@@ -1481,7 +1481,22 @@ sub Whitelist ($$;$$) {
   close $message;
 
   # Now call MAPSDeliver
-  my $status = system "$FindBin::Bin/MAPSDeliver $userid /tmp/MAPSMessage.$$";
+  my ($status, @output) = Execute "$FindBin::Bin/MAPSDeliver $userid /tmp/MAPSMessage.$$";
+  #my $status = system "$FindBin::Bin/MAPSDeliver $userid /tmp/MAPSMessage.$$";
+
+  if ($status != 0) {
+    my $msg =  "Unable to deliver message (message left at /tmp/MAPSMessage.%%\n\n";
+       $msg .= join "\n", @output;
+
+    Logmsg(
+      userid  => $userid,
+      type    => 'whitelist',
+      sender  => $sender,
+      message => $msg,
+    );
+
+    Error ($msg, 1);
+  } # if
 
   unlink "/tmp/MAPSMessage.$$";
 
index 64b6147..6cab6cd 100644 (file)
@@ -119,6 +119,8 @@ fi
 # Source bash_completion (if present) (too slow for Windows)
 if [ -r /etc/bash_completion -a $ARCHITECTURE != "cygwin" ]; then
   source /etc/bash_completion
+elif [ -r /usr/local/etc/bash_completion ]; then
+  source /usr/local/etc/bash_completion
 fi
 
 # Windows aliases
index a43a36a..8b81616 100644 (file)
--- a/rc/system
+++ b/rc/system
@@ -23,24 +23,8 @@ SYSNAME=$(echo ${SYSNAME:0:1} | tr [:lower:] [:upper:])$(echo ${SYSNAME:1}   | t
 
 # Aliasing
 case "$SYSNAME" in
-  Az25jzhxkb2d)
-    SYSNAME="Venus"
-    ;;
-
-  Cdvra99a0983)
-    SYSNAME="Dev"
-    ;;
-
-  Cuvra99a0983)
-    SYSNAME="UAT"
-    ;;
-
-  Crvra99a0983)
-    SYSNAME="BCP"
-    ;;
-
-  Cpvra99a0983)
-    SYSNAME="Production"
+  Andrews-macbook-pro)
+    SYSNAME="cPanel"
     ;;
 
 esac