| 123456789101112131415161718192021222324252627282930313233 | #!/bin/bash## Wait until a given IPsec connection becomes available## Params:# $1 - connection name# $2 - maximum time to wait in seconds, default is 5 secondsif [[ $# -lt 1 || $# -gt 2 ]]then	echo "invalid arguments"	exit 1fisecs=$2[ ! $secs ] && secs=5cmd="swanctl --list-conns"grep 'load.*stroke' /etc/strongswan.conf >/dev/nullif [ $? -eq 0 -o -n "$DAEMON_NAME" ]; then	cmd="ipsec statusall"filet steps=$secs*10for i in `seq 1 $steps`do	$cmd 2>&1 | grep ^[[:space:]]*$1: >/dev/null	[ $? -eq 0 ] && exit 0	sleep 0.1doneecho "Connection '$1' not available after $secs second(s)"exit 1
 |