mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-05 00:00:45 -04:00
This script can be used in pretest.dat files to wait until an IPsec connection becomes available. This avoids unconditional sleeps and improves test performance. The ipv6 tests have been updated to use the expect-connection script.
28 lines
481 B
Bash
Executable File
28 lines
481 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Wait until a given IPsec connection becomes available
|
|
#
|
|
# Params:
|
|
# $1 - connection name
|
|
# $2 - maximum time to wait in seconds, default is 5 seconds
|
|
|
|
if [[ $# -lt 1 || $# -gt 2 ]]
|
|
then
|
|
echo "invalid arguments"
|
|
exit 1
|
|
fi
|
|
|
|
secs=$2
|
|
[ ! $secs ] && secs=5
|
|
|
|
let steps=$secs*10
|
|
for i in `seq 1 $steps`
|
|
do
|
|
ipsec statusall 2>&1 | grep ^[[:space:]]*$1: >/dev/null
|
|
[ $? -eq 0 ] && exit 0
|
|
sleep 0.1
|
|
done
|
|
|
|
echo "Connection '$1' not available after $secs second(s)"
|
|
exit 1
|