update minor bugs

This commit is contained in:
Derek Macias 2015-12-14 01:28:47 -07:00
parent e33f7ce6b5
commit 5b016ac943
8 changed files with 69 additions and 112 deletions

View File

@ -3,7 +3,7 @@
<!DOCTYPE PLUGIN [ <!DOCTYPE PLUGIN [
<!ENTITY name "NerdPack"> <!ENTITY name "NerdPack">
<!ENTITY author "dmacias72"> <!ENTITY author "dmacias72">
<!ENTITY version "2015.12.13"> <!ENTITY version "2015.12.14">
<!ENTITY launch "Settings/&name;"> <!ENTITY launch "Settings/&name;">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master"> <!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master">
<!ENTITY pluginURL "&gitURL;/plugins/&name;.plg"> <!ENTITY pluginURL "&gitURL;/plugins/&name;.plg">
@ -17,6 +17,8 @@
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;"> <PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;">
<CHANGES> <CHANGES>
###2015.12.14
- fix some minor bugs
###2015.12.13 ###2015.12.13
- initial commit of wrapper plugin for packages in repo - initial commit of wrapper plugin for packages in repo
###2015.12.07 ###2015.12.07
@ -89,10 +91,6 @@ The 'install' script.
--> -->
<FILE Run="/bin/bash" Method="install"> <FILE Run="/bin/bash" Method="install">
<INLINE> <INLINE>
if [ ! -d &emhttp; ]; then
mkdir -p &emhttp;
fi
# Verify and install plugin package # Verify and install plugin package
sum1=$(/usr/bin/md5sum &plgpath;/&plgname;.txz) sum1=$(/usr/bin/md5sum &plgpath;/&plgname;.txz)
sum2=$(/usr/bin/cat &plgpath;/&plgname;.md5) sum2=$(/usr/bin/cat &plgpath;/&plgname;.md5)
@ -128,10 +126,10 @@ The 'remove' script.
--> -->
<FILE Run="/bin/bash" Method="remove"> <FILE Run="/bin/bash" Method="remove">
<INLINE> <INLINE>
removepkg &plgpath;/&plgname;.txz removepkg &plgpath;/&plgname;.txz \
rm -rf &emhttp; &plgpath;/&pkg;
rm -f &plgpath;/&plgname;.txz rm -rf &emhttp; \
rm -f &plgpath;/&plgname;.md5 -rf &plgpath;
echo "" echo ""
echo "-----------------------------------------------------------" echo "-----------------------------------------------------------"

View File

@ -3,7 +3,7 @@
<!DOCTYPE PLUGIN [ <!DOCTYPE PLUGIN [
<!ENTITY name "ipmitool-plugin"> <!ENTITY name "ipmitool-plugin">
<!ENTITY author "dmacias72"> <!ENTITY author "dmacias72">
<!ENTITY version "2015.12.13a"> <!ENTITY version "2015.12.14">
<!ENTITY launch "Tools/IPMItool"> <!ENTITY launch "Tools/IPMItool">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master"> <!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master">
<!ENTITY pluginURL "&gitURL;/plugins/&name;.plg"> <!ENTITY pluginURL "&gitURL;/plugins/&name;.plg">
@ -18,7 +18,7 @@
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;"> <PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;">
<CHANGES> <CHANGES>
###2015.12.13a ###2015.12.14
- make sure and remove old plugin - make sure and remove old plugin
###2015.12.11 ###2015.12.11
- change repo - change repo
@ -73,12 +73,8 @@ The 'install' script.
--> -->
<FILE Run="/bin/bash" Method="install"> <FILE Run="/bin/bash" Method="install">
<INLINE> <INLINE>
if [ ! -d &emhttp; ]; then
mkdir -p &emhttp;
fi
if [ ! -d /usr/local/emhttp/plugins/ipmitool ]; then if [ ! -d /usr/local/emhttp/plugins/ipmitool ]; then
mkdir -p /usr/local/emhttp/plugins/ipmitool rm -rf /usr/local/emhttp/plugins/ipmitool
fi fi
# Verify and install plugin package # Verify and install plugin package

View File

@ -11,8 +11,10 @@ The ipmitool plugin allows you to view your system sensors and events using your
</Description> </Description>
<Support>http://lime-technology.com/forum/index.php?topic=39787.0</Support> <Support>http://lime-technology.com/forum/index.php?topic=39787.0</Support>
<Icon>https://raw.githubusercontent.com/dmacias72/dmacias-plugin-repository/master/ipmitool-plugin.png</Icon> <Icon>https://raw.githubusercontent.com/dmacias72/dmacias-plugin-repository/master/ipmitool-plugin.png</Icon>
<Date>2015-12-11</Date> <Date>2015-12-14</Date>
<Changes> <Changes>
###2015.12.14
- make sure to remove old plugin
###2015.12.11 ###2015.12.11
- change repo - change repo
- change install and remove method - change install and remove method

View File

@ -6,14 +6,14 @@
# customary to leave one space after the ':' except on otherwise blank lines. # customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------| |-----handy-ruler------------------------------------------------------|
nerdapck: Nerd Tools unRAID Plugin NerdPack: Nerd Tools unRAID Plugin
nerdpack: NerdPack:
nerdpack: unRAID plugin wrapper for extra packages, mostly CLI, for advanced NerdPack: unRAID plugin wrapper for extra packages, mostly CLI, for advanced
nerdpack: users. Use at your own risk. Not officially supported by LimeTech. NerdPack: users. Use at your own risk. Not officially supported by LimeTech.
nerdpack: NerdPack:
nerdpack: Supports: apr, apt-util, bwm-ng, cpio, git, iftop, inotify, iotop, NerdPack: Supports: apr, apt-util, bwm-ng, cpio, git, iftop, inotify, iotop,
nerdpack: iperf, kbd, lftp, lshw, neon, p7zip, perl, python, readline, screen, NerdPack: iperf, kbd, lftp, lshw, neon, p7zip, perl, python, readline, screen,
nerdpack: sshfs-fuse, strace, subversion, unrar, utempter, vim NerdPack: sshfs-fuse, strace, subversion, unrar, utempter, vim
nerdpack: NerdPack:
nerdpack: plugin: https://github.com/dmacias72/unRAID-plugins NerdPack: plugin: https://github.com/dmacias72/unRAID-plugins
nerdpack: packages: https://github.com/eschultz/unraid6-nerdpack NerdPack: packages: https://github.com/eschultz/unraid6-nerdpack

View File

@ -3,16 +3,17 @@ Menu="NetworkServices"
Title="Nerd Pack" Title="Nerd Pack"
--- ---
<?php <?php
include("/urs/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php"); include("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
$pkg_repo = "https://api.github.com/repos/eschultz/unraid6-nerdpack/contents/packages"; $pkg_repo = "https://api.github.com/repos/eschultz/unraid6-nerdpack/contents/packages";
$repo_file= "/boot/config/plugins/NerdPack/packages.json"; $repo_file= "/boot/config/plugins/NerdPack/packages.json";
get_content_from_github($pkg_repo, $repo_file){ get_content_from_github($pkg_repo, $repo_file);
?> ?>
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css"> <link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css">
<div id="iframe-popup" style="display:none;-webkit-overflow-scrolling:touch;"></div>
<form markdown="1" id="package_form" name="package_settings" method="POST" action="/update.php" target="progressFrame"> <form markdown="1" id="package_form" name="package_settings" method="POST" action="/update.php" target="progressFrame">
<input type="hidden" name="#file" value="NerdPack/NerdPack.cfg" /> <input type="hidden" name="#file" value="NerdPack/NerdPack.cfg" />
<table style="margin-top:-22px;" class="tablesorter" id="tblPackages"> <table style="margin-top:-22px;" class="tablesorter" id="tblPackages">

View File

@ -1,5 +1,5 @@
<?php <?php
function progressBar($download_size, $downloaded_size, $upload_size, $uploaded_size) function progress_bar($download_size, $downloaded_size, $upload_size = null, $uploaded_size = null)
{ {
static $previousProgress = 0; static $previousProgress = 0;
@ -10,15 +10,12 @@ function progressBar($download_size, $downloaded_size, $upload_size, $uploaded_s
if ( $progress > $previousProgress){ if ( $progress > $previousProgress){
$previousProgress = $progress; $previousProgress = $progress;
$pct=(double)($progress/100); $pct=(double)($progress/100);
$bar=round($pct * 30); $bar=round($pct * 30);
$pct_disp=number_format($pct * 100, 0); $pct_disp=number_format($pct * 100, 0);
$status_bar="\r["; $status_bar="\r[";
$status_bar.=str_repeat("|", $bar); $status_bar.=str_repeat("|", $bar);
if($bar < 30){ if($bar < 30){
$status_bar.=">"; $status_bar.=">";
$status_bar.=str_repeat("-", 30 - $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%"; $status_bar.="] $pct_disp%";
echo $status_bar; echo $status_bar;
ob_flush();
flush(); flush();
if($progress == 100) { if($progress == 100) {
echo "\n"; echo "\n";
} }
} }
flush();
} }
function get_file_from_url($file, $url) { function get_file_from_url($file, $url) {
flush();
$chfile = fopen($file, 'w'); $chfile = fopen($file, 'w');
$ch = curl_init(); $ch = curl_init();
$ch_vers = curl_version(); $ch_vers = curl_version();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600); //curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
curl_setopt($ch, CURLOPT_NOPROGRESS, false ); curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'curl/' . $ch_vers['version'] ); 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_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $chfile ); curl_setopt($ch, CURLOPT_FILE, $chfile );
curl_exec($ch); curl_exec($ch);
curl_close($ch); curl_close($ch);
fclose($chfile); fclose($chfile);
flush();
} }
function get_content_from_github($repo, $file){ function get_content_from_github($repo, $file){
flush();
$ch = curl_init(); $ch = curl_init();
$ch_vers = curl_version(); $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_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, 'curl/' . $ch_vers['version'] ); curl_setopt($ch, CURLOPT_USERAGENT, 'curl/' . $ch_vers['version'] );
@ -71,6 +64,16 @@ function get_content_from_github($repo, $file){
curl_close($ch); curl_close($ch);
if (!empty($content)) if (!empty($content))
file_put_contents($file, $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;
} }
?> ?>

View File

@ -1,4 +1,5 @@
$(function(){ $(function(){
//Shadowbox.init({onClose:packageQuery});
//tablesorter options //tablesorter options
$('#tblPackages').tablesorter({headers:{5:{sorter:false}}}); $('#tblPackages').tablesorter({headers:{5:{sorter:false}}});
@ -54,14 +55,15 @@ function packageManager() {
type : "POST", type : "POST",
url : "/update.php", url : "/update.php",
data : $('#package_form').serializeArray(), data : $('#package_form').serializeArray(),
success: function() { complete: function() {
openBox('/plugins/NerdPack/scripts/packagemanager&arg1=webgui&arg2='+$.cookie('nerdpack_packages'),'Install Packages',490,430,true); openBox('/plugins/NerdPack/scripts/packagemanager&arg1=webgui&arg2='+$.cookie('nerdpack_packages'),'Manage Packages',600,900,true);
} }
}); });
}; };
//list all available packages in a table //list all available packages in a table
function packageQuery() { function packageQuery() {
$("#tblPackages tbody").empty();
$.ajax({ $.ajax({
type: "GET", type: "GET",
dataType: "json", dataType: "json",
@ -198,18 +200,3 @@ function checkDepends() {
$('#python','.pkgvalue').val('yes'); $('#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 () {
}
});
};

View File

@ -1,10 +1,10 @@
#!/usr/bin/php -q #!/usr/bin/php -q
<?php <?php
include("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php"); require_once("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
function logger($message) { function logger($output) {
echo "$message\n"; shell_exec( "echo '$output' 2>&1 | logger -tnerdpack");
//shell_exec( "echo $message | logger -tnerdpack"); echo "\n".$output."\n";
} }
$config_file = "/boot/config/plugins/NerdPack/NerdPack.cfg"; $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 foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
$pkg_cmd = ''; $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 patter for packages $pkg_pattern = "/^".$pkg_name.".*/"; // search patter 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
if($pkg_pref == "yes" && !$pkg_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 executing from the wegui check status and download if necessary
if ($argv[1] == "webgui"){ 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); $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_gitname = array_values($pkg_matches)[0]["name"];
$pkg_file = $pkg_path.$pkg_gitname; $pkg_file = $pkg_path.$pkg_gitname;
$pkg_url = array_values($pkg_matches)[0]["download_url"];
$pkg_url = array_values($pkg_matches)[0]["download_url"]; $pkg_sha = array_values($pkg_matches)[0]["sha"];
$pkg_sha = array_values($pkg_matches)[0]["sha"];
$pkg_size = array_values($pkg_matches)[0]["size"];
logger("Downloading $pkg_gitname package..."); logger("Downloading $pkg_gitname package...");
get_file_from_url($pkg_file, $pkg_url); get_file_from_url($pkg_file, $pkg_url);
/*$pkg_msg = "$pkg_name package download failed."; if(file_check_sha($pkg_file, $pkg_sha))
if (file_put_contents($pkg_new, fopen($pkg_git.$pkg_name, 'r')));{ logger("$pkg_gitname package downloaded sucessfully!");
$pkg_size = filesize($pkg_new); else
$pkg_handle = fopen($pkg_new, "rb"); logger("$pkg_gitname package download failed!");
$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);
*/
} }
} }
@ -96,14 +70,10 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
} }
if(!empty($pkg_cmd)){ if(!empty($pkg_cmd)){
logger("$pkg_msg $pkg_name package..."); echo "$pkg_msg $pkg_name package...\n";
$pkg_cmd = $pkg_cmd.$pkg_path.$pkg_name."*"; $pkg_cmd = $pkg_cmd.$pkg_path.$pkg_name."* 2>&1";
$output = shell_exec($pkg_cmd);
exec($pkg_cmd, $output, $return_var); logger($output);
for ($i = 0; $i < sizeof($output); $i++) {
logger($output[$i]);
}
} }
} }