mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2025-12-20 05:11:30 +00:00
[Dovecot] Suppress doveconf -P output on startup
This commit is contained in:
@@ -670,24 +670,20 @@ class BootstrapBase:
|
|||||||
allowed_chars = string.ascii_letters + string.digits + "_-"
|
allowed_chars = string.ascii_letters + string.digits + "_-"
|
||||||
return ''.join(secrets.choice(allowed_chars) for _ in range(length))
|
return ''.join(secrets.choice(allowed_chars) for _ in range(length))
|
||||||
|
|
||||||
def run_command(self, command, check=True, shell=False, input_stream=None):
|
def run_command(self, command, check=True, shell=False, input_stream=None, log_output=True):
|
||||||
"""
|
"""
|
||||||
Executes an OS command and optionally checks for errors.
|
Executes a shell command and optionally logs output.
|
||||||
Supports piping via input_stream.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
command (str or list): The command to execute.
|
command (str or list): Command to run.
|
||||||
check (bool): Raise CalledProcessError on failure if True.
|
check (bool): Raise if non-zero exit.
|
||||||
shell (bool): Run in a shell if True.
|
shell (bool): Run in shell.
|
||||||
input_stream: A pipe source to use as stdin (e.g. another process's stdout).
|
input_stream: stdin stream.
|
||||||
|
log_output (bool): If True, print output.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
subprocess.CompletedProcess: The result of the command execution.
|
subprocess.CompletedProcess
|
||||||
|
|
||||||
Logs:
|
|
||||||
Prints command output and errors.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
command,
|
command,
|
||||||
@@ -698,10 +694,11 @@ class BootstrapBase:
|
|||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
text=True
|
text=True
|
||||||
)
|
)
|
||||||
if result.stdout:
|
if log_output:
|
||||||
print(result.stdout.strip())
|
if result.stdout:
|
||||||
if result.stderr:
|
print(result.stdout.strip())
|
||||||
print(result.stderr.strip())
|
if result.stderr:
|
||||||
|
print(result.stderr.strip())
|
||||||
return result
|
return result
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Command failed with exit code {e.returncode}: {e.cmd}")
|
print(f"Command failed with exit code {e.returncode}: {e.cmd}")
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class Bootstrap(BootstrapBase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.run_command(["doveconf", "-P"], check=True)
|
result = self.run_command(["doveconf", "-P"], check=True, log_output=False)
|
||||||
pubkey_path = None
|
pubkey_path = None
|
||||||
for line in result.stdout.splitlines():
|
for line in result.stdout.splitlines():
|
||||||
if "mail_crypt_global_public_key" in line:
|
if "mail_crypt_global_public_key" in line:
|
||||||
|
|||||||
Reference in New Issue
Block a user