Ensure irc fifo-file is shared between dispatcher and core containers (#14647)

* Ensure fifo-file is shared between dispatcher container and core container

* Fix config path
This commit is contained in:
Olen
2023-04-28 16:03:24 +02:00
committed by GitHub
parent 741d93c2a5
commit 7ec37561c5
2 changed files with 12 additions and 2 deletions

View File

@@ -37,7 +37,12 @@ class Irc extends Transport
public function contactIrc($obj, $opts) public function contactIrc($obj, $opts)
{ {
$f = Config::get('install_dir') . '/.ircbot.alert'; $container_dir = '/data';
if (file_exists($container_dir) and posix_getpwuid(fileowner($container_dir))['name'] == 'librenms') {
$f = $container_dir . '/.ircbot.alert';
} else {
$f = Config::get('install_dir') . '/.ircbot.alert';
}
if (file_exists($f) && filetype($f) == 'fifo') { if (file_exists($f) && filetype($f) == 'fifo') {
$f = fopen($f, 'w+'); $f = fopen($f, 'w+');
$r = fwrite($f, json_encode($obj) . "\n"); $r = fwrite($f, json_encode($obj) . "\n");

View File

@@ -218,7 +218,12 @@ class IRCBot
private function connectAlert() private function connectAlert()
{ {
$f = $this->config['install_dir'] . '/.ircbot.alert'; $container_dir = '/data';
if (file_exists($container_dir) and posix_getpwuid(fileowner($container_dir))['name'] == 'librenms') {
$f = $container_dir . '/.ircbot.alert';
} else {
$f = $this->config['install_dir'] . '/.ircbot.alert';
}
if ((file_exists($f) && filetype($f) != 'fifo' && ! unlink($f)) || (! file_exists($f) && ! shell_exec("mkfifo $f && echo 1"))) { if ((file_exists($f) && filetype($f) != 'fifo' && ! unlink($f)) || (! file_exists($f) && ! shell_exec("mkfifo $f && echo 1"))) {
$this->log('Error - Cannot create Alert-File'); $this->log('Error - Cannot create Alert-File');