diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page index d92a34b0..326c85a6 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/NerdPack.page @@ -2,55 +2,37 @@ Icon="NerdPack.png" Menu="NetworkServices" Title="Nerd Pack" --- - - - - +.css"> + - +
- - + - +
Name Version Size Size Downloaded Installed
- + : +
- + \ No newline at end of file diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/css/NerdPack.css b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/css/NerdPack.css index b93c53bc..13de74fa 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/css/NerdPack.css +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/css/NerdPack.css @@ -1,3 +1,9 @@ .package { - cursor: pointer; + cursor: pointer; } +#package_form { + margin-top: -22px; +} +.switch-button-label.off { + color: inherit; +} \ No newline at end of file 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 adf1983e..bd3e70e9 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php @@ -1,38 +1,36 @@ $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); + 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 .= "|"; } - $status_bar.="] $pct_disp%"; + $status_bar .= "] $pct_disp%"; echo $status_bar; ob_flush(); - - if($progress == 100) { + if ($progress == 100) { echo "\n"; } } @@ -48,42 +46,39 @@ function get_file_from_url($file, $url) { //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, 'progress_bar' ); + curl_setopt($ch, CURLOPT_USERAGENT, 'curl/'.$ch_vers['version']); + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress_bar'); curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_FILE, $chfile ); + curl_setopt($ch, CURLOPT_FILE, $chfile); curl_exec($ch); curl_close($ch); fclose($chfile); } // get a json array of the contents of gihub repo -function get_content_from_github($repo, $file){ +function get_content_from_github($repo, $file) { $ch = curl_init(); $ch_vers = curl_version(); - 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'] ); - curl_setopt($ch, CURLOPT_URL, $repo); - $content = curl_exec($ch); - curl_close($ch); - if ((!empty($content)) && ($content != file_get_contents($file))) - file_put_contents($file, $content); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: application/json', 'Content-Type: application/json']); + curl_setopt($ch, CURLOPT_USERAGENT, 'curl/'.$ch_vers['version']); + curl_setopt($ch, CURLOPT_URL, $repo); + $content = curl_exec($ch); + curl_close($ch); + if (!empty($content) && (!is_file($file) || $content != file_get_contents($file))) + file_put_contents($file, $content); } // Compare the github sha1 value of a file -function file_check_sha1($file, $sha1){ +function file_check_sha1($file, $sha1) { $size = filesize($file); - $handle = fopen($file, "rb"); - $contents = fread($handle, $size); - fclose($handle); - + $contents = file_get_contents($file); + // create a sha1 like github does $str = "blob ".$size."\0".$contents; $sha1_file = sha1($str); - - $return = ($sha1_file == $sha1) ? true : false; - return $return; + + return ($sha1_file == $sha1); } ?> \ No newline at end of file diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php index 6266ef48..3190e142 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php @@ -1,5 +1,39 @@ &1 | logger -tnerdpack'); + if (!$quiet) { + echo "\n".$output." \n"; + usleep(100000); + } +} + +function format_size($value, $decimals, $unit = '?') { if ($value == '') return 'unknown'; @@ -26,7 +60,7 @@ function format_size($value, $decimals, $unit='?') { case 'T': return number_format($value / (float)1099511627776, $decimals).' TB'; case 'G': return number_format($value / (float)(1 << 30), $decimals).' GB'; case 'M': return number_format($value / (float)(1 << 20), $decimals).' MB'; - case 'K': return number_format($value / (float)(1 << 10), $decimals).' kB'; + case 'K': return number_format($value / (float)(1 << 10), $decimals).' KB'; case 'B': return $value.' B'; } diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php index f5b0655c..743c3e9b 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php @@ -1,71 +1,47 @@ 4){ //if package name has a subset get it + if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) { - $pkg_name = $pkg_name."-".$pkg_nameArray[$ii]; - } + $pkg_name .= '-'.$pkg_nameArray[$ii]; + } } - $pkg_version = $pkg_nameArray[sizeof($pkg_nameArray)-3]; // get package version + $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_pattern = "/^".$pkg_name.".*/"; // search patter for packages + $pkg_nver = $pkg_name.'-'.str_replace('.', '_', $pkg_version); // add underscored version to package name - $pkg = array(); + $pkg_pattern = '/^'.$pkg_name.'.*/'; // search patter for packages - $pkg["name"] = $pkgs_github_array[$i]["name"]; // add full package name - - $pkg["pkgname"] = $pkg_name; // add package name only - - $pkg["pkgnver"] = $pkg_nver; // add package name with underscored version - - $pkg["pkgversion"] = $pkg_version; // add package name with underscored version - - $pkg["size"] = format_size($pkgs_github_array[$i]["size"], 1, '?'); // add package size - - // checks if package name is installed - $pkg["installed"] = preg_grep($pkg_pattern , $pkgs_installed) ? "yes" : "no"; - - // checks if package is installed equals github exactly - $pkg["installeq"] = in_array( pathinfo($pkgs_github_array[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no"; - - // checks if package name is downloaded - $pkg["downloaded"] = preg_grep($pkg_pattern , $pkgs_downloaded) ? "yes" : "no"; - - // checks if package is downloaded equals github exactly - $pkg["downloadeq"] = in_array( $pkgs_github_array[$i]["name"], $pkgs_downloaded ) ? "yes" : "no"; - - $pkg["config"] = isset($pkg_cfg["$pkg_nver"]) ? $pkg_cfg["$pkg_nver"] : "no"; // checks config for install preference - - $pkg["desc"] = $pkgs_desc_array["$pkg_name"]; + $pkg = [ + 'name' => $pkg_github['name'], // add full package name + 'pkgname' => $pkg_name, // add package name only + 'pkgnver' => $pkg_nver, // add package name with underscored version + 'pkgversion' => $pkg_version, // add package name with raw version + 'size' => format_size($pkg_github['size'], 1, '?'), // add package size + 'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed + 'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package is installed equals github exactly + 'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded + 'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package is downloaded equals github exactly + 'config' => isset($pkg_cfg[$pkg_nver]) ? $pkg_cfg[$pkg_nver] : 'no', // checks config for install preference + 'desc' => $pkgs_desc_array[$pkg_name] + ]; $pkgs_array[] = $pkg; } echo json_encode($pkgs_array); -?> +?> \ No newline at end of file diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js index 41baf482..d5d2db25 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/js/jquery.NerdPack.js @@ -1,153 +1,141 @@ $(function(){ - // "uninstall package" switch and cookie - $('#uninstallpkg') - .switchButton({ - labels_placement: "left", - on_label: 'unInstall On', - off_label: 'unInstall Off', - checked: $.cookie('nerdpack_packages_uninstall') == '--uninstall' - }) - .change(function () { - $.cookie('nerdpack_packages_uninstall', $('#uninstallpkg').prop('checked') ? '--uninstall' : '', { expires: 3650 }); + // tablesorter options + $("#tblPackages").tablesorter({ + sortList: [[0,1]], + widgets: ["saveSort", "filter", "stickyHeaders"], + widgetOptions: { + stickyHeaders_filteredToTop: true, + filter_hideEmpty: true, + filter_liveSearch: true, + filter_saveFilters: true, + filter_reset: "button.reset", + filter_functions: { + ".filter-version": true, + ".filter-downloaded": true, + ".filter-installed": true + } + } }); + // "uninstall package" switch and cookie + $("#uninstallpkg") + .switchButton({ + labels_placement: "left", + on_label: "unInstall On", + off_label: "unInstall Off", + checked: $.cookie("nerdpack_packages_uninstall") == "--uninstall" + }) + .change(function () { + $.cookie("nerdpack_packages_uninstall", $(this).prop("checked") ? "--uninstall" : "", { expires: 3650 }); + }); + // "delete package" switch and cookie - $('#deletepkg') - .switchButton({ - labels_placement: "left", - on_label: 'delete On', - off_label: 'delete Off', - checked: $.cookie('nerdpack_packages_delete') == '--delete' - }) - .change(function () { - $.cookie('nerdpack_packages_delete', $('#deletepkg').prop('checked') ? '--delete' : '', { expires: 3650 }); - }); + $("#deletepkg") + .switchButton({ + labels_placement: "left", + on_label: "delete On", + off_label: "delete Off", + checked: $.cookie("nerdpack_packages_delete") == "--delete" + }) + .change(function () { + $.cookie("nerdpack_packages_delete", $(this).prop("checked") ? "--delete" : "", { expires: 3650 }); + }); // select all packages switch - $('#checkall') + $("#checkall") .switchButton({ labels_placement: "right", - on_label: 'Select All', - off_label: 'Select All', - checked: $.cookie('nerdpack_checkall') == 'yes' + on_label: "Select All", + off_label: "Select All", + checked: $.cookie("nerdpack_checkall") == "yes" }) - .change(function() { //on change - if(this.checked) { // check select status - $('.pkgcheckbox').each(function() { //loop through each checkbox - $(this).switchButton({checked: true}); - }); - $('.pkgvalue').each(function() { //loop through each value - $(this).val('yes'); - }); - }else{ - $('.pkgcheckbox').each(function() { //loop through each checkbox - $(this).switchButton({checked: false}); - }); - $('.pkgvalue').each(function() { //loop through each value - $(this).val('no'); - }); - } - }); + .change(function () { + var myval = $(this).prop("checked"); + $.cookie("nerdpack_checkall", myval ? "yes" : "no", { expires: 3650 }); + $(".pkgcheckbox").each(function() { // loop through each checkbox + $(this).switchButton({checked: myval}); + }); + $(".pkgvalue").each(function() { // loop through each value + $(this).val(myval ? "yes": "no"); + }); + }); - // set cookie on apply button press - $('#btnApply').click(function(event) { - $.cookie('nerdpack_checkall', $('#checkall').prop('checked') ? 'yes' : 'no', { expires: 3650 }); - packageManager(); + // set cookie on apply button press + $("#btnApply").click(function() { + checkDepends(); + + $.ajax({ + type: "POST", + url: "/update.php", + data: $("#package_form").serializeArray(), + success: function() { + openBox("/plugins/NerdPack/scripts/packagemanager&arg1=--download"+ + "&arg2="+$.cookie("nerdpack_packages_uninstall")+ + "&arg3="+$.cookie("nerdpack_packages_delete"), + "Package Manager", 600, 900, true); + } + }); }); packageQuery(); }); -function packageManager() { - $.ajax({ - type : "POST", - url : "/update.php", - data : $('#package_form').serializeArray(), - success: function() { - openBox('/plugins/NerdPack/scripts/packagemanager&arg1=--download'+ - '&arg2='+$.cookie('nerdpack_packages_uninstall')+ - '&arg3='+$.cookie('nerdpack_packages_delete'), - 'Package Manager',600,900,true); - } - }); -}; - //list all available packages in a table -function packageQuery() { - $("#tblPackages tbody").empty(); - $.ajax({ - type: "GET", - dataType: "json", - url: "/plugins/NerdPack/include/PackageQuery.php", - success: function(data) { - for( i in data ) { - var Update; - if (data[i].downloadeq == data[i].downloaded && data[i].installeq == data[i].installed ) - Update = " up-to-date"; - else - Update = " update ready"; +function packageQuery(force) { + $("#tblPackages tbody").html("
Please wait, retrieving plugin information ..."); + $.getJSON("/plugins/NerdPack/include/PackageQuery.php", {force: force}, function(data) { + $("#tblPackages tbody").empty(); + for (var i in data) { + var Update; + if (data[i].downloadeq == data[i].downloaded && data[i].installeq == data[i].installed) + Update = " up-to-date"; + else + Update = "
update ready"; - $("#tblPackages tbody").append( - ""+ - ""+data[i].name+""+ //package name - ""+Update+""+ //package status - ""+data[i].size+""+ //package size - ""+data[i].downloaded+""+ //package installed - ""+data[i].installed+""+ //package installed - ""+ - ""+ - ""); - - $('#'+data[i].pkgname) + var Downloaded = data[i].downloaded; + if (data[i].downloadeq != data[i].downloaded) + Downloaded = 'old'; + + var Installed = data[i].installed; + if (data[i].installeq != data[i].installed) + Installed = 'old'; + + $("#tblPackages tbody").append( + ""+ + ""+data[i].name+""+ // package name + ""+Update+""+ // package status + ""+data[i].size+""+ // package size + ""+Downloaded+""+ // package installed + ""+Installed+""+ // package installed + ""+ + ""+ + ""); + + $("#"+data[i].pkgname) .switchButton({ - labels_placement: 'right', - on_label: 'On', - off_label: 'Off', + labels_placement: "right", + on_label: "On", + off_label: "Off", checked: data[i].config == "yes" }) .change(function() { - var par = $(this).parent().parent(); - if(this.checked) - par.find('.pkgvalue').val("yes"); - else - par.find('.pkgvalue').val("no"); + $(this).parent().parent().find(".pkgvalue").val(this.checked ? "yes": "no"); + if (this.checked) + checkDepends(); $("#btnApply").prop("disabled", false); - checkDepends(); }); - } - $("#tblPackages").trigger("update"); - - //tablesorter options - $('#tblPackages').tablesorter({ - sortList: [[0,1]], - widgets: ['saveSort', 'filter', 'stickyHeaders'], - widgetOptions: { - stickyHeaders_filteredToTop: true, - filter_hideEmpty : true, - filter_liveSearch : true, - filter_saveFilters : true, - filter_reset : 'button.reset', - filter_functions: { - '.filter-version' : true, - '.filter-downloaded' : true, - '.filter-installed' : true - } - } - }); - }, - error: function () { } + $("#tblPackages").trigger("update"); }); -}; +} function checkDepends() { - if ($('#screen').prop('checked') == true){ - $('#utempter').switchButton({checked: true}); - $('#utempter','.pkgvalue').val('yes'); + if ($("#screen").prop("checked")) { + $("#utempter").switchButton({checked: true}); + $("#utempter", ".pkgvalue").val("yes"); } - if ($('#iotop').prop('checked') == true){ - $('#python').switchButton({checked: true}); - $('#python','.pkgvalue').val('yes'); + if ($("#iotop").prop("checked")) { + $("#python").switchButton({checked: true}); + $("#python", ".pkgvalue").val("yes"); } -}; \ No newline at end of file +} \ 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 21ce5dd4..148bfc27 100755 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager @@ -18,8 +18,8 @@ Usage: packagemanager [options] EOF; -$shortopts = "drquv"; -$longopts = array( +$shortopts = "drquv"; +$longopts = [ "delete", "download", "help", @@ -27,17 +27,17 @@ $longopts = array( "uninstall", "verbose", "version" -); +]; $args = getopt($shortopts, $longopts); if (array_key_exists("help", $args)) { - echo $usage; - exit(1); + echo $usage; + exit(1); } if (array_key_exists("version", $args)) { - echo "Package Manager Version: 1.2\n"; - exit(1); + echo "Package Manager Version: 1.2\n"; + exit(1); } $argd = (array_key_exists("d", $args) || array_key_exists("download", $args)); @@ -46,89 +46,63 @@ $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)); -require_once("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php"); +require_once '/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php'; +require_once '/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php'; -function logger($output, $quiet) { - shell_exec( "echo '$output' 2>&1 | logger -tnerdpack"); - if (!$quiet) - echo "\n".$output." \n"; - usleep(100000); -} - -$plg_path ="/boot/config/plugins/NerdPack";// plugin path -$pkg_path = "$plg_path/packages/"; // package path -$config_file = "$plg_path/NerdPack.cfg";// config file - -$pkg_cfg = (is_file($config_file)) ? parse_ini_file($config_file) : array(); // get package configs - -$pkgs_downloaded = array_diff( scandir($pkg_path, 1), array(".", "..") ); // get array of packages - -$pkgs_installed = array_diff( scandir("/var/log/packages", 1), array(".", "..") ); - -$pkgs_json = $pkg_path."packages.json"; -$pkgs_file = (is_file($pkgs_json)) ? file_get_contents($pkgs_json) : array(); - -$pkgs_github = json_decode($pkgs_file, true); - -logger("Processing Packages...", 0); - -foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package +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_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"){ + if ($pkg_pref == 'yes') { + // if executing from the wegui check status and download if necessary + if ($argd) { + if (!preg_grep($pkg_pattern, $pkgs_downloaded)) { - //if executing from the wegui check status and download if necessary - if ($argd){ + $pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array); - if(!preg_grep($pkg_pattern, $pkgs_downloaded)) { - - $pkg_online_status = preg_grep($pkg_pattern , $pkgs_github); - - $pkg_matches = array_filter($pkgs_github, function($a) use($pkg_pattern ) { - return preg_grep($pkg_pattern , $a); + $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"]; - logger("Downloading $pkg_gitname package...", $argq); + $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']; + + logger('Downloading '.$pkg_gitname.' package...', $argq); get_file_from_url($pkg_file, $pkg_url); - if(file_check_sha1($pkg_file, $pkg_sha1)) - logger("$pkg_gitname package downloaded sucessfully!", $argq); + if (file_check_sha1($pkg_file, $pkg_sha1)) + logger($pkg_gitname.' package downloaded sucessfully!', $argq); else - logger("$pkg_gitname package download failed!", $argq); + logger($pkg_gitname.' package download failed!', $argq); } } - if (!$pkg_install_status){ - $pkg_msg = "Installing"; - $pkg_cmd = "upgradepkg --install-new ".$pkg_path.$pkg_name."* 2>&1"; + if (!$pkg_install_status) { + $pkg_msg = 'Installing'; + $pkg_cmd = 'upgradepkg --install-new '.$pkg_path.$pkg_name.'* 2>&1'; } - }elseif($pkg_pref == "no" && $pkg_install_status && $argu){ - - $pkg_msg = "Uninstalling"; - $pkg_cmd = "removepkg ".$pkg_path.$pkg_name."* 2>&1"; - if ($argr){ - $pkg_cmd .= "; rm ".$pkg_path.$pkg_name."* 2>&1"; - $pkg_msg .= " and deleting"; + } else if ($pkg_pref == 'no' && $pkg_install_status && $argu) { + $pkg_msg = 'Uninstalling'; + $pkg_cmd = 'removepkg '.$pkg_path.$pkg_name.'* 2>&1'; + if ($argr) { + $pkg_cmd .= '; rm '.$pkg_path.$pkg_name.'* 2>&1'; + $pkg_msg .= ' and deleting'; } } - if(!empty($pkg_cmd)){ - logger("$pkg_msg $pkg_name package...", 0); + if (!empty($pkg_cmd)) { + logger($pkg_msg.' '.$pkg_name.' package...'); shell_exec($pkg_cmd); //$output = shell_exec($pkg_cmd); //logger($output); - }else - logger($pkg_name." package up to date", $argq); + } else + logger($pkg_name.' package up to date', $argq); } -logger("All packages processed", 0); - +logger('All packages processed'); ?> \ No newline at end of file