mirror of
https://github.com/unraid/webgui.git
synced 2026-01-01 23:20:35 -06:00
Revert "plugin & language: replace conflicting logger name"
This reverts commit 2c97bc312c.
This commit is contained in:
@@ -150,7 +150,7 @@ function download($url, $name, &$error) {
|
||||
|
||||
// Deal with logging message.
|
||||
//
|
||||
function logmsg($message) {
|
||||
function logger($message) {
|
||||
shell_exec("logger $message");
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ if ($method == 'install') {
|
||||
copy($xml_file, $lang_file);
|
||||
symlink($lang_file, $link_file);
|
||||
write("language: $lang language pack installed\n");
|
||||
logmsg("language: $lang language pack installed");
|
||||
logger("language: $lang language pack installed");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
@@ -396,7 +396,7 @@ if ($method == 'update') {
|
||||
copy($xml_file, $lang_file);
|
||||
symlink($lang_file, $link_file);
|
||||
write("language: $lang language pack updated\n");
|
||||
logmsg("language: $lang language pack updated");
|
||||
logger("language: $lang language pack updated");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
@@ -423,7 +423,7 @@ if ($method == 'remove') {
|
||||
done(1);
|
||||
}
|
||||
write("language: $lang language pack removed\n");
|
||||
logmsg("language: $lang language pack removed");
|
||||
logger("language: $lang language pack removed");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
|
||||
@@ -283,7 +283,7 @@ function filter_url($url) {
|
||||
|
||||
// Deal with logging message.
|
||||
//
|
||||
function logmsg($message) {
|
||||
function logger($message) {
|
||||
shell_exec("logger $message");
|
||||
}
|
||||
|
||||
@@ -382,12 +382,12 @@ function plugin($method, $plugin_file, &$error) {
|
||||
// If file already exists, check the SHA256/MD5 (if supplied)
|
||||
if (file_exists($name)) {
|
||||
if ($file->SHA256) {
|
||||
logmsg("plugin: checking: $name - SHA256");
|
||||
logger("plugin: checking: $name - SHA256");
|
||||
if (hash_file('sha256', $name) != $file->SHA256) {
|
||||
unlink($name);
|
||||
}
|
||||
} elseif ($file->MD5) {
|
||||
logmsg("plugin: checking: $name - MD5");
|
||||
logger("plugin: checking: $name - MD5");
|
||||
if (md5_file($name) != $file->MD5) {
|
||||
unlink($name);
|
||||
}
|
||||
@@ -396,12 +396,12 @@ function plugin($method, $plugin_file, &$error) {
|
||||
// If file already exists, do not overwrite
|
||||
//
|
||||
if (file_exists($name)) {
|
||||
logmsg("plugin: skipping: $name already exists");
|
||||
logger("plugin: skipping: $name already exists");
|
||||
} elseif ($file->LOCAL) {
|
||||
// Create the file
|
||||
//
|
||||
// for local file, just copy it
|
||||
logmsg("plugin: creating: $name - copying LOCAL file $file->LOCAL");
|
||||
logger("plugin: creating: $name - copying LOCAL file $file->LOCAL");
|
||||
if (!copy($file->LOCAL, $name)) {
|
||||
$error = "unable to copy LOCAL file: $name";
|
||||
@unlink($name);
|
||||
@@ -409,10 +409,10 @@ function plugin($method, $plugin_file, &$error) {
|
||||
}
|
||||
} elseif ($file->INLINE) {
|
||||
// for inline file, create with inline contents
|
||||
logmsg("plugin: creating: $name - from INLINE content");
|
||||
logger("plugin: creating: $name - from INLINE content");
|
||||
$contents = trim($file->INLINE).PHP_EOL;
|
||||
if ($file->attributes()->Type == 'base64') {
|
||||
logmsg("plugin: decoding: $name as base64");
|
||||
logger("plugin: decoding: $name as base64");
|
||||
$contents = base64_decode($contents);
|
||||
if ($contents === false) {
|
||||
$error = "unable to decode inline base64: $name";
|
||||
@@ -426,20 +426,20 @@ function plugin($method, $plugin_file, &$error) {
|
||||
}
|
||||
} elseif ($file->URL) {
|
||||
// for download file, download and maybe verify the file MD5
|
||||
logmsg("plugin: creating: $name - downloading from URL $file->URL");
|
||||
logger("plugin: creating: $name - downloading from URL $file->URL");
|
||||
if ( (download($file->URL, $name, $error) === false) && (download(filter_url($file->URL), $name, $error) === false) ) {
|
||||
@unlink($name);
|
||||
return false;
|
||||
}
|
||||
if ($file->SHA256) {
|
||||
logmsg("plugin: checking: $name - SHA256");
|
||||
logger("plugin: checking: $name - SHA256");
|
||||
if (hash_file('sha256', $name) != $file->SHA256) {
|
||||
$error = "bad file SHA256: $name";
|
||||
unlink($name);
|
||||
return false;
|
||||
}
|
||||
} elseif ($file->MD5) {
|
||||
logmsg("plugin: checking: $name - MD5");
|
||||
logger("plugin: checking: $name - MD5");
|
||||
if (md5_file($name) != $file->MD5) {
|
||||
$error = "bad file MD5: $name";
|
||||
unlink($name);
|
||||
@@ -452,7 +452,7 @@ function plugin($method, $plugin_file, &$error) {
|
||||
if ($file->attributes()->Mode) {
|
||||
// if file has 'Mode' attribute, apply it
|
||||
$mode = $file->attributes()->Mode;
|
||||
logmsg("plugin: setting: $name - mode to $mode");
|
||||
logger("plugin: setting: $name - mode to $mode");
|
||||
if (!chmod($name, octdec($mode))) {
|
||||
$error = "chmod failure: $name";
|
||||
return false;
|
||||
@@ -464,13 +464,13 @@ function plugin($method, $plugin_file, &$error) {
|
||||
if ($file->attributes()->Run) {
|
||||
$command = $file->attributes()->Run;
|
||||
if ($name) {
|
||||
logmsg(escapeshellarg("plugin: running: $command $name"));
|
||||
logger(escapeshellarg("plugin: running: $command $name"));
|
||||
$retval = run("$command $name");
|
||||
} elseif ($file->LOCAL) {
|
||||
logmsg(escapeshellarg("plugin: running: $command $file->LOCAL"));
|
||||
logger(escapeshellarg("plugin: running: $command $file->LOCAL"));
|
||||
$retval = run("$command $file->LOCAL");
|
||||
} elseif ($file->INLINE) {
|
||||
logmsg("plugin: running: 'anonymous'");
|
||||
logger("plugin: running: 'anonymous'");
|
||||
$name = '/tmp/inline.sh';
|
||||
file_put_contents($name, $file->INLINE);
|
||||
$retval = run("$command $name");
|
||||
@@ -718,10 +718,10 @@ if ($method == 'install') {
|
||||
if ($target != $plugin_file) copy($plugin_file, $target);
|
||||
symlink($target, $symlink);
|
||||
write("plugin: $plugin installed\n");
|
||||
logmsg("plugin: $plugin installed");
|
||||
logger("plugin: $plugin installed");
|
||||
} else {
|
||||
write("script: $plugin executed\n");
|
||||
logmsg("script: $plugin executed");
|
||||
logger("script: $plugin executed");
|
||||
}
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
@@ -835,7 +835,7 @@ if ($method == 'update') {
|
||||
copy($plugin_file, $target);
|
||||
symlink($target, $symlink);
|
||||
write("plugin: $plugin updated\n");
|
||||
logmsg("plugin: $plugin updated");
|
||||
logger("plugin: $plugin updated");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
done(0);
|
||||
@@ -867,7 +867,7 @@ if ($method == 'remove') {
|
||||
// remove the plugin file
|
||||
move($installed_plugin_file, "$boot-removed");
|
||||
write("plugin: $plugin removed\n");
|
||||
logmsg("plugin: $plugin removed");
|
||||
logger("plugin: $plugin removed");
|
||||
exec("/usr/local/sbin/update_cron");
|
||||
// run hook scripts for post processing
|
||||
post_hooks();
|
||||
|
||||
Reference in New Issue
Block a user