diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 9d724330..c5400c06 100755 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -679,6 +679,10 @@ sub connect password => $anvil->Log->secure ? $password : "#!string!log_0186!#", }}); + # Some places will want to pull up the database user, so in case it isn't set (which is + # usual), set it as if we had read it from the config file using the default. + $anvil->data->{database}{$uuid}{name} = $anvil->data->{sys}{database}{name} if not $anvil->data->{database}{$uuid}{name}; + # If not set, we will always ping before connecting. if ((not exists $anvil->data->{database}{$uuid}{ping}) or (not defined $anvil->data->{database}{$uuid}{ping})) { diff --git a/Anvil/Tools/Template.pm b/Anvil/Tools/Template.pm index b1c2ee4e..0122250c 100755 --- a/Anvil/Tools/Template.pm +++ b/Anvil/Tools/Template.pm @@ -240,13 +240,22 @@ sub get }}); if ((not $template_found) or ($template eq "#!not_found!#")) { - # Error! + # Woops! $template = $anvil->Words->string({key => "error_0029", variables => { template => $name, file => $source, }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }}); } + + # If there was a problem processing the template, it will be '#!error!#'. + if ($template eq "#!error!#") + { + $template = $anvil->Words->string({key => "error_0030", variables => { + template => $name, + file => $source, + }}); + } } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }}); diff --git a/cgi-bin/home b/cgi-bin/home index a72db7f0..37e0fa32 100755 --- a/cgi-bin/home +++ b/cgi-bin/home @@ -218,10 +218,12 @@ sub process_task # If we're here, the user is logged in! if ($anvil->data->{cgi}{striker}{value}) { - $anvil->data->{form}{back_link} = "?striker=true"; + $anvil->data->{form}{back_link} = "?striker=true"; + $anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value}; + $anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value}; if ($anvil->data->{cgi}{task}{value} eq "sync") { - $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "striker-sync"}); + process_sync_page($anvil); } else { @@ -253,6 +255,49 @@ sub process_task return(0); } +# This handles tasks related to setting up peer Strikers. +sub process_sync_page +{ + my ($anvil) = @_; + + # Are we adding a new peer? + if ($anvil->data->{cgi}{action}{value} eq "add") + { + #add_sync_peer($anvil); + } + elsif ($anvil->data->{cgi}{action}{value} eq "remove") + { + #remove_sync_peer($anvil); + } + + $anvil->System->get_ips(); + + # We'll want to show the user way to access the local machine. For that, we'll loop through our own IPs. + my $table = ""; + foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{sys}{network}{interface}}) + { + next if (($interface !~ /^bcn/) && ($interface !~ /^ifn/)); + next if not $anvil->Validate->is_ipv4({ip => $anvil->data->{sys}{network}{interface}{$interface}{ip}}); + next if not $anvil->Validate->is_subnet({subnet => $anvil->data->{sys}{network}{interface}{$interface}{subnet}}); + my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/); + + my $host_uuid = $anvil->Get->host_uuid; + my $database_user = $anvil->data->{database}{$host_uuid}{name}; + my $database_port = $anvil->data->{database}{$host_uuid}{port}; + my $network_key = $network_type eq "bcn" ? "striker_0018" : "striker_0022"; + my $say_network = $anvil->Words->string({key => $network_key, variables => { number => $network_number }}); + $table .= $anvil->Template->get({file => "striker.html", name => "striker-sync-inbound", variables => { + access => $database_user."\@".$anvil->data->{sys}{network}{interface}{$interface}{ip}.":".$database_port, + note => $anvil->Words->string({key => "striker_0066", variables => { network => $say_network }}), + }}); + } + + # Build the menu. + $anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "striker-sync", variables => { table => $table }}); + + return(0); +} + # This shows the menus for configuring Striker. sub configure_striker { diff --git a/html/skins/alteeve/main.css b/html/skins/alteeve/main.css index d96bed7c..3c51e376 100644 --- a/html/skins/alteeve/main.css +++ b/html/skins/alteeve/main.css @@ -69,12 +69,18 @@ select { } body { - font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif; - background-image: url("/skins/alteeve/images/Texture.jpg"); + font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif; + background-image: url("/skins/alteeve/images/Texture.jpg"); background-repeat: repeat; color: #f2f2f2; } +a { + font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif; + color: #f2f2f2; + text-decoration: none; +} + table.data_table_nowrap { border: 1px solid #8f8f8f; border-radius: 4px; diff --git a/html/skins/alteeve/main.html b/html/skins/alteeve/main.html index 654e7e8e..824d61b3 100644 --- a/html/skins/alteeve/main.html +++ b/html/skins/alteeve/main.html @@ -219,5 +219,5 @@ - + diff --git a/html/skins/alteeve/striker.html b/html/skins/alteeve/striker.html index 0bed7b63..f8d366ff 100644 --- a/html/skins/alteeve/striker.html +++ b/html/skins/alteeve/striker.html @@ -22,7 +22,7 @@
+ Add or remove Striker peers. + | +
+ Peer dashboards are Striker machines whose databases this Striker will use to record data. If this machine ever needs to be replaced, or goes offline for a period of time, it will automatically pull the data back from any peers that it is missing. + | +
+ |
+