diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm
index 619339ee..2c101499 100755
--- a/Anvil/Tools/System.pm
+++ b/Anvil/Tools/System.pm
@@ -29,6 +29,7 @@ my $THIS_FILE = "System.pm";
# ping
# read_ssh_config
# reload_daemon
+# reboot_needed
# start_daemon
# stop_daemon
# stty_echo
@@ -1694,6 +1695,87 @@ sub reload_daemon
return($return);
}
+=head2 reboot_needed
+
+This sets, clears or checks if the local system needs to be restart.
+
+This returns C<< 1 >> if a reset is currently needed and C<< 0 >> if not.
+
+Parameters;
+
+=head3 set (optional)
+
+If this is set to C<< 1 >>, the reset needed variable is set. If this is set to C<< 0 >>, reset needed is cleared.
+
+=cut
+sub reboot_needed
+{
+ my $self = shift;
+ my $parameter = shift;
+ my $anvil = $self->parent;
+ my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
+
+ my $set = defined $parameter->{set} ? $parameter->{set} : "";
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { set => $set }});
+
+ if (($set) or ($set eq "0"))
+ {
+ ### TODO: stop other systems from using this database.
+ # Am I enabling or disabling?
+ if ($set eq "1")
+ {
+ # Set
+ $anvil->Database->insert_or_update_variables({
+ debug => 2,
+ variable_name => "reboot::needed",
+ variable_value => "1",
+ variable_default => "0",
+ variable_description => "striker_0089",
+ variable_section => "system",
+ variable_source_uuid => $anvil->Get->host_uuid,
+ variable_source_table => "hosts",
+ update_value_only => 1,
+ });
+ }
+ elsif ($set eq "0")
+ {
+ # Clear
+ $anvil->Database->insert_or_update_variables({
+ debug => 2,
+ variable_name => "reboot::needed",
+ variable_value => "0",
+ variable_default => "0",
+ variable_description => "striker_0089",
+ variable_section => "system",
+ variable_source_uuid => $anvil->Get->host_uuid,
+ variable_source_table => "hosts",
+ update_value_only => 1,
+ });
+ }
+ else
+ {
+ # Called with an invalid value.
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0197", variables => { set => $set }});
+ $set = "";
+ }
+ }
+
+ my ($reboot_needed, $variable_uuid, $modified_date) = $anvil->Database->read_variable({debug => $debug, variable_name => "reboot::needed"});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
+ reboot_needed => $reboot_needed,
+ variable_uuid => $variable_uuid,
+ modified_date => $modified_date,
+ }});
+
+ if ($reboot_needed eq "")
+ {
+ $reboot_needed = 0;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { reboot_needed => $reboot_needed }});
+ }
+
+ return($reboot_needed);
+}
+
=head2 start_daemon
This method starts a daemon. The return code from the start request will be returned.
diff --git a/cgi-bin/striker b/cgi-bin/striker
index 52791a9c..bd482670 100755
--- a/cgi-bin/striker
+++ b/cgi-bin/striker
@@ -238,6 +238,7 @@ sub process_task
{
# The 'back' goes home
$anvil->data->{form}{back_link} = "?";
+ my $reset_icon =
$anvil->data->{form}{body} = $anvil->Template->get({file => "striker.html", name => "striker-setup"});
}
}
diff --git a/html/skins/alteeve/images/sources.txt b/html/skins/alteeve/images/sources.txt
index b2b58c7c..28698529 100644
--- a/html/skins/alteeve/images/sources.txt
+++ b/html/skins/alteeve/images/sources.txt
@@ -37,3 +37,10 @@ customize by Trusted Icons from the Noun Project (https://thenounproject.com/ter
configure by iconesia from the Noun Project (https://thenounproject.com/term/configure/1651241/)
- build_icon.png
+
+power by Blair Adams from the Noun Project (https://thenounproject.com/search/?q=power&i=865890)
+- power_icon.png
+
+reset by Mooms from the Noun Project (https://thenounproject.com/search/?q=reset&i=1033425)
+- reboot_icon.png
+
diff --git a/html/skins/alteeve/striker.html b/html/skins/alteeve/striker.html
index cba0e6ba..e6a5aa5b 100644
--- a/html/skins/alteeve/striker.html
+++ b/html/skins/alteeve/striker.html
@@ -257,6 +257,19 @@
#!string!striker_0059!#
+
+
+
+ |
+
+
+
+
+
diff --git a/share/words.xml b/share/words.xml
index 5e33bfc0..c82d3ced 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -78,6 +78,18 @@ Report maintenance mode: #!variable!program!#
This system is in maintenance mode.
This system is NOT in maintenance mode.
+ This system has been set to need a reboot.
+ This system was already set to need a reboot, nothing changed.
+ This system has has been set to no longer need a reboot.
+ This system was not in maintenance mode, nothing changed.
+ Bad call. Usage:
+Set that a reboot is required: #!variable!program!# --set 1
+Clear the need for a reboot: #!variable!program!# --set 0
+Report if a reboot is needed: #!variable!program!#
+
+ This system needs to be rebooted.
+ This system does NOT need to be rebooted.
+
Starting: [#!variable!program!#].
@@ -441,6 +453,9 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
The system will be updated momentarily. This system will now be in maintenance mode until the update is complete.
This indicates whether this system needs to be rebooted or not.
This system is in maintenance mode and is not currently available.
+ Reset this Striker
+ This option will restart the host operating system. This is not currently needed.
+ This machine needs to be rebooted. This option will restart the host operating system.
Configure Network
diff --git a/tools/anvil-clear-reboot b/tools/anvil-clear-reboot
deleted file mode 100755
index b14d1a59..00000000
--- a/tools/anvil-clear-reboot
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/perl
-#
-# Exit codes;
-# 0 = Normal exit.
-# 1 = No database connections available.
-
-use strict;
-use warnings;
-use Anvil::Tools;
-
-# Disable buffering
-$| = 1;
-
-my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
-my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
-if (($running_directory =~ /^\./) && ($ENV{PWD}))
-{
- $running_directory =~ s/^\./$ENV{PWD}/;
-}
-
-my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
-
-$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
-
-# Read switches
-$anvil->Get->switches;
-
-# Connect to DBs.
-$anvil->Database->connect;
-$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
-if (not $anvil->data->{sys}{database}{connections})
-{
- # No databases, exit.
- print $anvil->Words->string({key => "error_0003"})."\n";
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, key => "error_0003"});
- $anvil->nice_exit({exit_code => 1});
-}
-
-# If the uptime is less than ten minutes, clear the reboot flag.
-my $uptime = $anvil->Storage->read_file({file => $anvil->data->{path}{proc}{uptime}});
-
-$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0200"});
-$anvil->Database->insert_or_update_variables({
- variable_name => "reboot::needed",
- variable_value => "0",
- variable_default => "0",
- variable_description => "striker_0089",
- variable_section => "system",
- variable_source_uuid => $anvil->Get->host_uuid,
- variable_source_table => "hosts",
- update_value_only => 1,
-});
-
-# We're done
-$anvil->nice_exit({exit_code => 0});
diff --git a/tools/anvil-maintenance-mode b/tools/anvil-maintenance-mode
index e4da0002..7e5a4abb 100755
--- a/tools/anvil-maintenance-mode
+++ b/tools/anvil-maintenance-mode
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# This set, clears or reports if the host is in mainentance mode or not.
+# This set, clear and report if the host is in mainentance mode or not.
#
# Examples;
# - Enable - anvil-maintenance-mode --set 1
diff --git a/tools/anvil-reboot-needed b/tools/anvil-reboot-needed
new file mode 100755
index 00000000..33444405
--- /dev/null
+++ b/tools/anvil-reboot-needed
@@ -0,0 +1,101 @@
+#!/usr/bin/perl
+#
+# This set, clear and report if the host needs to be rebooted.
+#
+# Examples;
+# - Enable - anvil-reboot-needed --set 1
+# - Disable - anvil-reboot-needed --set 0
+# - Report - anvil-reboot-needed
+#
+# Exit codes;
+# 0 = Normal exit.
+# 1 = No database connections available.
+
+use strict;
+use warnings;
+use Anvil::Tools;
+
+# Disable buffering
+$| = 1;
+
+my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
+my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
+if (($running_directory =~ /^\./) && ($ENV{PWD}))
+{
+ $running_directory =~ s/^\./$ENV{PWD}/;
+}
+
+my $anvil = Anvil::Tools->new({log_level => 2, log_secure => 1});
+
+$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
+
+# Read switches
+$anvil->data->{switches}{set} = "";
+$anvil->Get->switches;
+
+# Connect to DBs.
+$anvil->Database->connect;
+$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
+if (not $anvil->data->{sys}{database}{connections})
+{
+ # No databases, exit.
+ print $anvil->Words->string({key => "error_0003"})."\n";
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, secure => 0, key => "error_0003"});
+ $anvil->nice_exit({exit_code => 1});
+}
+
+my $reboot_needed = $anvil->System->reboot_needed({debug => 2});
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
+
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::set" => $anvil->data->{switches}{set} }});
+if ($anvil->data->{switches}{set} eq "1")
+{
+ # Enable
+ if (not $reboot_needed)
+ {
+ $reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 1});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
+ print $anvil->Words->string({key => "message_0048"})."\n";
+ }
+ else
+ {
+ # Was already set, do nothing
+ print $anvil->Words->string({key => "message_0049"})."\n";
+ }
+}
+elsif ($anvil->data->{switches}{set} eq "0")
+{
+ # Disabled
+ if ($reboot_needed)
+ {
+ $reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 0});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
+ print $anvil->Words->string({key => "message_0050"})."\n";
+ }
+ else
+ {
+ # Was already disabled, do nothing
+ print $anvil->Words->string({key => "message_0051"})."\n";
+ }
+}
+elsif ($anvil->data->{switches}{set})
+{
+ # Bad call
+ print $anvil->Words->string({key => "message_0052", variables => { program => $THIS_FILE }})."\n";
+}
+
+# Get the current state
+
+if ($reboot_needed)
+{
+ # Report that we're in mainteance mode
+ print $anvil->Words->string({key => "message_0053"})."\n";
+}
+else
+{
+ # Report that we're not.
+ print $anvil->Words->string({key => "message_0054"})."\n";
+}
+
+# We're done
+$anvil->nice_exit({exit_code => 0});
diff --git a/tools/anvil-update-system b/tools/anvil-update-system
index 68f80a38..901b1d10 100755
--- a/tools/anvil-update-system
+++ b/tools/anvil-update-system
@@ -114,16 +114,8 @@ my ($reboot) = run_os_update($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot => $reboot }});
# We're done updating
-my ($reboot_needed, $variable_uuid, $modified_date) = $anvil->Database->read_variable({
- variable_name => "reboot::needed",
- variable_source_uuid => $anvil->Get->host_uuid,
- variable_source_table => "hosts",
-});
-$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
- reboot_needed => $reboot_needed,
- variable_uuid => $variable_uuid,
- modified_date => $modified_date,
-}});
+my $reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 1});
+$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
if ($reboot_needed)
{
update_progress($anvil, 100, "message_0039");
@@ -220,17 +212,9 @@ sub run_os_update
{
# Reboot will be needed.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0199"});
- $anvil->Database->insert_or_update_variables({
- variable_name => "reboot::needed",
- variable_value => "1",
- variable_default => "0",
- variable_description => "striker_0089",
- variable_section => "system",
- variable_source_uuid => $anvil->Get->host_uuid,
- variable_source_table => "hosts",
- update_value_only => 1,
- });
+ my $reboot_needed = $anvil->System->reboot_needed({debug => 2, set => 1});
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
}
if ((not $verifying) && ($line =~ /^Verifying /i))