Merge branch 'master' into master

This commit is contained in:
dlandon
2024-04-12 08:04:31 -05:00
committed by GitHub
76 changed files with 877 additions and 1279 deletions

View File

@@ -1,93 +0,0 @@
#!/bin/bash
#
# script: WOL_action
#
# Startup script for unraidwold
#
# Simon Fairweather - Initial Script October 2023
DAEMON="unraidwold"
BINARY="/usr/local/bin/unraidwold"
# run & log functions
. /etc/rc.d/rc.runlog
. /boot/config/wol.cfg
unraidwold_running(){
sleep 0.1
ps axc | grep -q ' unraidwold'
}
unraidwold_start(){
log "Starting $DAEMON..."
local REPLY
if unraidwold_running; then
REPLY="Already started"
else
nohup $BINARY $1 $2 $3 $4 $5 $6 > /dev/null &
fi
log "$DAEMON... $REPLY."
}
unraidwold_stop(){
log "Stopping $DAEMON..."
local REPLY
if ! unraidwold_running; then
REPLY="Already stopped"
else
killall -TERM $DAEMON
if ! unraidwold_running; then REPLY="Stopped"; else REPLY="Failed"; fi
fi
log "$DAEMON... $REPLY."
}
unraidwold_status(){
if unraidwold_running; then
echo "$DAEMON is currently running."
else
echo "$DAEMON is not running."
exit 1
fi
}
unraidwold_load()
{
if unraidwold_running; then
unraidwold_stop
fi
sleep 1
if [ "$WOLENABLED" == "yes" ]; then
interfacemode=""
logoptions=""
if [ "$IFMODE" == "y" ]; then
interfacemode="--promiscuous"
fi
if [ "$LOGFILE" != "syslog" ]; then
logoptions="--log $LOGFILE"
fi
unraidwold_start --interface $INTERFACE $interfacemode $logoptions
fi
}
case "$1" in
'start')
unraidwold_start $2 $3 $4 $5 $6
;;
'stop')
unraidwold_stop
;;
'status')
unraidwold_status
;;
'load')
unraidwold_load
;;
*)
echo "Usage: $BDAEMON start|stop|restart|status"
exit 1
esac
exit 0

View File

@@ -25,6 +25,7 @@ $zip = $all ? ($argv[2]??'') : ($argv[1]??'');
$cli = empty($zip);
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Wrappers.php";
$folders = ['/boot','/boot/config','/boot/config/plugins','/boot/syslinux','/var/log','/var/log/plugins','/boot/extra','/var/log/packages','/var/lib/pkgtools/packages','/tmp'];
@@ -115,16 +116,6 @@ function maskIP($file) {
// anonymize full IPv6 addresses
run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null");
}
function cache_only($disk) {
return _var($disk,'type')=='Cache';
}
function cache_filter($disks) {
return array_filter($disks,'cache_only');
}
function pools_filter($disks) {
return array_unique(array_map('prefix',array_keys(cache_filter($disks))));
}
function download_url($url, $path="", $bg=false, $timeout=15) {
$ch = curl_init();
curl_setopt_array($ch,[
@@ -661,6 +652,13 @@ if (file_exists($dhcplog)) {
if (!$all) maskIP($log);
}
// copy phplog
$phplog = "/var/log/phplog";
if (file_exists($phplog)) {
$log = "/$diag/logs/phplog.txt";
run("todos <$phplog >".escapeshellarg($log));
}
// copy graphql-api.log
$graphql = "/var/log/graphql-api.log";
if (file_exists($graphql)) {

View File

@@ -35,7 +35,7 @@ if [[ -n $local_server ]]; then
sed -ri "\$a\\\$InputUDPServerBindRuleset remote\n\\\$UDPServerRun ${server_port:-514}" $ETC
[[ $server_protocol == udp ]] && sed -ri 's/^(\$ModLoad imtcp)/#\1/;/^\$InputTCPServerBindRuleset remote$/d;/^\$InputTCPServerRun [0-9]+$/d' $ETC
fi
sed -ri "/^\\\$template remote,.*$/d;/^#\\\$UDPServerRun [0-9]+.*$/a\\\$template remote,\"${server_folder:-/mnt/user/system}/syslog-%FROMHOST-IP%.log\"" $ETC
sed -ri "/^\\\$template remote,.*$/d;/^#\\\$UDPServerRun [0-9]+.*$/a\\\$template remote,\"${server_folder:-/mnt/user/system}/${server_filename:-syslog-%FROMHOST-IP%.log}\"" $ETC
else
sed -ri '/^\$RuleSet remote$/d;/^\$FileOwner nobody$/d;/^\$FileGroup users$/d;/^\$FileCreateMode 06[46][46]$/d;/^\$IncludeConfig \/etc\/rsyslog\.d\/\*\.conf # remote$/d;/^\*\.\* \?remote$/d;/^\$template remote,".*"$/d;/^\$Input(TCP|UDP)ServerBindRuleset remote$/d;/^\$(InputTCP|UDP)ServerRun [0-9]+$/d;s/^#?\$(ModLoad imtcp|ModLoad imudp)/#\$\1/' $ETC
fi

View File

@@ -1,7 +1,7 @@
#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
/* Copyright 2005-2024, Lime Technology
* Copyright 2012-2024, 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,
@@ -21,6 +21,7 @@ $disks = (array)@parse_ini_file("/var/local/emhttp/disks.ini",true);
require_once "$docroot/webGui/include/CustomMerge.php";
$script = "$docroot/webGui/scripts/notify";
// this command will set the $notify array
extract(parse_plugin_cfg("dynamix",true));
$output = _var($notify,'report');
$server = strtoupper(_var($var,'NAME','tower'));
@@ -178,7 +179,8 @@ $warn = ($error0 || $error3) ? "alert" : (($error1 || $error2) ? "warning" : "no
$stat = $warn=="normal" ? "[PASS]" : "[FAIL]";
$info = "Array has $size disk".($size==1 ? "" : "s").($parity ? " ({$word}parity".($pools ? " & pools)" : ")") : ($pools ? " ({$word}pools)" : ""));
$message = implode('\n', $data);
exec("$script -s ".escapeshellarg("Notice [$server] - array health report $stat")." -d ".escapeshellarg("$info")." -m ".escapeshellarg("$message")." -i ".escapeshellarg("$warn $output")." -l '/Main'");
$subject = "Notice [$server] - array health report $stat";
exec("$script -s ".escapeshellarg($subject)." -d ".escapeshellarg("$info")." -m ".escapeshellarg("$message")." -i ".escapeshellarg("$warn $output")." -l '/Main'");
exit(0);
?>