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 [
<!ENTITY name "NerdPack">
<!ENTITY author "dmacias72">
<!ENTITY version "2015.12.13">
<!ENTITY version "2015.12.14">
<!ENTITY launch "Settings/&name;">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master">
<!ENTITY pluginURL "&gitURL;/plugins/&name;.plg">
@ -17,6 +17,8 @@
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;">
<CHANGES>
###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.
-->
<FILE Run="/bin/bash" Method="install">
<INLINE>
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.
-->
<FILE Run="/bin/bash" Method="remove">
<INLINE>
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 "-----------------------------------------------------------"

View File

@ -3,7 +3,7 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "ipmitool-plugin">
<!ENTITY author "dmacias72">
<!ENTITY version "2015.12.13a">
<!ENTITY version "2015.12.14">
<!ENTITY launch "Tools/IPMItool">
<!ENTITY gitURL "https://raw.githubusercontent.com/&author;/unRAID-plugins/master">
<!ENTITY pluginURL "&gitURL;/plugins/&name;.plg">
@ -18,7 +18,7 @@
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;">
<CHANGES>
###2015.12.13a
###2015.12.14
- make sure and remove old plugin
###2015.12.11
- change repo
@ -73,12 +73,8 @@ The 'install' script.
-->
<FILE Run="/bin/bash" Method="install">
<INLINE>
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

View File

@ -11,8 +11,10 @@ The ipmitool plugin allows you to view your system sensors and events using your
</Description>
<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>
<Date>2015-12-11</Date>
<Date>2015-12-14</Date>
<Changes>
###2015.12.14
- make sure to remove old plugin
###2015.12.11
- change repo
- change install and remove method

View File

@ -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

View File

@ -3,16 +3,17 @@ Menu="NetworkServices"
Title="Nerd Pack"
---
<?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";
$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">
<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">
<input type="hidden" name="#file" value="NerdPack/NerdPack.cfg" />
<table style="margin-top:-22px;" class="tablesorter" id="tblPackages">

View File

@ -1,5 +1,5 @@
<?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;
@ -10,15 +10,12 @@ function progressBar($download_size, $downloaded_size, $upload_size, $uploaded_s
if ( $progress > $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;
}
?>

View File

@ -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 () {
}
});
};

View File

@ -1,10 +1,10 @@
#!/usr/bin/php -q
<?php
include("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
require_once("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
function logger($message) {
echo "$message\n";
//shell_exec( "echo $message | logger -tnerdpack");
function logger($output) {
shell_exec( "echo '$output' 2>&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);
}
}