Skip to content

Commit

Permalink
Merge branch 'master' of baltig.sandia.gov:scot/SCOT
Browse files Browse the repository at this point in the history
  • Loading branch information
brymon68 committed Jun 1, 2018
2 parents 28ee11c + e9855d0 commit be52307
Show file tree
Hide file tree
Showing 104 changed files with 196,424 additions and 3,164 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ package-lock.json
#compiled scot.js
#scot.js
scot-debug.js
.idea/
3 changes: 2 additions & 1 deletion Dockerfile-Perl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ RUN cpanm --force IO::AIO AnyEvent::AIO Array::Split Data::Dumper Data::Dumper::
MIME::Base64 IPC::Run IO::Prompt Log::Log4perl Mail::IMAPClient Mail::IMAPClient::BodyStructure MongoDB@1.2.3 MongoDB::GridFS@1.2.3 \
MongoDB::GridFS::File@1.2.3 MongoDB::OID@1.2.3 Meerkat Mojo MojoX::Log::Log4perl Mojolicious::Plugin::WithCSRFProtection \
Mojolicious::Plugin::TagHelpers XML::Smart Config::Auto Data::GUID File::LibMagic List::Uniq Domain::PublicSuffix Mozilla::PublicSuffix \
Crypt::PBKDF2 Config::Crontab Test::JSON Math::Int128 GeoIP2 Search::Elasticsearch Term::ANSIColor Courriel Statistics::Descriptive Net::SSH::Perl Net::SFTP Lingua::EN::StopWords Data::Clone XML::Twig
Crypt::PBKDF2 Config::Crontab Test::JSON Math::Int128 GeoIP2 Search::Elasticsearch Term::ANSIColor Courriel Statistics::Descriptive Net::SSH::Perl \
Net::SFTP Lingua::EN::StopWords Data::Clone XML::Twig Mail::Send SVG::Sparkline

#Mongo stuff

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile-Scot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND="noninteractive" \


RUN apt-get update && \
apt-get install apt-utils ca-certificates curl vim -y -f && \
apt-get install apt-utils ca-certificates curl vim ssmtp -y -f && \
update-ca-certificates && \
apt-get autoclean && \
apt-get --purge -y autoremove && \
Expand All @@ -28,6 +28,7 @@ COPY docker-scripts/* /opt/scot/bin/
COPY docker-configs/scot/backup.cfg.pl /opt/scot/etc/
COPY docker-configs/scot/restore.cfg.pl /opt/scot/etc/


RUN groupadd -g 2060 scot && \
useradd -r -u 1060 -g scot scot

Expand Down
2 changes: 1 addition & 1 deletion bin/amq_queue_read_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use DateTime;


my $stomp = AnyEvent::STOMP::Client->new("localhost");
my $stomp = AnyEvent::STOMP::Client->new("localhost", 61613, {login=>"scot", passcode=>"scot1234"});

$stomp->connect();
$stomp->on_connected(
Expand Down
4 changes: 2 additions & 2 deletions bin/amq_queue_send_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
host => '127.0.0.1',
port => 61613,
);
$stomp->connect;
$stomp->connect(login => "scot", passcode => "scot1234");

for my $i (1..10) {

Expand All @@ -26,7 +26,7 @@

my $json = encode_json $href;
$stomp->send(
destination => "/queue/coe",
destination => "/queue/incoming",
body => $json,
);

Expand Down
8 changes: 4 additions & 4 deletions bin/backup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# $env has
#
# pidfile = the pid file for runnign dump
# location = directory to dump the mongodump
# bkuplocation = directory to dump the mongodump
# tarloc = directory to place tar file
# cleanup = true if you wish to remove the dumped directory
# user = if needed, set to user name for db access
Expand All @@ -42,7 +42,7 @@
print $pidfh "$$";
close $pidfh;

my $dumpdir = $env->location;
my $dumpdir = $env->bkuplocation;
unless ($dumpdir) {
warn "$dumpdir is missing! Setting to /tmp/dump";
$dumpdir = "/tmp/dump";
Expand Down Expand Up @@ -197,8 +197,8 @@
print "removing $esdir\n";
system("rm -rf $esdir/*");
}
print "finding and removing old ".$env->location."\n";
system("find ".$env->location." -ctime 7 -print0 | xargs -0 /bin/rm -f");
print "finding and removing old ".$env->bkuplocation."\n";
system("find ".$env->bkuplocation." -ctime 7 -print0 | xargs -0 /bin/rm -f");
print "done";
system("rm -f $pidfile");

Expand Down
237 changes: 237 additions & 0 deletions bin/check_configs.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
#!/usr/bin/env perl

use v5.18;

use lib '../lib';
use Scot::Env;
use Try::Tiny;
use Data::Compare;
use Data::Dumper;



my @required = (
{
config_file => "/opt/scot/etc/scot.cfg.pl",
install_ver => "../install/src/scot/scot.cfg.pl",
attributes => [
"location",
"site_identifier",
"default_share_policy",
"log_config",
"modules",
"get_method",
"default_groups",
"group_mode",
"mode",
"default_groups",
"federation",
"row_limit",
"session_expiration",
"admin_group",
"file_store_root",
"epoch_cols",
"int_cols",
"mojo_defaults",
"entry_actions",
"forms"
],
},
{
config_file => "/opt/scot/etc/alert.cfg.pl",
install_ver => "../install/src/scot/scot.cfg.pl",
attributes => [
"location",
"site_identifier",
"default_share_policy",
"time_zone",
"log_config",
"modules",
"leave_unseen",
"verbose",
"max_processes",
"fetch_mode",
"since",
"approved_alert_domains",
"approved_accounts",
"parser_dir",
"default_groups",
"default_owner",
],
},
{
config_file => "/opt/scot/etc/flair.cfg.pl",
install_ver => "../install/src/scot/flair.cfg.pl",
attributes => [
"location",
"site_identifier",
"default_share_policy",
"time_zone",
"servername",
"username",
"password",
"authtype",
"log_config",
"modules",
"stomp_host",
"stomp_port",
"topic",
"max_workers",
"default_owner",
],
},
{
config_file => "/opt/scot/etc/reflair.cfg.pl",
install_ver => "../install/src/scot/reflair.cfg.pl",
attributes => [
"location",
"site_identifier",
"time_zone",
"servername",
"username",
"password",
"authtype",
"log_config",
"modules",
"stomp_host",
"stomp_port",
"topic",
"max_workers",
],
},
{
config_file => "/opt/scot/etc/backup.cfg.pl",
install_ver => "../install/src/scot/backup.cfg.pl",
attributes => [
"location",
"log_config",
"dbname",
"pidfile",
"bkuplocation",
"cacheimg",
"tarloc",
"cleanup",
"es_server",
"es_backup_location",
],
},
{
config_file => "/opt/scot/etc/restore.cfg.pl",
install_ver => "../install/src/scot/restore.cfg.pl",
attributes => [
"location",
"log_config",
"dbname",
"pidfile",
"bkuplocation",
"cacheimg",
"tarloc",
"cleanup",
"es_server",
"es_backup_location",
],
},
{
config_file => "/opt/scot/etc/game.cfg.pl",
install_ver => "../install/src/scot/game.cfg.pl",
attributes => [
"location",
"log_config",
"days_ago",
"modules",
],
},
{
config_file => "/opt/scot/etc/metrics.cfg.pl",
install_ver => "../install/src/scot/metrics.cfg.pl",
attributes => [
"time_zone",
"log_config",
"modules",
],
},
{
config_file => "/opt/scot/etc/stretch.cfg.pl",
install_ver => "../install/src/scot/stretch.cfg.pl",
attributes => [
"location",
"time_zone",
"log_config",
"max_workers",
"stomp_host",
"stomp_port",
"topic",
"default_owner",
"modules",
],
},
);

my @attrs_needed = ();

foreach my $req (@required) {

my $default = load_config($req->{install_ver});
my $actual = load_config($req->{config_file});

foreach my $attr (@{$req->{attributes}}) {


say "\nAttribute: ".$attr;
say "------------------------------\n";

try {

my $value = $actual->{$attr};
my $default = $default->{$attr};

if ( defined $value ) {
say " attribute exists.";
}
else {
push @attrs_needed, {
config => $req->{config_file},
attribute => $attr,
};
}

if ( examine($default, $value) ) {
say " attribute has default value";
}
else {
say " attribure has changed value";
}
}
catch {
say " ERROR: attribute does not exist in ".
$req->{config_file};
};
}
}

say "________________________________________________";
say "Missing Attributes in configs";
say "________________________________________________";
say Dumper(\@attrs_needed);

sub examine {
my $def = shift;
my $val = shift;
return Compare($def, $val);
}

sub load_config {
my $file = shift;
unless ( -r $file ) {
die "Config file not readable!\n";
};
no strict 'refs';
my $cont = new Safe 'MCONFIG';
my $result = $cont->rdo($file);
my $hname = 'MCONFIG::environment';
my %copy = %$hname;
my $href = \%copy;
return $href;
}


36 changes: 36 additions & 0 deletions bin/fedrec.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env perl

use strict;
use warnings;
use lib '../lib';
use lib '../../lib';
use lib '../../Scot-Internal-Modules/lib';
use lib '/opt/scot/lib';
use v5.18;
use Scot::App::FedRec;
use Data::Dumper;

my $config_file = $ENV{'scot_app_flair_config_file'} //
'/opt/scot/etc/fedrec.cfg.pl';
my $env = Scot::Env->new(
config_file => $config_file,
);

$SIG{__DIE__} = sub { our @reason = @_ };

END {
our @reason;
if (@reason) {
say "$0 died because: @reason";
$env->log->error("$0 died because: ",{filter=>\&Dumper, value=>\@reason});
}
}




my $loop = Scot::App::FedRec->new({
env => $env,
});
$loop->run();

36 changes: 36 additions & 0 deletions bin/fedup.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env perl

use strict;
use warnings;
use lib '../lib';
use lib '../../lib';
use lib '../../Scot-Internal-Modules/lib';
use lib '/opt/scot/lib';
use v5.18;
use Scot::App::Responder::FederateUp;
use Data::Dumper;

my $config_file = $ENV{'scot_app_flair_config_file'} //
'/opt/scot/etc/fedup.cfg.pl';
my $env = Scot::Env->new(
config_file => $config_file,
);

$SIG{__DIE__} = sub { our @reason = @_ };

END {
our @reason;
if (@reason) {
say "$0 died because: @reason";
$env->log->error("$0 died because: ",{filter=>\&Dumper, value=>\@reason});
}
}




my $loop = Scot::App::Responder::FederateUp->new({
env => $env,
});
$loop->run();

Loading

0 comments on commit be52307

Please sign in to comment.