#!/bin/bash TRY=30 if svc -u /service/ipsec 2>&1 | grep supervise ; then exit 0 fi while ! ipsec whack --status 2>/dev/null|grep "^000 interface" &>/dev/null; do echo "Waiting for ipsec to start.. ($TRY)" sleep 1 (( TRY-- )) if [ $TRY -eq 0 ]; then echo "Timeout while waiting for ipsec to start" exit 1 fi done