- remove curl progress bar

- separate plugin depends by comma
- only show update status of selected packages when processing
This commit is contained in:
dmacias72 2016-02-17 02:56:06 -07:00
parent af987cd06f
commit c3692381a9
4 changed files with 11 additions and 48 deletions

View File

@ -1,2 +0,0 @@
#!/bin/bash
/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager --quiet

View File

@ -1,42 +1,4 @@
<?php
// Progress bar for curl download
function progress_bar($download_size, $downloaded_size, $upload_size = null, $uploaded_size = null) {
ob_start();
static $previousProgress = 0;
if ($download_size == 0)
$progress = 0;
else
$progress = round($downloaded_size * 100 / $download_size);
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);
} else {
$status_bar .= "|";
}
$status_bar .= "] $pct_disp%";
echo $status_bar;
ob_flush();
if ($progress == 100) {
echo "\n";
}
}
ob_end_flush();
}
// Download a file from given url
function get_file_from_url($file, $url) {
$chfile = fopen($file, 'w');
@ -44,10 +6,10 @@ function get_file_from_url($file, $url) {
$ch_vers = curl_version();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_NOPROGRESS, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'curl/'.$ch_vers['version']);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress_bar');
//curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress_bar');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $chfile);
curl_exec($ch);

View File

@ -29,11 +29,12 @@ foreach ($pkgs_github_array as $pkg_github) {
$plugins = [];
exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_github['name']}' -sl",$plugins);
$pkg_plgs = "";
$pkg_plgs = '--';
if ($plugins){
foreach ($plugins as $plugin){
$pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME)." ";
$pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME).', ';
}
$pkg_plgs = substr($pkg_plgs, 2, -2);
}
$pkg = [

View File

@ -64,9 +64,9 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
if ($plugins){
$plg_msg = "$pkg_name used by plugin: ";
foreach ($plugins as $plugin){
$plg_msg .= pathinfo($plugin, PATHINFO_FILENAME)." ";
$plg_msg .= pathinfo($plugin, PATHINFO_FILENAME).", ";
}
logger($plg_msg);
logger(substr($plg_msg, 0, -2));
}
if ($pkg_pref == 'yes') {
@ -116,8 +116,10 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
shell_exec($pkg_cmd);
//$output = shell_exec($pkg_cmd);
//logger($output);
} else
} else {
if ($pkg_pref == 'yes')
logger("$pkg_name package up to date", $argq);
}
}
logger('All packages processed...');