summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/system-syslog.py14
-rw-r--r--src/etc/logrotate.d/vyos-rsyslog12
-rwxr-xr-xsrc/helpers/system-versions-foot.py19
-rwxr-xr-xsrc/helpers/vyos-save-config.py54
4 files changed, 38 insertions, 61 deletions
diff --git a/src/conf_mode/system-syslog.py b/src/conf_mode/system-syslog.py
index 3d8a51cd8..309b4bdb0 100755
--- a/src/conf_mode/system-syslog.py
+++ b/src/conf_mode/system-syslog.py
@@ -17,6 +17,7 @@
import os
import re
+from pathlib import Path
from sys import exit
from vyos.config import Config
@@ -89,7 +90,7 @@ def get_config(config=None):
filename: {
'log-file': '/var/log/user/' + filename,
'max-files': '5',
- 'action-on-max-size': '/usr/sbin/logrotate /etc/logrotate.d/' + filename,
+ 'action-on-max-size': '/usr/sbin/logrotate /etc/logrotate.d/vyos-rsyslog-generated-' + filename,
'selectors': '*.err',
'max-size': 262144
}
@@ -205,10 +206,17 @@ def generate(c):
conf = '/etc/rsyslog.d/vyos-rsyslog.conf'
render(conf, 'syslog/rsyslog.conf.tmpl', c)
+ # cleanup current logrotate config files
+ logrotate_files = Path('/etc/logrotate.d/').glob('vyos-rsyslog-generated-*')
+ for file in logrotate_files:
+ file.unlink()
+
# eventually write for each file its own logrotate file, since size is
# defined it shouldn't matter
- conf = '/etc/logrotate.d/vyos-rsyslog'
- render(conf, 'syslog/logrotate.tmpl', c)
+ for filename, fileconfig in c.get('files', {}).items():
+ if fileconfig['log-file'].startswith('/var/log/user/'):
+ conf = '/etc/logrotate.d/vyos-rsyslog-generated-' + filename
+ render(conf, 'syslog/logrotate.tmpl', { 'config_render': fileconfig })
def verify(c):
diff --git a/src/etc/logrotate.d/vyos-rsyslog b/src/etc/logrotate.d/vyos-rsyslog
new file mode 100644
index 000000000..3c087b94e
--- /dev/null
+++ b/src/etc/logrotate.d/vyos-rsyslog
@@ -0,0 +1,12 @@
+/var/log/messages {
+ create
+ missingok
+ nomail
+ notifempty
+ rotate 10
+ size 1M
+ postrotate
+ # inform rsyslog service about rotation
+ /usr/lib/rsyslog/rsyslog-rotate
+ endscript
+}
diff --git a/src/helpers/system-versions-foot.py b/src/helpers/system-versions-foot.py
index b44408542..2aa687221 100755
--- a/src/helpers/system-versions-foot.py
+++ b/src/helpers/system-versions-foot.py
@@ -16,13 +16,24 @@
# along with this library. If not, see <http://www.gnu.org/licenses/>.
import sys
+import vyos.formatversions as formatversions
+import vyos.systemversions as systemversions
import vyos.defaults
-from vyos.component_version import write_footer
+import vyos.version
+
+sys_versions = systemversions.get_system_component_version()
+
+component_string = formatversions.format_versions_string(sys_versions)
+
+os_version_string = vyos.version.get_version()
sys.stdout.write("\n\n")
if vyos.defaults.cfg_vintage == 'vyos':
- write_footer(None, vintage='vyos')
+ formatversions.write_vyos_versions_foot(None, component_string,
+ os_version_string)
elif vyos.defaults.cfg_vintage == 'vyatta':
- write_footer(None, vintage='vyatta')
+ formatversions.write_vyatta_versions_foot(None, component_string,
+ os_version_string)
else:
- write_footer(None, vintage='vyatta')
+ formatversions.write_vyatta_versions_foot(None, component_string,
+ os_version_string)
diff --git a/src/helpers/vyos-save-config.py b/src/helpers/vyos-save-config.py
deleted file mode 100755
index 628d510dd..000000000
--- a/src/helpers/vyos-save-config.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (C) 2022 VyOS maintainers and contributors
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 or later as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-#
-import os
-import re
-import sys
-from tempfile import NamedTemporaryFile
-
-from vyos.config import Config
-from vyos.remote import urlc
-from vyos.component_version import system_footer
-
-DEFAULT_CONFIG_FILE = '/opt/vyatta/etc/config/config.boot'
-remote_save = None
-
-if len(sys.argv) > 1:
- save_file = sys.argv[1]
-else:
- save_file = DEFAULT_CONFIG_FILE
-
-if re.match(r'\w+:/', save_file):
- try:
- remote_save = urlc(save_file)
- except ValueError as e:
- sys.exit(e)
-
-config = Config()
-ct = config.get_config_tree(effective=True)
-
-write_file = save_file if remote_save is None else NamedTemporaryFile(delete=False).name
-with open(write_file, 'w') as f:
- f.write(ct.to_string())
- f.write("\n")
- f.write(system_footer())
-
-if remote_save is not None:
- try:
- remote_save.upload(write_file)
- finally:
- os.remove(write_file)