diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-07-06 15:32:42 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-07-07 16:28:59 +0000 |
commit | 28ba0ef32425ee458293a37a4a5ba664dfe577b2 (patch) | |
tree | 9e6847a82ca668e874a3ad3cd763370be1f8dab9 /src/op_mode/generate_ssh_server_key.py | |
parent | c548d1c7bac049c2a309bb3afac3694009a25b5f (diff) | |
download | vyos-1x-28ba0ef32425ee458293a37a4a5ba664dfe577b2.tar.gz vyos-1x-28ba0ef32425ee458293a37a4a5ba664dfe577b2.zip |
op-mode: T4503: Prevent restart service if commit in progress
Prevent op-mode scripts from restarting services if commit in
progress
Diffstat (limited to 'src/op_mode/generate_ssh_server_key.py')
-rwxr-xr-x | src/op_mode/generate_ssh_server_key.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/op_mode/generate_ssh_server_key.py b/src/op_mode/generate_ssh_server_key.py index cbc9ef973..43e94048d 100755 --- a/src/op_mode/generate_ssh_server_key.py +++ b/src/op_mode/generate_ssh_server_key.py @@ -17,10 +17,15 @@ from sys import exit from vyos.util import ask_yes_no from vyos.util import cmd +from vyos.util import commit_in_progress if not ask_yes_no('Do you really want to remove the existing SSH host keys?'): exit(0) +if commit_in_progress(): + print('Cannot restart SSH while a commit is in progress') + exit(1) + cmd('rm -v /etc/ssh/ssh_host_*') cmd('dpkg-reconfigure openssh-server') cmd('systemctl restart ssh.service') |