diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-01-12 23:10:17 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-12 23:10:17 +0700 |
commit | 1d6006dccca4bcb341789be990e2b01b8eae94e4 (patch) | |
tree | b0b829f2652102560fb4b5fc4da1ffeda88d724e | |
parent | 9ffb9f5902d7c30e8f37e782268c3ed57b95f72d (diff) | |
parent | bd55a85af79d6e16b511f2f07b87582fb5dd3ced (diff) | |
download | vyatta-op-vpn-1d6006dccca4bcb341789be990e2b01b8eae94e4.tar.gz vyatta-op-vpn-1d6006dccca4bcb341789be990e2b01b8eae94e4.zip |
Merge pull request #32 from sever-sever/T4168
op-vpn: T4168: Add timeout for restart vpn with nhrp
-rwxr-xr-x | scripts/vyatta-vpn-op.pl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/vyatta-vpn-op.pl b/scripts/vyatta-vpn-op.pl index 3be7fd8..b48bbb5 100755 --- a/scripts/vyatta-vpn-op.pl +++ b/scripts/vyatta-vpn-op.pl @@ -65,6 +65,18 @@ if ($op eq 'clear-vpn-ipsec-process') { # Check if nhrp configuration exists, exit code # As 'restart vpn' doesn't load nhrp configuration T3846 if (system('cli-shell-api existsActive protocols nhrp') == 0) { + # Set a small timeout for waiting for charon will be loaded + # 0 => process not found, 1 => process found + my $timeout = 7; + if (system("pgrep charon | wc -l" eq 0)) { + while ($timeout >= 1){ + sleep(1); + if (system("pgrep charon | wc -l" eq 1)){ + last; + } + $timeout--; + } + } system 'sudo swanctl --load-all'; } } else { |