System update

This commit is contained in:
bergware
2022-07-05 11:49:03 +02:00
parent ca0b37c932
commit bd08a31ebc
7 changed files with 69 additions and 47 deletions

View File

@@ -24,7 +24,7 @@ $_SERVER['REQUEST_URI'] = 'plugins';
$_SESSION['locale'] = $display['locale'];
require_once "$docroot/webGui/include/Translations.php";
$console = !(isset($argv[1]) && $argv[1]=='nchan');
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
function write($message){
global $console;

View File

@@ -51,14 +51,6 @@ function error_desc($code) {
}
}
// Set output control
// Check for optional parameter 'nchan'
//
function console($i) {
global $console, $argv;
$console = !(isset($argv[$i]) && $argv[$i]=='nchan');
}
// Function to write either to console (echo) or nchan (curl)
// Default output is console, use optional parameter "nchan" to write to nchan instead
//
@@ -193,13 +185,12 @@ $boot = '/boot/config/plugins';
$plugins = '/var/log/plugins';
$tmp = '/tmp/plugins';
$method = $argv[1];
$console = true; // default output is console, nchan otherwise
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
// language checkall
// check all installed languages
//
if ($method == 'checkall') {
console(2);
write("language: checking all language packs\n");
foreach (glob("$plugins/lang-*.xml", GLOB_NOSORT) as $link) {
$lang_file = @readlink($link);
@@ -217,7 +208,6 @@ if ($method == 'checkall') {
// update all installed languages
//
if ($method == 'updateall') {
console(2);
write("language: updating all language packs\n");
foreach (glob("$plugins/lang-*.xml", GLOB_NOSORT) as $link) {
$lang_file = @readlink($link);
@@ -245,7 +235,6 @@ if ($argc < 3) {
// language install [language_file]
//
if ($method == 'install') {
console(3);
$argv[2] = preg_replace('#[\x00-\x1F\x80-\xFF]#', '', $argv[2]);
$name = basename($argv[2]);
write("language: installing language pack\n");
@@ -280,7 +269,6 @@ if ($method == 'install') {
// language check [language]
//
if ($method == 'check') {
console(3);
$name = $argv[2];
write("language: checking language pack\n");
$link_file = "$plugins/lang-$name.xml";
@@ -312,7 +300,6 @@ if ($method == 'check') {
// language update [language]
//
if ($method == 'update') {
console(3);
$name = $argv[2];
write("language: updating language pack\n");
$link_file = "$plugins/lang-$name.xml";
@@ -352,7 +339,6 @@ if ($method == 'update') {
// language remove [language]
//
if ($method == 'remove') {
console(3);
$name = $argv[2];
write("language: removing language pack: $name\n");
$link_file = "$plugins/lang-$name.xml";
@@ -373,7 +359,6 @@ if ($method == 'remove') {
// return attribute
//
console(3);
$xml_file = $argv[2];
$value = language($method, $xml_file, $error);
if ($value === false) {

View File

@@ -14,7 +14,7 @@
<?
$method = $argv[1];
$plugins = explode('*',$argv[2]);
$console = !(isset($argv[3]) && $argv[3]=='nchan');
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
function write($message){
global $console;

View File

@@ -162,14 +162,6 @@ function error_desc($code) {
}
}
// Set output control
// Check for optional parameter 'nchan'
//
function console($i) {
global $console, $argv;
$console = !(isset($argv[$i]) && $argv[$i]=='nchan');
}
// Function to write either to console (echo) or nchan (curl)
// Default output is console, use optional parameter "nchan" to write to nchan instead
//
@@ -465,13 +457,12 @@ $plugins = '/var/log/plugins';
$tmp = '/tmp/plugins';
$method = $argv[1];
$builtin = ['unRAIDServer','unRAIDServer-'];
$console = true; // default output is console, nchan otherwise
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
// plugin checkall
// check all installed plugins, except built-in
//
if ($method == 'checkall') {
console(2);
if (!$cmd = realpath($argv[0])) {
write("Unknown command: {$argv[0]}\n");
exit(1);
@@ -494,7 +485,6 @@ if ($method == 'checkall') {
// update all installed plugins, which have a update available
//
if ($method == 'updateall') {
console(2);
if (!$cmd = realpath($argv[0])) {
write("Unknown command: {$argv[0]}\n");
exit(1);
@@ -522,7 +512,6 @@ if ($method == 'updateall') {
// check built-in only
//
if ($method == 'checkos') {
console(2);
if (!$cmd = realpath($argv[0])) {
write("Unknown command: {$argv[0]}\n");
exit(1);
@@ -553,7 +542,6 @@ if ($argc < 3) {
//
$unraid = parse_ini_file('/etc/unraid-version');
if ($method == 'install') {
console(3);
$argv[2] = preg_replace('#[\x00-\x1F\x80-\xFF]#', '', $argv[2]);
$plugin = basename($argv[2]);
write("plugin: installing: $plugin\n");
@@ -667,7 +655,6 @@ if ($method == 'install') {
// directory.
//
if ($method == 'check') {
console(3);
$plugin = $argv[2];
$symlink = "$plugins/$plugin";
write("plugin: checking: $plugin ...\n");
@@ -709,7 +696,6 @@ if ($method == 'check') {
// Finally we mark the new.plg "installed".
//
if ($method == 'update') {
console(3);
$plugin = $argv[2];
$symlink = "$plugins/$plugin";
write("plugin: updating: $plugin\n");
@@ -763,7 +749,6 @@ if ($method == 'update') {
// only .plg files should have a remove method
//
if ($method == 'remove') {
console(3);
$plugin = $argv[2];
$symlink = "$plugins/$plugin";
write("plugin: removing: $plugin\n");
@@ -793,7 +778,6 @@ if ($method == 'remove') {
// return attribute
//
console(3);
$plugin_file = $argv[2];
$value = plugin($method, $plugin_file, $error);
if ($value === false) {

View File

@@ -1,10 +1,10 @@
Menu="Registration"
Title="Install Key"
Tag="flag"
Cond="($var['regTy']!='Pro')"
Cond="($var['regTy']=='Pro')"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
/* Copyright 2005-2022, Lime Technology
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
@@ -14,18 +14,21 @@ Cond="($var['regTy']!='Pro')"
* all copies or substantial portions of the Software.
*/
?>
<style>
span.info{margin-left:12px}
</style>
<script>
function installKey(file) {
if (file)
openBox("/webGui/include/InstallKey.php?url="+file,"_(Install Key)_",600,900,true);
file = file.trim();
if (file) openPlugin('install_key '+encodeURIComponent(file), "_(Install Key)_");
}
</script>
<form markdown="1">
_(To install a registration key, paste the key file URL in the box below and click **Install Key**)_.
<span class="info">_(To install a registration key, paste the key file URL in the box below and click **Install Key**)_.</span>
_(Key file URL)_:
: <input type="text" name="file" id="key_file" maxlength="1024" value="" style="width:33%">
<input type="button" value="_(Install Key)_" onclick="installKey(this.form.file.value.trim())">
</form>

View File

@@ -0,0 +1,47 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
*
* 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.
*/
?>
<?
function write($message) {
$nchan = curl_init();
curl_setopt_array($nchan,[
CURLOPT_URL => 'http://localhost/pub/plugins?buffer_length=0',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $message,
CURLOPT_RETURNTRANSFER => true
]);
curl_exec($nchan);
curl_close($nchan);
}
$url = rawurldecode($argv[1]);
$host = parse_url($url)['host'];
usleep(50000);
if (in_array($host,['keys.lime-technology.com','lime-technology.com'])) {
$key_file = basename($url);
write("Downloading $keyfile ...\n");
exec("/usr/bin/wget -q -O ".escapeshellarg("/boot/config/$key_file")." ".escapeshellarg($url), $output, $return_var);
if ($return_var === 0) {
if (parse_ini_file('/var/local/emhttp/var.ini')['mdState'] == 'STARTED') {
write("Installing ... Please Stop array to complete key installation.\n");
} else {
write("Installed ...\n");
}
} else {
write("ERROR: $return_var\n");
}
} else {
write("ERROR, bad or missing key file URL: $url\n");
}
?>

View File

@@ -1,5 +1,7 @@
#!/usr/bin/php -q
<?
# Copyright 2005-2022, Lime Technology
#
# Usage: newperms [dir] [owner] [group]
# Recursively changes the ownership and permissions of the directory and all files/subdirs
# within the directory.
@@ -16,8 +18,8 @@
# go+u Copy the user permissions to group and other
# ugo+X Set the 'x' bit for directories in user, group, and other
$console = $argv[$argc-1] != 'nchan';
if (!$console) unset($argv[$argc-1]);
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
if (!$console) unset($argv[$argc-1]); // remove nchan parameter
function write($message) {
global $console;
@@ -39,8 +41,8 @@ function write($message) {
function process($path) {
global $argv;
$owner = $argv[2] ?: "nobody";
$group = $argv[3] ?: "users";
$owner = $argv[2] ?: 'nobody';
$group = $argv[3] ?: 'users';
if (is_dir($path)) {
write("Processing: $path\n");
write("... chmod -R u-x,go-rwx,go+u,ugo+X $path\n");
@@ -56,12 +58,13 @@ function process($path) {
$startTime = time();
if ($argv[1]) {
usleep(50000);
$paths = explode('*',rawurldecode($argv[1]));
foreach ($paths as $path) process($path);
} else {
$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);
foreach ($disks as $disk => $prop) {
if (is_dir("/mnt/$disk") && $prop['status'] !== "DISK_NP_DSBL" && $prop['status'] !== "DISK_NP") process("/mnt/$disk");
if (is_dir("/mnt/$disk") && !in_array($prop['status'],['DISK_NP_DSBL','DISK_NP'])) process("/mnt/$disk");
}
}