|
|
@ -15,6 +15,7 @@ |
|
|
|
# 1 = No database connections available. |
|
|
|
# 1 = No database connections available. |
|
|
|
# 2 = The job UUID was passed, but it wasn't valid. |
|
|
|
# 2 = The job UUID was passed, but it wasn't valid. |
|
|
|
# 3 = It looks like the update failed, reset progress to '0'. |
|
|
|
# 3 = It looks like the update failed, reset progress to '0'. |
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
use strict; |
|
|
|
use strict; |
|
|
|
use warnings; |
|
|
|
use warnings; |
|
|
@ -38,6 +39,9 @@ $anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"}); |
|
|
|
$anvil->data->{switches}{'job-uuid'} = ""; |
|
|
|
$anvil->data->{switches}{'job-uuid'} = ""; |
|
|
|
$anvil->Get->switches; |
|
|
|
$anvil->Get->switches; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Log that we've started. |
|
|
|
|
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }}); |
|
|
|
|
|
|
|
|
|
|
|
# Connect to DBs. |
|
|
|
# Connect to DBs. |
|
|
|
$anvil->Database->connect; |
|
|
|
$anvil->Database->connect; |
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); |
|
|
|
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); |
|
|
@ -50,6 +54,7 @@ if (not $anvil->data->{sys}{database}{connections}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Did we get called with a job UUID? |
|
|
|
# Did we get called with a job UUID? |
|
|
|
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::job-uuid" => $anvil->data->{switches}{'job-uuid'} }}); |
|
|
|
if ($anvil->data->{switches}{'job-uuid'}) |
|
|
|
if ($anvil->data->{switches}{'job-uuid'}) |
|
|
|
{ |
|
|
|
{ |
|
|
|
# Is it set and valid? |
|
|
|
# Is it set and valid? |
|
|
@ -106,11 +111,14 @@ WHERE |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Clea any old runs. |
|
|
|
|
|
|
|
update_progress($anvil, 0, "clear"); |
|
|
|
|
|
|
|
|
|
|
|
# Mark that we're starting |
|
|
|
# Mark that we're starting |
|
|
|
|
|
|
|
print $THIS_FILE."; time: [".time."], running with PID: [".$$."]\n"; |
|
|
|
update_progress($anvil, 1, "message_0033"); |
|
|
|
update_progress($anvil, 1, "message_0033"); |
|
|
|
|
|
|
|
|
|
|
|
print $THIS_FILE." running with PID: [".$$."]\n" |
|
|
|
|
|
|
|
sleep 60; |
|
|
|
sleep 60; |
|
|
|
|
|
|
|
print $THIS_FILE."; time: [".time."], exiting\n"; |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
|
|
|
|
|
|
|
|
run_os_update($anvil); |
|
|
|
run_os_update($anvil); |
|
|
@ -140,11 +148,23 @@ sub update_progress |
|
|
|
my ($anvil, $progress, $message) = @_; |
|
|
|
my ($anvil, $progress, $message) = @_; |
|
|
|
|
|
|
|
|
|
|
|
# Log the progress percentage. |
|
|
|
# Log the progress percentage. |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { progress => $progress }}); |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { |
|
|
|
|
|
|
|
progress => $progress, |
|
|
|
|
|
|
|
message => $message, |
|
|
|
|
|
|
|
"jobs::job_uuid" => $anvil->data->{jobs}{job_uuid}, |
|
|
|
|
|
|
|
}}); |
|
|
|
|
|
|
|
|
|
|
|
if ($anvil->data->{jobs}{job_uuid}) |
|
|
|
if ($anvil->data->{jobs}{job_uuid}) |
|
|
|
{ |
|
|
|
{ |
|
|
|
# Get the current job_status and append this new one. |
|
|
|
# Get the current job_status and append this new one. |
|
|
|
|
|
|
|
my $job_picked_up_by = $$; |
|
|
|
|
|
|
|
my $job_status = ""; |
|
|
|
|
|
|
|
if ($message eq "clear") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$job_picked_up_by = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
my $query = " |
|
|
|
my $query = " |
|
|
|
SELECT |
|
|
|
SELECT |
|
|
|
job_status |
|
|
|
job_status |
|
|
@ -153,26 +173,31 @@ FROM |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
job_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{jobs}{job_uuid})." |
|
|
|
job_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{jobs}{job_uuid})." |
|
|
|
;"; |
|
|
|
;"; |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); |
|
|
|
|
|
|
|
|
|
|
|
my $job_status = $anvil->Database->query({uuid => $uuid, debug => $debug, query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0]; |
|
|
|
$job_status = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0]; |
|
|
|
$job_status = "" if not defined $old_job_status; |
|
|
|
$job_status = "" if not defined $job_status; |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { job_status => $job_status }}); |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_status => $job_status }}); |
|
|
|
|
|
|
|
|
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { message => $message }}); |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { message => $message }}); |
|
|
|
|
|
|
|
if ($job_status) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$job_status .= "\n"; |
|
|
|
|
|
|
|
} |
|
|
|
if ($message) |
|
|
|
if ($message) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$job_status .= $message."\n"; |
|
|
|
$job_status .= $message; |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { job_status => $job_status }}); |
|
|
|
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_status => $job_status }}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
my $query = " |
|
|
|
my $query = " |
|
|
|
UPDATE |
|
|
|
UPDATE |
|
|
|
jobs |
|
|
|
jobs |
|
|
|
SET |
|
|
|
SET |
|
|
|
job_picked_up_by = ".$anvil->data->{sys}{database}{use_handle}->quote($$).", |
|
|
|
job_picked_up_by = ".$anvil->data->{sys}{database}{use_handle}->quote($job_picked_up_by).", |
|
|
|
job_updated = now(), |
|
|
|
job_updated = ".time.", |
|
|
|
job_progress = ".$progress.", |
|
|
|
job_progress = ".$anvil->data->{sys}{database}{use_handle}->quote($progress).", |
|
|
|
job_status = ".$anvil->data->{sys}{database}{use_handle}->quote($job_status).", |
|
|
|
job_status = ".$anvil->data->{sys}{database}{use_handle}->quote($job_status).", |
|
|
|
modified_date = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{timestamp})." |
|
|
|
modified_date = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{timestamp})." |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|