* Made some progress on displaying the network state on an HTML page using jquery. It's ugly as sin, but it works.

* Fixed a bug in Storage->write_file() where the parent directory wasn't created if it was missing. Also removed passing the mode to the parent directory creation as the file mode rarely applies to the directory (ie: 644 breaks directories but is common for files).
* Changed Template->skin to return just the skin name, not the path.
* Updated scancore-update-states to write the network state information to both xml (for ScanCore) and JSON (for jquery) files.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 8 years ago
parent bea6bc5e69
commit 8c42b78e63
  1. 7
      AN/Tools.pm
  2. 30
      AN/Tools/Storage.pm
  3. 10
      AN/Tools/Template.pm
  4. 5
      AN/Tools/Words.pm
  5. 77
      cgi-bin/home
  6. 9
      cgi-bin/words.xml
  7. BIN
      html/skins/alteeve/images/Texture.jpg
  8. BIN
      html/skins/alteeve/images/logo.png
  9. BIN
      html/skins/alteeve/images/network-wired-connected.png
  10. BIN
      html/skins/alteeve/images/network-wired-disconnected.png
  11. 3
      html/skins/alteeve/images/sources.txt
  12. 83
      html/skins/alteeve/main.css
  13. 94
      html/skins/alteeve/main.html
  14. 22
      html/skins/alteeve/main.js
  15. 6
      tools/scancore-daemon
  16. 75
      tools/scancore-update-states
  17. 2
      units/scancore-daemon.service

@ -563,6 +563,9 @@ sub _set_paths
'scancore-daemon' => "/usr/sbin/striker/scancore-daemon",
'scancore-update-states' => "/usr/sbin/striker/scancore-update-states",
},
urls => {
skins => "/skins",
},
words => {
'an-tools.xml' => "/usr/share/perl5/AN/an-tools.xml",
},
@ -571,8 +574,8 @@ sub _set_paths
# Make sure we actually have the requested files.
foreach my $type (sort {$a cmp $b} keys %{$an->data->{path}})
{
# We don't look for logs because we'll create them if they don't exist.
next if $type eq "logs";
# We don't look for urls because they're relative to the domain.
next if $type eq "urls";
foreach my $file (sort {$a cmp $b} keys %{$an->data->{path}{$type}})
{
if (not -e $an->data->{path}{$type}{$file})

@ -128,13 +128,13 @@ sub change_mode
if (not $error)
{
my $shell_call = $an->data->{path}{exe}{'chmod'}." $mode $target";
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0011", variables => { shell_call => $shell_call }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0011", variables => { shell_call => $shell_call }});
open (my $file_handle, $shell_call." 2>&1 |") or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{
chomp;
my $line = $_;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0017", variables => { line => $line }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0017", variables => { line => $line }});
}
close $file_handle;
}
@ -174,7 +174,7 @@ sub change_owner
my $target = defined $parameter->{target} ? $parameter->{target} : "";
my $group = defined $parameter->{group} ? $parameter->{group} : "";
my $user = defined $parameter->{user} ? $parameter->{user} : "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
target => $target,
group => $group,
user => $user,
@ -201,13 +201,13 @@ sub change_owner
if ((not $error) && ($string))
{
my $shell_call = $an->data->{path}{exe}{'chown'}." $string $target";
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0011", variables => { shell_call => $shell_call }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0011", variables => { shell_call => $shell_call }});
open (my $file_handle, $shell_call." 2>&1 |") or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{
chomp;
my $line = $_;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0017", variables => { line => $line }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0017", variables => { line => $line }});
}
close $file_handle;
}
@ -329,7 +329,7 @@ sub make_directory
my $group = defined $parameter->{group} ? $parameter->{group} : "";
my $mode = defined $parameter->{mode} ? $parameter->{mode} : "";
my $user = defined $parameter->{user} ? $parameter->{user} : "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
directory => $directory,
group => $group,
mode => $mode,
@ -342,17 +342,19 @@ sub make_directory
{
next if not $directory;
$working_directory .= "/$directory";
if (-e $working_directory)
$working_directory =~ s/\/\//\//g;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { working_directory => $working_directory }});
if (not -e $working_directory)
{
# Directory doesn't exist, so create it.
my $shell_call = $an->data->{path}{exe}{'mkdir'}." ".$working_directory;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0011", variables => { shell_call => $shell_call }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0011", variables => { shell_call => $shell_call }});
open (my $file_handle, $shell_call." 2>&1 |") or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{
chomp;
my $line = $_;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0017", variables => { line => $line }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0017", variables => { line => $line }});
}
close $file_handle;
@ -703,7 +705,7 @@ sub write_file
my $mode = defined $parameter->{mode} ? $parameter->{mode} : "";
my $overwrite = defined $parameter->{overwrite} ? $parameter->{overwrite} : 0;
my $user = defined $parameter->{user} ? $parameter->{user} : "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
body => $body,
file => $file,
group => $group,
@ -731,24 +733,24 @@ sub write_file
{
# Break the directory off the file.
my ($directory, $file_name) = ($file =~ /^(\/.*)\/(.*)$/);
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
directory => $directory,
file_name => $file_name,
}});
if (not -d $directory)
if (not -e $directory)
{
# Don't pass the mode as the file's mode is likely not executable.
$an->Storage->make_directory({
directory => $directory,
group => $group,
mode => $mode,
user => $user,
});
}
# Now write the file.
my $shell_call = $file;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0013", variables => { shell_call => $shell_call }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0013", variables => { shell_call => $shell_call }});
open (my $file_handle, ">", $shell_call) or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0016", variables => { shell_call => $shell_call, error => $! }});
print $file_handle $body;
close $file_handle;

@ -12,6 +12,7 @@ my $THIS_FILE = "Template.pm";
### Methods;
# get
# skin
=pod
@ -125,7 +126,7 @@ sub get
# If the user passed the skin, prepend the skins directory. Otherwise use the active skin.
if (not $skin)
{
$skin = $an->Template->skin;
$skin = $an->data->{path}{directories}{skins}."/".$an->Template->skin;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { skin => $skin }});
}
else
@ -211,10 +212,9 @@ sub get
return($template);
}
=head2 skin
This sets or returns the active skin used when rendering web output. The returned string is the full path to the skin directory, including the active skin name.
This sets or returns the active skin used when rendering web output.
The default skin is set via 'C<< defaults::template::html >>' and it must be the same as the directory name under 'C<< /var/www/html/skins/ >>'.
@ -242,7 +242,7 @@ sub skin
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { skin_directory => $skin_directory }});
if (-d $skin_directory)
{
$self->{SKIN}{HTML} = $skin_directory;
$self->{SKIN}{HTML} = $set;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'SKIN::HTML' => $self->{SKIN}{HTML} }});
}
else
@ -253,7 +253,7 @@ sub skin
if (not $self->{SKIN}{HTML})
{
$self->{SKIN}{HTML} = $an->data->{path}{directories}{skins}."/".$an->data->{defaults}{template}{html};
$self->{SKIN}{HTML} = $an->data->{defaults}{template}{html};
}
return($self->{SKIN}{HTML});

@ -265,8 +265,9 @@ sub read
my $an = $self->parent;
# Setup default values
my $file = defined $parameter->{file} ? $parameter->{file} : 0;
my $return_code = 0;
my $file = defined $parameter->{file} ? $parameter->{file} : 0;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
if (not $file)
{
@ -283,7 +284,7 @@ sub read
elsif (not -r $file)
{
# NOTE: Log the problem, do not translate.
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => "[ Error ] - Words->read()' asked to read: [$file] which was not readable by: [".getpwuid($<)."/".getpwuid($>)."] (uid/euid: [".$<."/".$>."])."});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => "[ Error ] - Words->read()' asked to read: [$file] which was not readable by: [".getpwuid($<)."] (uid/euid: [".$<."])."});
$return_code = 3;
}
else

@ -3,6 +3,7 @@
use strict;
use warnings;
use AN::Tools;
use Data::Dumper;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
@ -25,21 +26,77 @@ $an->Words->read({file => $an->data->{path}{directories}{'cgi-bin'}."/words.xml"
$| = 1;
my $header = $an->Template->get({file => "main.html", name => "header", variables => {
language => $an->Words->language,
skin_directory => $an->Template->skin,
language => $an->Words->language,
skin_url => $an->data->{path}{urls}{skins}."/".$an->Template->skin,
}});
my $footer = $an->Template->get({file => "main.html", name => "footer"});
my $network = get_network_details($an);
my $template = $an->Template->get({file => "main.html", name => "master", variables => {
header => $header,
left_top_bar => "",
center_top_bar => "",
right_top_bar => "",
center_body => "",
left_bottom_bar => "",
center_bottom_bar => "",
right_bottom_bar => "",
footer => "",
skin_url => $an->data->{path}{urls}{skins}."/".$an->Template->skin,
left_top_bar => "&nbsp;",
center_top_bar => "$network",
right_top_bar => "&nbsp;",
center_body => "&nbsp;",
left_bottom_bar => "&nbsp;",
center_bottom_bar => "&nbsp;",
right_bottom_bar => "&nbsp;",
footer => $footer,
}});
print $template;
exit(0);
#############################################################################################################
# Functions #
#############################################################################################################
# This reads the network status XML file and creates the template body.
sub get_network_details
{
my ($an) = @_;
my $file = $an->data->{path}{directories}{html}."/status/network.xml";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
my $xml = XML::Simple->new();
my $data = "";
my $network = "";
eval { $data = $xml->XMLin($file, KeyAttr => { interface => 'name', key => 'name' }, ForceArray => [ 'interface', 'key' ]) };
if ($@)
{
chomp $@;
my $error = "[ Error ] - The was a problem reading: [$file]. The error was:\n";
$error .= "===========================================================\n";
$error .= $@."\n";
$error .= "===========================================================\n";
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => $error});
}
else
{
my $interface_list = "";
$network = $an->Template->get({file => "main.html", name => "network_header"});
foreach my $interface (sort {$a cmp $b} keys %{$data->{interface}})
{
$interface_list .= "$interface,";
$network .= $an->Template->get({file => "main.html", name => "network_entry", variables => {
#mac => $data->{interface}{$interface}{mac},
mac => "",
mac_id => $interface."_mac",
name => $interface,
name_id => $interface."_name",
#speed => $data->{interface}{$interface}{speed},
speed => "",
speed_id => $interface."_speed",
#'link' => $data->{interface}{$interface}{'link'},
'link' => "",
link_id => $interface."_link",
}});
}
$interface_list =~ s/,$//;
$network .= $an->Template->get({file => "main.html", name => "network_footer", variables => { interface_list => $interface_list }});
}
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network => $network }});
return($network);
}

@ -17,6 +17,14 @@ This is the AN::Tools master 'words' file.
<key name="brand_0002">Anvil!</key>
<key name="brand_0003">Striker</key>
<key name="brand_0004">ScanCore</key>
<key name="brand_0005"><![CDATA[&copy; 2017 <a href="https://alteeve.com/" target="_new">Alteeve's Niche! Inc.</a>, Toronto, Ontario, Canada]]></key>
<key name="header_0001">Network Interfaces</key>
<key name="header_0002">MAC Address</key>
<key name="header_0003">Current Name</key>
<key name="header_0004">Link State</key>
<key name="header_0005">Link Speed (Mbps)</key>
</language>
<!-- 日本語 -->
@ -26,6 +34,7 @@ This is the AN::Tools master 'words' file.
<key name="brand_0002">Anvil!</key>
<key name="brand_0003">ストライカ</key>
<key name="brand_0004">スカンコア</key>
<key name="brand_0005"><![CDATA[&copy; 2017 <a href="https://alteeve.com/" target="_new">Alteeve's Niche! Inc.</a>, トロント、オンタリオ、カナダ]]></key>
</language>
</words>

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -0,0 +1,3 @@
From the gnome project;
- network-wired-connected.png
- network-wired-disconnected.png

@ -1,14 +1,81 @@
/*
Colours;
- Darkest Gray: #343434
- Logo Gray: #9ba0a5
- Lightest Gray: #f7f7f7
- Font Dark Gray: #444444
- Font Light Gray: #f2f2f2
- Alteeve Red: #d02724
- Darkest Gray: #343434
- Logo Gray: #9ba0a5
- Lightest Gray: #f7f7f7
- Font Dark Gray: #444444
- Font Light Gray: #f2f2f2
- Alteeve Red: #d02724
- Footer background: #171717
- Footer text: #515151
*/
body {
background-image: url("skins/alteeve/images/Texture.jpg");
background-repeat: repeat-y;
font-family: 'Dejavu Sans', Arial, Helvetica, Verdana, Sans-Serif;
background-image: url("/skins/alteeve/images/Texture.jpg");
background-repeat: repeat;
color: #f2f2f2;
}
.body_table {
width: 90%;
border: 0.1em solid blue;
margin: auto;
top: 0;
position: absolute;
left: 5%
}
table {
border-spacing: 0;
border-collapse: collapse;
}
td {
border: 1px solid green;
padding: 0;
border-collapse: collapse;
}
.logo {
height: 2.5em;
}
.header {
text-align: center;
background: #343434;
color: #f2f2f2;
border-bottom: 0.2em solid #d02724;
}
.header a:link, .header a:visited {
cursor: pointer;
color: #f6f6f6;
text-decoration: none;
}
.header a:hover {
cursor: pointer;
color: #f6f6f6;
text-decoration: none;
}
.footer {
text-align: center;
background: #171717;
font-size: 12px;
color: #515151;
width: 90%;
position: fixed;
bottom: 0;
left: 5%;
}
.footer a:link, .footer a:visited {
cursor: pointer;
text-decoration: none;
color: #515151;
}
.footer a:hover {
cursor: pointer;
text-decoration: none;
color: #616161;
}

@ -1,7 +1,41 @@
<!-- start button_bar -->
<!--end button_bar -->
<!-- start footer -->
<div onload="show_status()" class="footer">
#!string!brand_0005!#
</div>
<!-- end footer -->
<!-- start header -->
<!DOCTYPE html>
<html lang="#!variable!language!#">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Disable caching during development. -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" /> <title>#!string!brand_0001!# - #!string!brand_0003!#</title>
<link rel="stylesheet" href="#!variable!skin_url!#/main.css" media="screen" />
<script type="text/javascript" src="/jquery-latest.js"></script>
<script type="text/javascript" src="#!variable!skin_url!#/main.js"></script>
</head>
<!-- end header -->
<!-- start master -->
#!variable!header!#
<table>
<body>
<table class="body_table">
<tr>
<td class="header" colspan="3">
<img src="#!variable!skin_url!#/images/logo.png" class="logo">
</td>
</tr>
<tr>
<td>
#!variable!left_top_bar!#
@ -30,21 +64,53 @@
</td>
</tr>
</table>
</body>
#!variable!footer!#
</html>
<!-- end master -->
<!-- start header -->
<!DOCTYPE html>
<html lang="#!variable!language!#">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>#!string!brand_0001!# - #!string!brand_0003!#</title>
<link rel="stylesheet" href="#!variable!skin_directory!#/main.css" media="screen" />
<script type="text/javascript" src="#!data!path::directories::html!#/jquery-latest.js"></script>
<script type="text/javascript" src="#!variable!skin_directory!#/main.js"></script>
</head>
<!-- end header -->
<!-- start network_footer -->
<input type="hidden" name="interface_list" id="interface_list" value="#!variable!interface_list!#">
</table>
<!-- end network_footer -->
<!-- start button_bar -->
<!--end button_bar -->
<!-- start network_entry -->
<tr>
<td>
<span name="#!variable!mac_id!#" id="#!variable!mac_id!#">#!variable!mac!#</span>
</td>
<td>
<span name="#!variable!name_id!#" id="#!variable!name_id!#">#!variable!name!#</span>
</td>
<td>
<span name="#!variable!link_id!#" id="#!variable!link_id!#">#!variable!link!#</span>
</td>
<td>
<span name="#!variable!speed_id!#" id="#!variable!speed_id!#">#!variable!speed!#</span>
</td>
</tr>
<!-- end network_entry -->
<!-- start network_header -->
<table id="network_status">
<tr>
<td colspan="4">
#!string!header_0001!#
</td>
</tr>
<tr>
<td>
#!string!header_0002!#
</td>
<td>
#!string!header_0003!#
</td>
<td>
#!string!header_0004!#
</td>
<td>
#!string!header_0005!#
</td>
</tr>
<!-- end network_header -->

@ -0,0 +1,22 @@
$(function() {
var say_up = "Up";
var say_down = "Down";
if($("#network_status").length) {
//alert('network status exists.');
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.networks, function(index, element) {
console.log('entry: ['+index+'], name: ['+element.name+'], mac: ['+element.mac+'], link: ['+element.link+']');
var link = say_up;
if (element.link == 0) {
link = say_down;
}
$("#"+element.name+"_mac").text(element.mac);
$("#"+element.name+"_link").text(link);
});
});
}
if($("#disk_status").length) {
//alert('disk status exists.');
//$("#bar").text('B');
}
});

@ -24,7 +24,7 @@ while(1)
{
update_state_file($an);
sleep 10;
sleep 2;
}
exit(0);
@ -40,12 +40,12 @@ sub update_state_file
my ($an) = @_;
my $shell_call = $an->data->{path}{tools}{'scancore-update-states'};
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0011", variables => { shell_call => $shell_call }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0011", variables => { shell_call => $shell_call }});
open (my $file_handle, $shell_call." 2>&1 |") or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0014", variables => { shell_call => $shell_call, error => $! }});
while(<$file_handle>)
{
chomp;
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0017", variables => { output => $_ }});
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0017", variables => { output => $_ }});
}
close $file_handle;

@ -20,36 +20,7 @@ $an->Log->level(2);
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
$| = 1;
# my $shell_call = "/sys/class/net/ens11/address";
# $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0012", variables => { shell_call => $shell_call }});
# open (my $file_handle, "<$shell_call") or $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0015", variables => { shell_call => $shell_call, error => $! }});;
# while(<$file_handle>)
# {
# chomp;
# my $line = $_;
# $an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0023", variables => { output => $line }});
# print "line: [$line]\n";
# }
# close
my $status = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$status .= "<status>\n";
$status .= report_network($an);
$status .= "</status>\n";
### TODO: Set the 'status.xml' name into 'striker.conf'
# Write the file.
my $output_file = $an->data->{path}{directories}{html}."/status.xml";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output_file => $output_file }});
$an->Storage->write_file({
file => $output_file,
body => $status,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
report_network($an);
exit(0);
@ -62,7 +33,11 @@ sub report_network
{
my ($an) = @_;
my $network = " <network>\n";
# Write out the data in json format.
my $network_json = "{\"networks\":[\n";
my $network_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$network_xml .= "<network>\n";
my $directory = $an->data->{path}{sysfs}{network_interfaces};
local(*DIRECTORY);
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0018", variables => { directory => $directory }});
@ -93,12 +68,42 @@ sub report_network
operational => $operational,
speed => $speed,
}});
$network .= " <interface name=\"$interface\" mac=\"$mac_address\" link=\"$link_state\" duplex=\"$duplex\" state=\"$operational\" speed=\"$speed\">\n";
$network_json .= " { \"name\":\"$interface\", \"mac\":\"$mac_address\", \"link\":\"$link_state\", \"duplex\":\"$duplex\", \"state\":\"$operational\", \"speed\":\"$speed\" },\n";
$network_xml .= " <interface name=\"$interface\" mac=\"$mac_address\" link=\"$link_state\" duplex=\"$duplex\" state=\"$operational\" speed=\"$speed\" />\n";
}
}
closedir(DIRECTORY);
$network .= " <network>\n";
$network_json =~ s/,$//s;
$network_json .= "]}\n";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_json => $network_json }});
$network_xml .= "</network>\n";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_xml => $network_xml }});
### TODO: Set the 'status/network.xml' and 'status/network.json' names into 'striker.conf'
# Write the JSON file.
my $output_json = $an->data->{path}{directories}{html}."/status/network.json";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output_xml => $output_json }});
$an->Storage->write_file({
file => $output_json,
body => $network_json,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
# Write the XML file.
my $output_xml = $an->data->{path}{directories}{html}."/status/network.xml";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output_xml => $output_xml }});
$an->Storage->write_file({
file => $output_xml,
body => $network_xml,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network => $network }});
return($network);
return(0);
}

@ -1,5 +1,5 @@
[Unit]
Description=ScanCore daemon used to handle several jobs as part of the Anvil! IA suite
Description=ScanCore - Anvil! IA Suite
Wants=network.target
[Service]

Loading…
Cancel
Save