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
|
||||
|
@ -8,22 +8,22 @@ if (!is_dir($pkg_path))
|
||||
$pkg_desc = 'https://raw.githubusercontent.com/dmacias72/unRAID-plugins/master/plugins/packages-desc';
|
||||
$pkg_repo = "https://api.github.com/repos/dmacias72/unRAID-plugins/contents/packages/$os_version";
|
||||
|
||||
$desc_file = $pkg_path.'packages-desc';
|
||||
$repo_file = $pkg_path.'packages.json';
|
||||
$desc_file = $pkg_path.'packages-desc';
|
||||
$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_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 = [];
|
||||
@ -25,7 +25,7 @@ foreach ($pkgs_github_array as $pkg_github) {
|
||||
|
||||
$pkg_version = $pkg_nameArray[sizeof($pkg_nameArray) - 3]; // get package version
|
||||
|
||||
$pkg_nver = $pkg_name.'-'.str_replace('.', '_', $pkg_version); // add underscored version to package name
|
||||
$pkg_nver = $pkg_name.'-'.str_replace('.', '_', $pkg_version); // add underscored version to package name
|
||||
|
||||
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search pattern for packages
|
||||
|
||||
|
@ -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,28 +48,39 @@ $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
|
||||
$pkg_cmd = '';
|
||||
$pkg_name = str_replace('_', '.', $pkg_name); // replace "_" with "." in package names
|
||||
$pkg_name = str_replace('_', '.', $pkg_name); // replace "_" with "." in package names
|
||||
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search pattern for packages
|
||||
$pkg_install_status = preg_grep($pkg_pattern, $pkgs_installed); // check install status
|
||||
$pkg_install_status = preg_grep($pkg_pattern, $pkgs_installed); // check install status
|
||||
$pkg_download_status = preg_grep($pkg_pattern, $pkgs_downloaded); // check package download status
|
||||
$pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array);
|
||||
$pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array);
|
||||
|
||||
$pkg_matches = array_filter($pkgs_github_array, function($a) use ($pkg_pattern) {
|
||||
return preg_grep($pkg_pattern, $a);
|
||||
});
|
||||
|
||||
$pkg_gitname = array_values($pkg_matches)[0]['name'];
|
||||
$pkg_file = $pkg_path.$pkg_gitname;
|
||||
$pkg_url = array_values($pkg_matches)[0]['download_url'];
|
||||
$pkg_sha1 = array_values($pkg_matches)[0]['sha'];
|
||||
$pkg_file = $pkg_path.$pkg_gitname;
|
||||
$pkg_url = array_values($pkg_matches)[0]['download_url'];
|
||||
$pkg_sha1 = array_values($pkg_matches)[0]['sha'];
|
||||
|
||||
//check if plugin is dependent on package
|
||||
$plugins = [];
|
||||
@ -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