summaryrefslogtreecommitdiff
path: root/src/conf_mode/service_console-server.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-02-21 17:24:57 +0100
committerChristian Poessinger <christian@poessinger.com>2021-02-21 17:26:17 +0100
commit65adcc1d80d06e0e76387de0b0c5c9d6c79d8f99 (patch)
tree3ed2b87760b9008ca3082fe85420bc5781c2927e /src/conf_mode/service_console-server.py
parent50b2882c663a1c308e9f71f6d0d52109a0170afd (diff)
downloadvyos-1x-65adcc1d80d06e0e76387de0b0c5c9d6c79d8f99.tar.gz
vyos-1x-65adcc1d80d06e0e76387de0b0c5c9d6c79d8f99.zip
console-server: T2490: do not use cli-shell-api in systemd unit
(cherry picked from commit d5804b19d3ffecdd4fe6bd89d50ac84dabb549fd)
Diffstat (limited to 'src/conf_mode/service_console-server.py')
-rwxr-xr-xsrc/conf_mode/service_console-server.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/conf_mode/service_console-server.py b/src/conf_mode/service_console-server.py
index 0e5fc75b0..6e94a19ae 100755
--- a/src/conf_mode/service_console-server.py
+++ b/src/conf_mode/service_console-server.py
@@ -25,7 +25,8 @@ from vyos.util import call
from vyos.xml import defaults
from vyos import ConfigError
-config_file = r'/run/conserver/conserver.cf'
+config_file = '/run/conserver/conserver.cf'
+dropbear_systemd_file = '/etc/systemd/system/dropbear@{port}.service.d/override.conf'
def get_config(config=None):
if config:
@@ -75,9 +76,22 @@ def generate(proxy):
return None
render(config_file, 'conserver/conserver.conf.tmpl', proxy)
+ if 'device' in proxy:
+ for device in proxy['device']:
+ if 'ssh' not in proxy['device'][device]:
+ continue
+
+ tmp = {
+ 'device' : device,
+ 'port' : proxy['device'][device]['ssh']['port'],
+ }
+ render(dropbear_systemd_file.format(**tmp),
+ 'conserver/dropbear@.service.tmpl', tmp)
+
return None
def apply(proxy):
+ call('systemctl daemon-reload')
call('systemctl stop dropbear@*.service conserver-server.service')
if not proxy:
@@ -89,9 +103,10 @@ def apply(proxy):
if 'device' in proxy:
for device in proxy['device']:
- if 'ssh' in proxy['device'][device]:
- port = proxy['device'][device]['ssh']['port']
- call(f'systemctl restart dropbear@{device}.service')
+ if 'ssh' not in proxy['device'][device]:
+ continue
+ port = proxy['device'][device]['ssh']['port']
+ call(f'systemctl restart dropbear@{port}.service')
return None