Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup setting persistent journal config file #309

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions resources/lib/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,24 +701,26 @@ def do_journald(self, listItem=None):
if not listItem == None:
self.set_value(listItem)
if self.struct['journal']['settings']['journal_persistent']['value'] == '0':
try:
if os.path.isfile(self.JOURNALD_CONFIG_FILE):
os.remove(self.JOURNALD_CONFIG_FILE)
except:
pass
else:
config_file = open(self.JOURNALD_CONFIG_FILE, 'w')
config_file.write("# SPDX-License-Identifier: GPL-2.0-or-later\n" +
"# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)\n\n" +
"# This file is generated automatically, don't modify.\n\n" +
"[Journal]\n")

size = self.struct['journal']['settings']['journal_size']['value'].replace(' MiB', 'M')
config_file.write(f"SystemMaxUse={size}\n" +
"MaxRetentionSec=0\n")
if self.struct['journal']['settings']['journal_rate_limit']['value'] == '1':
config_file.write("RateLimitInterval=0\n" +
"RateLimitBurst=0\n")
config_file.close()
journal_config = f"""\
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)

# This file is generated automatically. Do not modify.

[Journal]
SystemMaxUse={size}
MaxRetentionSec=0
{'RateLimitInterval=0' if self.struct['journal']['settings']['journal_rate_limit']['value'] == '1' else ''}
{'RateLimitBurst=0' if self.struct['journal']['settings']['journal_rate_limit']['value'] == '1' else ''}
"""
# remove trailing whitespace, then add one new line
journal_config = f'{journal_config.rstrip()}{chr(10)}'
with open(self.JOURNALD_CONFIG_FILE, 'w') as config_file:
config_file.write(journal_config)

@log.log_function()
def do_wizard(self):
Expand Down