From 5b016ac9434dbe79bb73fcd25699c4a50fe5924b Mon Sep 17 00:00:00 2001 From: Derek Macias Date: Mon, 14 Dec 2015 01:28:47 -0700 Subject: [PATCH] update minor bugs --- plugins/NerdPack.plg | 16 ++--- plugins/ipmitool-plugin.plg | 10 +-- plugins/ipmitool-plugin.xml | 4 +- source/NerdPack/install/slack-desc | 22 +++---- .../emhttp/plugins/NerdPack/NerdPack.page | 5 +- .../NerdPack/include/DownloadHelpers.php | 37 ++++++----- .../NerdPack/javascript/jquery.NerdPack.js | 23 ++----- .../plugins/NerdPack/scripts/packagemanager | 64 +++++-------------- 8 files changed, 69 insertions(+), 112 deletions(-) diff --git a/plugins/NerdPack.plg b/plugins/NerdPack.plg index 64af10fd..98e19b20 100644 --- a/plugins/NerdPack.plg +++ b/plugins/NerdPack.plg @@ -3,7 +3,7 @@ - + @@ -17,6 +17,8 @@ +###2015.12.14 +- fix some minor bugs ###2015.12.13 - initial commit of wrapper plugin for packages in repo ###2015.12.07 @@ -89,10 +91,6 @@ The 'install' script. --> -if [ ! -d &emhttp; ]; then - mkdir -p &emhttp; -fi - # Verify and install plugin package sum1=$(/usr/bin/md5sum &plgpath;/&plgname;.txz) sum2=$(/usr/bin/cat &plgpath;/&plgname;.md5) @@ -128,10 +126,10 @@ The 'remove' script. --> -removepkg &plgpath;/&plgname;.txz -rm -rf &emhttp; -rm -f &plgpath;/&plgname;.txz -rm -f &plgpath;/&plgname;.md5 +removepkg &plgpath;/&plgname;.txz \ + &plgpath;/&pkg; +rm -rf &emhttp; \ + -rf &plgpath; echo "" echo "-----------------------------------------------------------" diff --git a/plugins/ipmitool-plugin.plg b/plugins/ipmitool-plugin.plg index d049201e..3a7d743c 100755 --- a/plugins/ipmitool-plugin.plg +++ b/plugins/ipmitool-plugin.plg @@ -3,7 +3,7 @@ - + @@ -18,7 +18,7 @@ -###2015.12.13a +###2015.12.14 - make sure and remove old plugin ###2015.12.11 - change repo @@ -73,12 +73,8 @@ The 'install' script. --> -if [ ! -d &emhttp; ]; then - mkdir -p &emhttp; -fi - if [ ! -d /usr/local/emhttp/plugins/ipmitool ]; then - mkdir -p /usr/local/emhttp/plugins/ipmitool + rm -rf /usr/local/emhttp/plugins/ipmitool fi # Verify and install plugin package diff --git a/plugins/ipmitool-plugin.xml b/plugins/ipmitool-plugin.xml index fecaa876..2061ead3 100644 --- a/plugins/ipmitool-plugin.xml +++ b/plugins/ipmitool-plugin.xml @@ -11,8 +11,10 @@ The ipmitool plugin allows you to view your system sensors and events using your http://lime-technology.com/forum/index.php?topic=39787.0 https://raw.githubusercontent.com/dmacias72/dmacias-plugin-repository/master/ipmitool-plugin.png -2015-12-11 +2015-12-14 +###2015.12.14 +- make sure to remove old plugin ###2015.12.11 - change repo - change install and remove method diff --git a/source/NerdPack/install/slack-desc b/source/NerdPack/install/slack-desc index 53dca856..ec323c11 100644 --- a/source/NerdPack/install/slack-desc +++ b/source/NerdPack/install/slack-desc @@ -6,14 +6,14 @@ # customary to leave one space after the ':' except on otherwise blank lines. |-----handy-ruler------------------------------------------------------| -nerdapck: Nerd Tools unRAID Plugin -nerdpack: -nerdpack: unRAID plugin wrapper for extra packages, mostly CLI, for advanced -nerdpack: users. Use at your own risk. Not officially supported by LimeTech. -nerdpack: -nerdpack: Supports: apr, apt-util, bwm-ng, cpio, git, iftop, inotify, iotop, -nerdpack: iperf, kbd, lftp, lshw, neon, p7zip, perl, python, readline, screen, -nerdpack: sshfs-fuse, strace, subversion, unrar, utempter, vim -nerdpack: -nerdpack: plugin: https://github.com/dmacias72/unRAID-plugins -nerdpack: packages: https://github.com/eschultz/unraid6-nerdpack +NerdPack: Nerd Tools unRAID Plugin +NerdPack: +NerdPack: unRAID plugin wrapper for extra packages, mostly CLI, for advanced +NerdPack: users. Use at your own risk. Not officially supported by LimeTech. +NerdPack: +NerdPack: Supports: apr, apt-util, bwm-ng, cpio, git, iftop, inotify, iotop, +NerdPack: iperf, kbd, lftp, lshw, neon, p7zip, perl, python, readline, screen, +NerdPack: sshfs-fuse, strace, subversion, unrar, utempter, vim +NerdPack: +NerdPack: plugin: https://github.com/dmacias72/unRAID-plugins +NerdPack: packages: https://github.com/eschultz/unraid6-nerdpack diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page index f4ff52a3..2785a0b4 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page @@ -3,16 +3,17 @@ Menu="NetworkServices" Title="Nerd Pack" --- +
diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php index 4b4fd248..5c0d9375 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php @@ -1,5 +1,5 @@ $previousProgress){ $previousProgress = $progress; - $pct=(double)($progress/100); - $bar=round($pct * 30); - $pct_disp=number_format($pct * 100, 0); - $status_bar="\r["; $status_bar.=str_repeat("|", $bar); + if($bar < 30){ $status_bar.=">"; $status_bar.=str_repeat("-", 30 - $bar); @@ -29,40 +26,36 @@ function progressBar($download_size, $downloaded_size, $upload_size, $uploaded_s $status_bar.="] $pct_disp%"; echo $status_bar; - + ob_flush(); flush(); if($progress == 100) { echo "\n"; } } - flush(); } function get_file_from_url($file, $url) { - flush(); $chfile = fopen($file, 'w'); $ch = curl_init(); $ch_vers = curl_version(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_TIMEOUT, 3600); - curl_setopt($ch, CURLOPT_NOPROGRESS, false ); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + //curl_setopt($ch, CURLOPT_TIMEOUT, 3600); + curl_setopt($ch, CURLOPT_NOPROGRESS, false); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'curl/' . $ch_vers['version'] ); - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progressBar' ); + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress_bar' ); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FILE, $chfile ); curl_exec($ch); curl_close($ch); fclose($chfile); - flush(); } function get_content_from_github($repo, $file){ - flush(); $ch = curl_init(); $ch_vers = curl_version(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); curl_setopt($ch, CURLOPT_USERAGENT, 'curl/' . $ch_vers['version'] ); @@ -71,6 +64,16 @@ function get_content_from_github($repo, $file){ curl_close($ch); if (!empty($content)) file_put_contents($file, $content); - flush(); } -?> + +function file_check_sha($file, $sha){ + $size = filesize($file); + $handle = fopen($file, "rb"); + $contents = fread($handle, $size); + fclose($handle); + $str = "blob ".$size."\0".$contents; + $sha_file = sha1($str); + $return = ($sha_file == $sha) ? true : false; + return $return; +} +?> \ No newline at end of file diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/javascript/jquery.NerdPack.js b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/javascript/jquery.NerdPack.js index 1dbff1b5..dec92e5f 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/javascript/jquery.NerdPack.js +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/javascript/jquery.NerdPack.js @@ -1,4 +1,5 @@ $(function(){ + //Shadowbox.init({onClose:packageQuery}); //tablesorter options $('#tblPackages').tablesorter({headers:{5:{sorter:false}}}); @@ -54,14 +55,15 @@ function packageManager() { type : "POST", url : "/update.php", data : $('#package_form').serializeArray(), - success: function() { - openBox('/plugins/NerdPack/scripts/packagemanager&arg1=webgui&arg2='+$.cookie('nerdpack_packages'),'Install Packages',490,430,true); - } + complete: function() { + openBox('/plugins/NerdPack/scripts/packagemanager&arg1=webgui&arg2='+$.cookie('nerdpack_packages'),'Manage Packages',600,900,true); + } }); }; //list all available packages in a table function packageQuery() { + $("#tblPackages tbody").empty(); $.ajax({ type: "GET", dataType: "json", @@ -198,18 +200,3 @@ function checkDepends() { $('#python','.pkgvalue').val('yes'); } }; - -// check github for newer package and report status -function getPackages() { - $.ajax({ - type: "GET", - url: "https://api.github.com/repos/eschultz/unraid6-nerdpack/contents/packages", - dataType: "json", - success: function(data) { - }, - complete : function () { - }, - error: function () { - } - }); -}; \ No newline at end of file diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager index 46c00cfa..0cf88e04 100755 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager @@ -1,10 +1,10 @@ #!/usr/bin/php -q &1 | logger -tnerdpack"); + echo "\n".$output."\n"; } $config_file = "/boot/config/plugins/NerdPack/NerdPack.cfg"; @@ -27,11 +27,8 @@ 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_pattern = "/^".$pkg_name.".*/"; // search patter for packages - $pkg_install_status = preg_grep($pkg_pattern, $pkgs_installed); // check install status if($pkg_pref == "yes" && !$pkg_install_status){ @@ -39,7 +36,7 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package //if executing from the wegui check status and download if necessary if ($argv[1] == "webgui"){ - if(!preg_grep($pkg_pattern , $pkgs_downloaded)) { + if(!preg_grep($pkg_pattern, $pkgs_downloaded)) { $pkg_online_status = preg_grep($pkg_pattern , $pkgs_github); @@ -48,41 +45,18 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package }); $pkg_gitname = array_values($pkg_matches)[0]["name"]; - $pkg_file = $pkg_path.$pkg_gitname; - - $pkg_url = array_values($pkg_matches)[0]["download_url"]; - - $pkg_sha = array_values($pkg_matches)[0]["sha"]; - - $pkg_size = array_values($pkg_matches)[0]["size"]; + $pkg_url = array_values($pkg_matches)[0]["download_url"]; + $pkg_sha = array_values($pkg_matches)[0]["sha"]; logger("Downloading $pkg_gitname package..."); - get_file_from_url($pkg_file, $pkg_url); - - /*$pkg_msg = "$pkg_name package download failed."; - if (file_put_contents($pkg_new, fopen($pkg_git.$pkg_name, 'r')));{ - $pkg_size = filesize($pkg_new); - $pkg_handle = fopen($pkg_new, "rb"); - $pkg_contents = fread($pkg_handle, $pkg_size); - fclose($pkg_handle); - $pkg_str = "blob ".$pkg_size."\0".$pkg_contents; - $pkg_sha = sha1($pkg_str); - if($pkg_sha == $_POST["pkgsha"]) { - $pkg_msg = "$pkg_name package downloaded."; - if (is_file($pkg_old)) - unlink($pkg_old); - if($pkg_pref == "yes") { - $pkg_msg = "$pkg_name package updated."; - } - }else { - if (is_file($pkg_new)) - unlink($pkg_new); - } - } - echo json_encode($pkg_msg); - */ + get_file_from_url($pkg_file, $pkg_url); + + if(file_check_sha($pkg_file, $pkg_sha)) + logger("$pkg_gitname package downloaded sucessfully!"); + else + logger("$pkg_gitname package download failed!"); } } @@ -96,14 +70,10 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package } if(!empty($pkg_cmd)){ - logger("$pkg_msg $pkg_name package..."); - $pkg_cmd = $pkg_cmd.$pkg_path.$pkg_name."*"; - - exec($pkg_cmd, $output, $return_var); - - for ($i = 0; $i < sizeof($output); $i++) { - logger($output[$i]); - } + echo "$pkg_msg $pkg_name package...\n"; + $pkg_cmd = $pkg_cmd.$pkg_path.$pkg_name."* 2>&1"; + $output = shell_exec($pkg_cmd); + logger($output); } }