#!/usr/bin/ksh

#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
#

# To allow ipsectest to access the full run of STF infrastructure...
export STF_SUITE="/opt/net-tests"
export STF_TOOLS="/opt/test-runner/stf"
runner="/opt/test-runner/bin/run"

function fail
{
	echo $1
	exit ${2:-1}
}

function verify_id
{
	# For now, just force this to be run as root.  Eventually, the
	# appropriate IP configuration privileges should be enough.
	[[ $(id -u) != "0" ]] && fail "This script must be run as root."
}

##### END OF FUNCTIONS #####

verify_id

runfile='ipsec-peers.run'

while getopts qs c; do
	case $c in
	's')
		runfile='ipsec-self.run'
		;;
	'q')
		quiet='-q'
		;;
	esac
done
shift $((OPTIND - 1))

. $STF_SUITE/include/commands.kshlib
. $STF_SUITE/include/vars.kshlib

echo "RUNNING: $runner $quiet -c $STF_SUITE/runfiles/$runfile"
$runner $quiet -c $STF_SUITE/runfiles/$runfile

exit $?
