mirror of
https://github.com/unraid/api.git
synced 2026-02-09 09:29:12 -06:00
Merge branch 'master' of github.com:unraid/node-api
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
<?xml version='1.0' standalone='yes'?>
|
||||
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "dynamix.unraid.net">
|
||||
<!ENTITY launch "Unraid.net">
|
||||
<!ENTITY author "limetech">
|
||||
<!ENTITY version "{{ plg_version }}">
|
||||
<!ENTITY node_api_version "{{ node_api_version }}">
|
||||
<!ENTITY plugins_version "{{ node_plugins_version }}">
|
||||
<!ENTITY pluginURL "https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/&name;.plg">
|
||||
<!ENTITY node-api "https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/unraid-node-api-&node_api_version;.tgz">
|
||||
<!ENTITY plugins "https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/unraid-plugins-&node_plugins_version;.tgz">
|
||||
<!ENTITY name "dynamix.unraid.net">
|
||||
<!ENTITY launch "Unraid.net">
|
||||
<!ENTITY author "limetech">
|
||||
<!ENTITY version "{{ plg_version }}">
|
||||
<!ENTITY node_api_version "{{ node_api_version }}">
|
||||
<!ENTITY node_plugins_version "{{ node_plugins_version }}">
|
||||
<!ENTITY pluginURL "https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/&name;.plg">
|
||||
<!ENTITY node-api "https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/unraid-node-api-&node_api_version;.tgz">
|
||||
<!ENTITY plugins "https://s3.amazonaws.com/dnld.lime-technology.com/unraid-api/unraid-plugins-&node_plugins_version;.tgz">
|
||||
]>
|
||||
|
||||
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" launch="&launch;" support="https://forums.unraid.net" min="6.9.0-beta30" icon="globe">
|
||||
@@ -142,7 +142,7 @@ install() {
|
||||
# Copy across wc files
|
||||
rm -rf /usr/local/emhttp/webGui/wc
|
||||
mkdir -p /usr/local/emhttp/webGui/wc
|
||||
cp -r /boot/config/plugins/Unraid.net/wc /usr/local/emhttp/webGui/wc
|
||||
cp /boot/config/plugins/Unraid.net/wc/* /usr/local/emhttp/webGui/wc
|
||||
|
||||
# Start new process
|
||||
start
|
||||
@@ -253,17 +253,11 @@ if (empty($remote['wanport'])) {
|
||||
$remote['wanport'] = 443;
|
||||
}
|
||||
|
||||
$hasCert = $var['USE_SSL']=='auto' && file_exists('/boot/config/ssl/certs/certificate_bundle.pem');
|
||||
$hasCert = $var['USE_SSL']!='no' &&
|
||||
file_exists('/boot/config/ssl/certs/certificate_bundle.pem') &&
|
||||
preg_match('/[0-9a-f]{40}\.unraid\.net$/', exec('openssl x509 -in /boot/config/ssl/certs/certificate_bundle.pem -subject -noout 2>&1'));
|
||||
$isRegistered = !empty($remote['apikey']);
|
||||
$boolWebUIAuth = $isRegistered && file_exists('/etc/nginx/htpasswd');
|
||||
|
||||
$isActivated = false;
|
||||
$isUptodate = false;
|
||||
if ($isRegistered) {
|
||||
exec("/usr/bin/php -f $docroot/plugins/dynamix.unraid.net/include/UpdateFlashBackup.php status", $output, $retval);
|
||||
$isActivated = ($retval == 0);
|
||||
if ($isActivated) $isUptodate = empty($output);
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
function registerServer(button) {
|
||||
@@ -404,6 +398,23 @@ function enableFlashBackup(button) {
|
||||
openBox("/webGui/include/gitstatus.php", "Changes", 600,600, false);
|
||||
}
|
||||
}
|
||||
|
||||
function buttonStateReset(newstate) {
|
||||
$('#loadingpanel,#inactivespanel,#activepanel,#changespanel,#uptodatepanel').hide();
|
||||
|
||||
if (newstate['activated']) {
|
||||
$('#activepanel').show();
|
||||
|
||||
if (newstate['uptodate']) {
|
||||
$('#uptodatepanel').show();
|
||||
} else {
|
||||
$('#changespanel').show();
|
||||
}
|
||||
} else {
|
||||
$('#inactivespanel').show();
|
||||
}
|
||||
}
|
||||
$.get('/plugins/dynamix.unraid.net/include/FlashBackupStatus.php', buttonStateReset, "json");
|
||||
</script>
|
||||
|
||||
<form id="UnraidNetSettings" markdown="1" name="UnraidNetSettings" method="POST" action="/update.htm" target="progressFrame">
|
||||
@@ -413,7 +424,7 @@ Unraid.net Status:
|
||||
<?if($isRegistered):?>
|
||||
Allow Remote Access:
|
||||
<?if(!$hasCert):?>
|
||||
: <span><i class="fa fa-warning icon warning"></i> Disabled until you Provision a SSL Cert and enable SSL/TLS</span>
|
||||
: <span><i class="fa fa-warning icon warning"></i> Disabled until you Provision an unraid.net SSL Cert and set SSL/TLS to Auto</span>
|
||||
<input type="hidden" id="wanaccess" value="no">
|
||||
<input type="hidden" id="wanport" value="0">
|
||||
<?elseif(!$boolWebUIAuth):?>
|
||||
@@ -442,8 +453,13 @@ WAN Port:
|
||||
|
||||
<?if($isRegistered):?>
|
||||
<form markdown="1" name="FlashBackup" method="POST" action="/update.htm" target="progressFrame">
|
||||
<div markdown="1" id="loadingpanel">
|
||||
Flash backup:
|
||||
: <span class='blue p0'>Loading <i class="fa fa-spinner fa-spin" aria-hidden="true"></i></span>
|
||||
|
||||
</div>
|
||||
<div markdown="1" id="inactivespanel" style="display:none">
|
||||
Flash backup:
|
||||
<?if(!$isActivated):?>
|
||||
: <span class='orange p0'>Not activated</span>
|
||||
|
||||
|
||||
@@ -451,10 +467,16 @@ Flash backup:
|
||||
|
||||
> Click Activate to set up a local git repo for your local USB Flash boot device and connect to a dedicated remote on unraid.net tied tothis server.
|
||||
|
||||
<?else:?>
|
||||
: <span class='green p0'>Activated:</span> <?if(!$isUptodate):?><span class='orange p0'>Not up-to-date</span><?else:?><span class='green p0'>Up-to-date</span><?endif?>
|
||||
</div>
|
||||
<div markdown="1" id="uptodatepanel" style="display:none">
|
||||
Flash backup:
|
||||
: <span class='green p0'>Activated:</span> <span class='green p0'>Up-to-date</span>
|
||||
|
||||
</div>
|
||||
<div markdown="1" id="changespanel" style="display:none">
|
||||
Flash backup:
|
||||
: <span class='green p0'>Activated:</span> <span class='orange p0'>Not up-to-date</span>
|
||||
|
||||
<?if(!$isUptodate):?>
|
||||
|
||||
: <button type="button" onclick="enableFlashBackup(this)">Update</button> <button type="button" onclick="enableFlashBackup(this)">Changes</button>
|
||||
|
||||
@@ -464,13 +486,15 @@ Flash backup:
|
||||
|
||||
> Click Changes to see what has changed.
|
||||
|
||||
<?else:?>
|
||||
</div>
|
||||
<div markdown="1" id="uptodatepanel" style="display:none">
|
||||
|
||||
: <button type="button" disabled>Update</button>
|
||||
|
||||
> The Up-to-date status indicates your local configuration matches that stored on the unraid.net remote.
|
||||
|
||||
<?endif?>
|
||||
</div>
|
||||
<div markdown="1" id="activepanel" style="display:none">
|
||||
|
||||
: <button type="button" onclick="enableFlashBackup(this)">Deactivate</button> <button type="button" onclick="enableFlashBackup(this)">Reinitialize</button>
|
||||
|
||||
@@ -478,7 +502,7 @@ Flash backup:
|
||||
|
||||
> Click Reinitialize to erase all change history in both local and unraid.net remote.
|
||||
|
||||
<?endif?>
|
||||
</div>
|
||||
</form>
|
||||
<?endif?>
|
||||
]]>
|
||||
@@ -738,6 +762,59 @@ esac
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<FILE Name="/usr/local/emhttp/plugins/dynamix.unraid.net/include/FlashBackupStatus.php">
|
||||
<INLINE>
|
||||
<![CDATA[
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, 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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
|
||||
if (file_exists('/boot/config/plugins/dynamix/dynamix.cfg')) {
|
||||
extract(parse_ini_file('/boot/config/plugins/dynamix/dynamix.cfg',true));
|
||||
}
|
||||
if (empty($remote)) {
|
||||
$remote = [
|
||||
"apikey" => "",
|
||||
"username" => "",
|
||||
"avatar" => "",
|
||||
"wanaccess" => "no",
|
||||
"wanport" => "443"
|
||||
];
|
||||
}
|
||||
|
||||
$isRegistered = !empty($remote['apikey']);
|
||||
$isActivated = false;
|
||||
$isUptodate = false;
|
||||
if ($isRegistered) {
|
||||
exec("/usr/bin/php -f $docroot/plugins/dynamix.unraid.net/include/UpdateFlashBackup.php status", $output, $retval);
|
||||
$isActivated = ($retval == 0);
|
||||
if ($isActivated) $isUptodate = empty($output);
|
||||
}
|
||||
|
||||
$arrReturn = [
|
||||
'registered' => $isRegistered,
|
||||
'activated' => $isActivated,
|
||||
'uptodate' => $isUptodate
|
||||
];
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($arrReturn);
|
||||
?>
|
||||
]]>
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
<FILE Name="/usr/local/emhttp/plugins/dynamix.unraid.net/include/UpdateFlashBackup.php">
|
||||
<INLINE>
|
||||
<![CDATA[
|
||||
@@ -1214,7 +1291,7 @@ fi
|
||||
|
||||
# Copy files to boot
|
||||
mkdir -p /boot/config/plugins/Unraid.net/wc
|
||||
cp -r /usr/local/emhttp/webGui/wc /boot/config/plugins/Unraid.net/wc
|
||||
cp /usr/local/emhttp/webGui/wc/* /boot/config/plugins/Unraid.net/wc
|
||||
]]>
|
||||
</INLINE>
|
||||
</FILE>
|
||||
|
||||
Reference in New Issue
Block a user