fix packagemanager array erros
This commit is contained in:
parent
654b561dee
commit
14bb526fb7
|
@ -3,7 +3,7 @@
|
|||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "NerdPack">
|
||||
<!ENTITY author "dmacias72">
|
||||
<!ENTITY version "2016.09.16">
|
||||
<!ENTITY version "2016.09.18">
|
||||
<!ENTITY launch "Settings/&name;">
|
||||
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master">
|
||||
<!ENTITY pluginURL "&gitURL;/plugins/&name;.plg">
|
||||
|
@ -16,6 +16,8 @@
|
|||
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;">
|
||||
|
||||
<CHANGES>
|
||||
###2016.09.18
|
||||
- fix: packagemanager array errors
|
||||
###2016.09.16
|
||||
- fix: empty package list on new install or upgrade
|
||||
- update tablesorter to 2.27.6
|
||||
|
|
|
@ -11,8 +11,10 @@ This plugin allows installation of extra packages, mostly CLI, for advanced user
|
|||
</Description>
|
||||
<Support>http://lime-technology.com/forum/index.php?topic=37541.0</Support>
|
||||
<Icon>https://raw.githubusercontent.com/dmacias72/unRAID-plugins/master/plugins/NerdPack.png</Icon>
|
||||
<Date>2016-09-16</Date>
|
||||
<Date>2016-09-18</Date>
|
||||
<Changes>
|
||||
###2016.09.18
|
||||
- fix: packagemanager array errors
|
||||
###2016.09.16
|
||||
- fix: empty package list on new install or upgrade
|
||||
- update tablesorter to 2.27.6
|
||||
|
|
|
@ -13,17 +13,17 @@ $repo_file = $pkg_path.'packages.json';
|
|||
$config_file = $plg_path.'NerdPack.cfg';
|
||||
|
||||
// get package configs
|
||||
$pkg_cfg = (is_file($config_file)) ? parse_ini_file($config_file) : [];
|
||||
$pkg_cfg = file_exists($config_file) ? parse_ini_file($config_file) : [];
|
||||
|
||||
// get array of downloaded packages
|
||||
$pkgs_downloaded = file_exists($pkg_path) ? array_diff(scandir($pkg_path, 1), ['.', '..','packages.json','packages-desc']) : [];
|
||||
$pkgs_downloaded = is_dir($pkg_path) ? array_diff(scandir($pkg_path, 1), ['.', '..','packages.json','packages-desc']) : [];
|
||||
|
||||
// get array of all installed packages
|
||||
$pkgs_installed = array_diff(scandir("/var/log/packages", 1), ['.', '..']);
|
||||
|
||||
$pkgs_desc_array = (file_exists($desc_file)) ? json_decode(file_get_contents($desc_file), true) : '[]';
|
||||
$pkgs_desc_array = file_exists($desc_file) ? json_decode(file_get_contents($desc_file), true) : [];
|
||||
|
||||
$pkgs_github_array = (file_exists($repo_file)) ? json_decode(file_get_contents($repo_file), true) : '[]';
|
||||
$pkgs_github_array = file_exists($repo_file) ? json_decode(file_get_contents($repo_file), true) : [];
|
||||
|
||||
function logger($output, $quiet = false) {
|
||||
exec('echo '.escapeshellarg($output).' 2>&1 | logger -tnerdpack');
|
||||
|
|
|
@ -6,8 +6,8 @@ require_once '/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php';
|
|||
if (!file_exists($repo_file) || !empty($_GET['force']) || (filemtime($repo_file) < (time() - 3600))) {
|
||||
get_content_from_github($pkg_repo, $repo_file);
|
||||
get_content_from_github($pkg_desc, $desc_file);
|
||||
$pkgs_desc_array = (file_exists($desc_file)) ? json_decode(file_get_contents($desc_file), true) : '[]';
|
||||
$pkgs_github_array = (file_exists($repo_file)) ? json_decode(file_get_contents($repo_file), true) : '[]';
|
||||
$pkgs_desc_array = file_exists($desc_file) ? json_decode(file_get_contents($desc_file), true) : [];
|
||||
$pkgs_github_array = file_exists($repo_file) ? json_decode(file_get_contents($repo_file), true) : [];
|
||||
}
|
||||
|
||||
$pkgs_array = [];
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
$debug = FALSE;
|
||||
$prog = pathinfo(__FILE__, PATHINFO_FILENAME);
|
||||
$usage = <<<EOF
|
||||
|
||||
Process package files in NerdPack config. Download and install,
|
||||
|
@ -14,12 +16,13 @@ Usage: packagemanager [options]
|
|||
-v, --verbose print all packages progress
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
|
||||
--debug turn on debugging
|
||||
|
||||
EOF;
|
||||
|
||||
$shortopts = "drquv";
|
||||
$longopts = [
|
||||
"debug",
|
||||
"delete",
|
||||
"download",
|
||||
"help",
|
||||
|
@ -45,10 +48,21 @@ $argq = (array_key_exists("q", $args) || array_key_exists("quiet", $args));
|
|||
$argr = (array_key_exists("r", $args) || array_key_exists("delete", $args));
|
||||
$argu = (array_key_exists("u", $args) || array_key_exists("uninstall", $args));
|
||||
$argv = (array_key_exists("v", $args) || array_key_exists("verbose", $args));
|
||||
$debug = array_key_exists("debug", $args);
|
||||
|
||||
require_once '/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php';
|
||||
require_once '/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php';
|
||||
|
||||
/* debug */
|
||||
function debug($m){
|
||||
global $prog, $debug;
|
||||
if($debug){
|
||||
$STDERR = fopen('php://stderr', 'w+');
|
||||
fwrite($STDERR, $m.PHP_EOL);
|
||||
fclose($STDERR);
|
||||
}
|
||||
}
|
||||
|
||||
logger('Processing Packages...');
|
||||
|
||||
foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each package
|
||||
|
@ -140,4 +154,16 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
|
|||
}
|
||||
|
||||
logger('All packages processed...');
|
||||
|
||||
/* print variable */
|
||||
$defined_vars = get_defined_vars();
|
||||
|
||||
//remove vars from array to save
|
||||
unset($defined_vars['pkgs_desc_array'],$defined_vars['pkgs_github_array']);
|
||||
|
||||
foreach (array("_GET","_POST","_COOKIE","_FILES","argv","argc","_SERVER") as $i)
|
||||
unset($defined_vars[$i]);
|
||||
|
||||
debug("\nDECLARED VARIABLES:\n".print_r($defined_vars, true));
|
||||
unset($defined_vars);
|
||||
?>
|
Loading…
Reference in New Issue
Block a user