summaryrefslogtreecommitdiff
path: root/src/conf_mode/system_login_banner.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-02-28 20:47:10 +0100
committerChristian Breunig <christian@breunig.cc>2024-02-28 20:47:10 +0100
commit0ea3a454cf560171d3eb9d4d1b97b172c06360fe (patch)
tree70641e8afef125dbb91a4eb086822fd0224755b0 /src/conf_mode/system_login_banner.py
parent6f7d1e15665655e37e8ca830e28d9650445c1217 (diff)
downloadvyos-1x-0ea3a454cf560171d3eb9d4d1b97b172c06360fe.tar.gz
vyos-1x-0ea3a454cf560171d3eb9d4d1b97b172c06360fe.zip
banner: T6077: implement ASCII contest winner default logo
Implement VyOS ASCII art contest winners logo as the default for our MOTD
Diffstat (limited to 'src/conf_mode/system_login_banner.py')
-rwxr-xr-xsrc/conf_mode/system_login_banner.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/conf_mode/system_login_banner.py b/src/conf_mode/system_login_banner.py
index 65fa04417..923e1bf57 100755
--- a/src/conf_mode/system_login_banner.py
+++ b/src/conf_mode/system_login_banner.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020-2021 VyOS maintainers and contributors
+# Copyright (C) 2020-2024 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
@@ -18,30 +18,26 @@ from sys import exit
from copy import deepcopy
from vyos.config import Config
+from vyos.template import render
from vyos.utils.file import write_file
+from vyos.version import get_version_data
from vyos import ConfigError
from vyos import airbag
airbag.enable()
-try:
- with open('/usr/share/vyos/default_motd') as f:
- motd = f.read()
-except:
- # Use an empty banner if the default banner file cannot be read
- motd = "\n"
-
PRELOGIN_FILE = r'/etc/issue'
PRELOGIN_NET_FILE = r'/etc/issue.net'
POSTLOGIN_FILE = r'/etc/motd'
default_config_data = {
'issue': 'Welcome to VyOS - \\n \\l\n\n',
- 'issue_net': '',
- 'motd': motd
+ 'issue_net': ''
}
def get_config(config=None):
banner = deepcopy(default_config_data)
+ banner['version_data'] = get_version_data()
+
if config:
conf = config
else:
@@ -92,7 +88,11 @@ def generate(banner):
def apply(banner):
write_file(PRELOGIN_FILE, banner['issue'])
write_file(PRELOGIN_NET_FILE, banner['issue_net'])
- write_file(POSTLOGIN_FILE, banner['motd'])
+ if 'motd' in banner:
+ write_file(POSTLOGIN_FILE, banner['motd'])
+ else:
+ render(POSTLOGIN_FILE, 'login/default_motd.j2', banner,
+ permission=0o644, user='root', group='root')
return None