Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/dynamix.docker.manager/include/CreateDocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
?>
<?
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$var = parse_ini_file('state/var.ini');

ignore_user_abort(true);

Expand Down
23 changes: 8 additions & 15 deletions plugins/dynamix.plugin.manager/Plugins.page
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Title="Installed Plugins"
Tabs="true"
---
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
Expand All @@ -18,15 +18,14 @@ Tabs="true"

<?
// Remove stale /tmp/plugin/*.plg entries
$tmp_stale = ($path != $prev);
if ($tmp_stale) foreach (glob("/tmp/plugins/*.{plg,txt}", GLOB_NOSORT+GLOB_BRACE) as $entry) if (!file_exists("/var/log/plugins/".basename($entry))) @unlink($entry);
$stale = ($path != $prev);
if ($stale) foreach (glob("/tmp/plugins/*.{plg,txt}", GLOB_NOSORT+GLOB_BRACE) as $entry) if (!file_exists("/var/log/plugins/".basename($entry))) @unlink($entry);
?>
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.filetree.css">
<style>
#plugin_tree{width:33%;height:200px;overflow:scroll;}
#plugin_tree{width:33%;height:200px;overflow-y:scroll;}
</style>
<script src="/webGui/javascript/jquery.filetree.js"></script>

<script>
<?if ($display['resize']):?>
function resize(bind) {
Expand All @@ -42,7 +41,7 @@ function resize(bind) {
}
<?endif;?>
$(function() {
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{stale:'<?=$tmp_stale?>'},function(data) {
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{stale:'<?=$stale?>'},function(data) {
if (data) $('#plugin_list').html(data);
<?if ($display['resize']):?>
resize();
Expand All @@ -52,15 +51,9 @@ $(function() {
$('.desc_readmore').readmore({maxHeight:58});
});
$('#plugin_tree').fileTree({root:'/boot/',filter:'plg'}, function(file) {$('#plugin_file').val(file);});
$('.tabs').append("<span class='status vhshift'><input type='button' value='Check for Updates' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkall\",\"Plugin Update Check\",490,430,true)'></span>");
});
</script>

<blockquote class="inline_help ontop">
Click <span class="strong big">check for updates</span> to check all plugins. This page might take some time to load depending on your internet connection and how many plugins need to be checked.
</blockquote>

<table class='tablesorter plugins shift' id='plugin_table'>
<thead><tr><th></th><th>Plugin</th><th>Author</th><th>Version</th><th>Status</th><th></th></tr></thead>
<tbody id="plugin_list"><tr><td colspan='6' style='text-align:center;padding-top:12px'><i class="fa fa-spinner fa-spin icon"></i><em>Please wait, retrieving plugin information ...</em></td><tr></tbody>
<thead><tr><th></th><th>Plugin</th><th>Author</th><th>Version</th><th>Status</th><th>Uninstall</th></tr></thead>
<tbody id="plugin_list"><tr><td colspan='6' style='text-align:center;padding-top:12px'><i class="fa fa-spinner fa-spin icon"></i><em>Please wait,<?=$stale?' updating and':''?> retrieving plugin information ...</em></td><tr></tbody>
</table>
47 changes: 47 additions & 0 deletions plugins/dynamix.plugin.manager/Update.page
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Menu="About"
Title="Update OS"
---
<?PHP
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>

<?$empty = "<tr><td colspan='6' style='text-align:center;padding-top:12px'><i class='fa fa-spinner fa-spin icon'></i><em>Please wait, updating and retrieving system information ...</em></td><tr>"?>
<script>
var original = null;

function change_release(release) {
$('#os_list').html("<?=$empty?>");
if (original) {
if (release != original) release = '';
} else {
if (release) original = release;
}
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:'true',release:release},function(data) {
if (data) $('#os_list').html(data);
$('#os_table').trigger('update',true);
});
}
$(function() {
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:'true'},function(data) {
if (data) $('#os_list').html(data);
$('#os_table').tablesorter({sortList:[[1,0]],headers:{0:{sorter:false},5:{sorter:false}}});
<?if (preg_match("/^\*\*REBOOT REQUIRED\!\*\*/",@file_get_contents("$docroot/plugins/unRAIDServer/README.md"))):?>
$('#change_release').prop('disabled',true);
<?endif;?>
});
});
</script>

<table class='tablesorter plugins shift' id='os_table'>
<thead><tr><th></th><th>System</th><th>Author</th><th>Version</th><th>Status</th><th>Release</th></tr></thead>
<tbody id="os_list"><?=$empty?></tbody>
</table>
Binary file added plugins/dynamix.plugin.manager/icons/updateos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions plugins/dynamix.plugin.manager/include/PluginHelpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
Expand All @@ -11,7 +11,7 @@
*/
?>
<?
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';

// Invoke the plugin command with indicated method
function plugin($method, $arg = '') {
Expand All @@ -21,12 +21,12 @@ function plugin($method, $arg = '') {
return implode("\n", $output);
}

function make_link($method, $arg) {
function make_link($method, $arg, $extra='') {
$id = basename($arg, ".plg").$method;
$check = $method=='update' ? "" : "<input type='checkbox' onClick='document.getElementById(\"$id\").disabled=!this.checked'>";
$check = $method=='remove' ? "<input type='checkbox' onClick='document.getElementById(\"$id\").disabled=!this.checked'>" : "";
$disabled = $check ? " disabled" : "";
$cmd = $method == "delete" ? "/plugins/dynamix.plugin.manager/scripts/plugin_rm&arg1=$arg" : "/plugins/dynamix.plugin.manager/scripts/plugin&arg1=$method&arg2=$arg";
return "{$check}<input type='button' id='$id' value='{$method}' onclick='openBox(\"{$cmd}\",\"".ucwords($method)." Plugin\",600,900,true)'{$disabled}>";
$cmd = $method == "delete" ? "/plugins/dynamix.plugin.manager/scripts/plugin_rm&arg1=$arg" : "/plugins/dynamix.plugin.manager/scripts/plugin&arg1=$method&arg2=$arg".($extra?"&arg3=$extra":"");
return "{$check}<input type='button' id='$id' value='".ucfirst($method)."' onclick='hideUpgrade();openBox(\"{$cmd}\",\"".ucwords($method)." Plugin\",600,900,true)'{$disabled}>";
}

// trying our best to find an icon
Expand All @@ -47,4 +47,7 @@ function icon($name) {
// last resort - plugin manager icon
return "plugins/dynamix.plugin.manager/images/dynamix.plugin.manager.png";
}
function mk_option($select,$value) {
return "<option value='$value'".($select==$value?" selected":"").">".ucfirst($value)."</option>";
}
?>
137 changes: 92 additions & 45 deletions plugins/dynamix.plugin.manager/include/ShowPlugins.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?PHP
/* Copyright 2005-2016, Lime Technology
* Copyright 2012-2016, Bergware International.
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
Expand All @@ -11,78 +11,125 @@
*/
?>
<?
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Markdown.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";

$current = parse_ini_file('/etc/unraid-version');
foreach (glob("/var/log/plugins/*.plg", GLOB_NOSORT) as $plugin_link) {
// only consider symlinks
$stale = $_GET['stale'] ?? false;
$release = $_GET['release'] ?? false;
$system = $_GET['system'] ?? false;
$empty = true;
$nofetch = false;
$builtin = ['unRAIDServer','dynamix'];
$https = ['stable' => 'https://raw.github.com/limetech/\&name;/master/\&name;.plg',
'next' => 'https://s3.amazonaws.com/dnld.lime-technology.com/\&category;/\&name;.plg'];

foreach (glob("/var/log/plugins/*.plg",GLOB_NOSORT) as $plugin_link) {
//only consider symlinks
$plugin_file = @readlink($plugin_link);
if ($plugin_file === false) continue;
// plugin name
$name = plugin("name", $plugin_file);
if ($name === false) $name = basename($plugin_file, ".plg");
// link/icon
//plugin name
$name = plugin('name',$plugin_file) ?: basename($plugin_file,".plg");
$custom = in_array($name,$builtin);
//switch between system and custom plugins
if (($system && !$custom) || (!$system && $custom)) continue;
//forced plugin check?
if ($stale || $system) plugin('check',$name.'.plg');
//OS update?
$os = $system && $name==$builtin[0];
$toggle = false;
//toggle stable/next release?
if ($os && $release) {
$toggle = plugin('version',$plugin_file);
$cat = strpos($toggle,'rc')!==false ? 'stable' : 'next';
$tmp_plg = "$name-.plg";
$tmp_file = "/var/tmp/$name.plg";
copy($plugin_file,$tmp_file);
exec("sed -ri 's|^(<!ENTITY category).*|\\1 \"{$cat}\">|' $tmp_file");
exec("sed -ri 's|^(<!ENTITY pluginURL).*|\\1 \"{$https[$release]}\">|' $tmp_file");
symlink($tmp_file,"/var/log/plugins/$tmp_plg");
plugin('check',$tmp_plg);
copy("/tmp/plugins/$tmp_plg",$tmp_file);
$plugin_file = $tmp_file;
}
//link/icon
$icon = icon($name);
if ($launch = plugin("launch", $plugin_file))
$link = "<a href='/$launch'><img src='/$icon' width='48px'/></a>";
if ($launch = plugin('launch',$plugin_file))
$link = "<a href='/$launch'><img src='/$icon'></a>";
else
$link = "<img src='/{$icon}' width='48px'/>";
// desc
$link = "<img src='/$icon'>";
//description
$readme = "plugins/{$name}/README.md";
if (file_exists($readme))
$desc = Markdown(file_get_contents($readme));
else
$desc = Markdown("**{$name}**");
// author
$author = plugin("author", $plugin_file);
if ($author === false) $author = "anonymous";
// version
$version = plugin("version", $plugin_file);
if ($version === false) $version = "unknown";
// version info
$version_info = $version;
// status info
$status_info = "no update";
//author
$author = plugin('author',$plugin_file) ?: "anonymous";
//version
$version = plugin('version',$plugin_file) ?: "unknown";
//category
$cat = strpos($version,'rc')!==false ? 'next' : 'stable';
//status
$status = 'no update';
$changes_file = $plugin_file;
$URL = plugin("pluginURL", $plugin_file);
$URL = plugin('pluginURL',$plugin_file);
if ($URL !== false) {
$filename = "/tmp/plugins/".basename($URL);
$filename = "/tmp/plugins/".(($os && $release) ? $tmp_plg : basename($URL));
if (file_exists($filename)) {
$latest = plugin("version", $filename);
if (strcmp($latest, $version) > 0) {
$unRAID = plugin("unRAID", $filename);
if ($unRAID === false || version_compare($current['version'], $unRAID, '>=')) {
$version_info .= "<br><span class='red-text'>{$latest}</span>";
$status_info = make_link("update", basename($plugin_file));
$changes_file = $filename;
if ($toggle && $toggle != $version) {
$status = make_link('install',$plugin_file,'forced');
} else {
$latest = plugin('version',$filename);
if (strcmp($latest,$version) > 0) {
$unRAID = plugin('unRAID',$filename);
if ($unRAID === false || version_compare($current['version'],$unRAID,'>=')) {
$version .= "<br><span class='red-text'>{$latest}</span>";
$status = make_link("update",basename($plugin_file));
$changes_file = $filename;
} else {
$status = "up-to-date";
}
} else {
$status_info = "up-to-date";
$status = "up-to-date";
}
} else {
$status_info = "up-to-date";
}
} else {
if ($_GET['stale']) $status_info = "unknown";
if ($stale) $status = "unknown";
}
$nofetch |= ($status == 'no update');
}
$changes = plugin("changes", $changes_file);
$changes = plugin('changes',$changes_file);
if ($changes !== false) {
$txtfile = "/tmp/plugins/".basename($plugin_file,'.plg').".txt";
file_put_contents($txtfile, $changes);
$version_info .= "&nbsp;<a href='#' title='View Release Notes' onclick=\"openBox('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=".urlencode($txtfile)."','Release Notes',600,900); return false\"><img src='/webGui/images/information.png' class='icon'></a>";
file_put_contents($txtfile,$changes);
$version .= "&nbsp;<a href='#' title='View Release Notes' onclick=\"openBox('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=".urlencode($txtfile)."','Release Notes',600,900); return false\"><img src='/webGui/images/information.png' class='icon'></a>";
}
// action
$action = strpos($plugin_file, "$docroot/plugins") !== 0 ? make_link("remove", basename($plugin_file)) : "built-in";
// write plugin information
//write plugin information
$empty = false;
echo "<tr>";
echo "<td style='vertical-align:top;width:64px'><p style='text-align:center'>{$link}</p></td>";
echo "<td><span class='desc_readmore' style='display:block'>{$desc}</span></td>";
echo "<td>{$author}</td>";
echo "<td>{$version_info}</td>";
echo "<td>{$status_info}</td>";
echo "<td>{$action}</td>";
echo "<td>{$version}</td>";
echo "<td>{$status}</td>";
echo "<td>";
if ($system) {
if ($os) {
echo "<select id='change_release' class='auto' onchange='change_release(this.value)'>";
echo mk_option($cat,'stable');
echo mk_option($cat,'next');
echo "</select>";
}
} else {
echo make_link('remove',basename($plugin_file));
}
echo "</td>";
echo "</tr>";
//remove temporary symlink
@unlink("/var/log/plugins/$tmp_plg");
}
if ($empty) echo "<tr><td colspan='6' style='text-align:center;padding-top:12px'><i class='fa fa-check-square-o icon'></i> No plugins installed</td><tr>";
elseif ($nofetch) echo "<tr><td colspan='4'></td><td><input type='button' value='Retry' onclick='change_release()'></td><td></td><tr>";
?>
26 changes: 16 additions & 10 deletions plugins/dynamix.plugin.manager/scripts/plugin
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
$usage = <<<EOF
Process plugin files.

Usage: plugin install PLUGIN-FILE
Usage: plugin install PLUGIN-FILE [forced]
install a plugin

PLUGIN-FILE is a plugin definition XML file with ".plg" extension.

PLUGIN-FILE can be a local file, or a URL. If a URL, the plugin file is first downloaded to /tmp/plugins.

forced is optional and can be used to install a lower version than currently running.

This command will process all FILE elements in PLUGIN-FILE which are tagged with the "install" method (or
that have no method tag).

Expand Down Expand Up @@ -56,7 +58,7 @@ Usage: plugin check PLUGIN
Usage: plugin checkall
check all installed plugins

Runs 'plugin check PLUGIN' for each plugin file linked-to in /var/lib/plugins.
Runs 'plugin check PLUGIN' for each plugin file linked-to in /var/log/plugins.

Usage: plugin update PLUGIN
update the plugin
Expand Down Expand Up @@ -438,14 +440,18 @@ if ($method == "install") {
echo "plugin: $error\n";
exit(1);
}
// do not re-install if same plugin already installed or has higher version
if (strcmp($version, $installed_version) < 0) {
echo "plugin: not installing older version\n";
exit(1);
}
if (strcmp($version, $installed_version) == 0) {
echo "plugin: not reinstalling same version\n";
exit(1);
// check version installation?
$forced = $argc==4 ? $argv[3] : false;
if (!$forced) {
// do not re-install if same plugin already installed or has higher version
if (strcmp($version, $installed_version) < 0) {
echo "plugin: not installing older version\n";
exit(1);
}
if (strcmp($version, $installed_version) == 0) {
echo "plugin: not reinstalling same version\n";
exit(1);
}
}
if (plugin("install", $plugin_file, $error) === false) {
echo "plugin: $error\n";
Expand Down
Loading