diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-06-19 16:12:27 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-06-19 16:12:27 +0200 |
commit | 587416ef606827c5cbf6ac49834fc65283794fbb (patch) | |
tree | eb600ee73115f881e2e332002d13f3727391cf48 | |
parent | a9daaa8409347ad9e51d75f76f5985b8e9f2e365 (diff) | |
download | vyos-1x-587416ef606827c5cbf6ac49834fc65283794fbb.tar.gz vyos-1x-587416ef606827c5cbf6ac49834fc65283794fbb.zip |
console-server: T2490: add SSH support for direct device access
-rwxr-xr-x | src/conf_mode/service_console-server.py | 17 | ||||
-rw-r--r-- | src/etc/systemd/system/conserver-server.service.d/override.conf | 3 | ||||
-rw-r--r-- | src/systemd/dropbear@.service | 6 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/conf_mode/service_console-server.py b/src/conf_mode/service_console-server.py index 087b13c04..7f6967983 100755 --- a/src/conf_mode/service_console-server.py +++ b/src/conf_mode/service_console-server.py @@ -62,13 +62,14 @@ def verify(proxy): if not proxy: return None - for tmp in proxy['device']: - device = proxy['device'][tmp] - if not device['speed']: + for device in proxy['device']: + keys = proxy['device'][device].keys() + if 'speed' not in keys: raise ConfigError(f'Serial port speed must be defined for "{tmp}"!') - if 'ssh' in device.keys(): - if 'port' not in device['ssh'].keys(): + if 'ssh' in keys: + ssh_keys = proxy['device'][device]['ssh'].keys() + if 'port' not in ssh_keys: raise ConfigError(f'SSH port must be defined for "{tmp}"!') return None @@ -81,8 +82,7 @@ def generate(proxy): return None def apply(proxy): - call('systemctl stop conserver-server.service') - call('systemctl stop dropbear@*.service') + call('systemctl stop dropbear@*.service conserver-server.service') if not proxy: if os.path.isfile(config_file): @@ -93,7 +93,8 @@ def apply(proxy): for device in proxy['device']: if 'ssh' in proxy['device'][device].keys(): - call('systemctl restart dropbear@{device}.service') + port = proxy['device'][device]['ssh']['port'] + call(f'systemctl restart dropbear@{device}.service') return None diff --git a/src/etc/systemd/system/conserver-server.service.d/override.conf b/src/etc/systemd/system/conserver-server.service.d/override.conf index 5301b38ce..828d0bc4b 100644 --- a/src/etc/systemd/system/conserver-server.service.d/override.conf +++ b/src/etc/systemd/system/conserver-server.service.d/override.conf @@ -1,9 +1,10 @@ [Unit] After= After=vyos-router.service +ConditionPathExists=/run/conserver/conserver.cf [Service] Type=simple ExecStart= ExecStart=/usr/sbin/conserver -C /run/conserver/conserver.cf - +Restart=on-failure diff --git a/src/systemd/dropbear@.service b/src/systemd/dropbear@.service index a7057ffe1..606a7ea6d 100644 --- a/src/systemd/dropbear@.service +++ b/src/systemd/dropbear@.service @@ -2,13 +2,13 @@ Description=Dropbear SSH per-connection server Requires=dropbearkey.service Wants=conserver-server.service -After=mongodb.service +ConditionPathExists=/run/conserver/conserver.cf After=dropbearkey.service vyos-router.service conserver-server.service [Service] Type=forking -ExecStartPre=/usr/bin/bash -c '/usr/bin/systemctl set-environment PORT=$(cli-shell-api returnValue service console-server device "%I" ssh port)' +ExecStartPre=/usr/bin/bash -c '/usr/bin/systemctl set-environment PORT=$(cli-shell-api returnActiveValue service console-server device "%I" ssh port)' ExecStart=-/usr/sbin/dropbear -w -j -k -r /etc/dropbear/dropbear_rsa_host_key -c "/usr/bin/console %I" -P /run/conserver/dropbear.%I.pid -p ${PORT} PIDFile=/run/conserver/dropbear.%I.pid KillMode=process - +Restart=on-failure |