summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/conf_mode/service_console-server.py17
-rw-r--r--src/etc/systemd/system/conserver-server.service.d/override.conf3
-rw-r--r--src/systemd/dropbear@.service6
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