#!/usr/bin/openrc-run

LIO_CONFIG=${LIO_CONFIG-"/opt/etc/target/saveconfig.json"}

description="Loading and saving iSCSI LIO target configuration"

. /opt/etc/functions.openrc

depend()
{
	need localmount
	use srp
	after srp
	provide ${SVCNAME}
}

start()
{
	ebegin "Starting \"${SVCNAME}\""
	/usr/bin/targetctl restore ${LIO_CONFIG}
	eend $?
	return $?
}

stop()
{
	ebegin "Stopping service \"${SVCNAME}\""
	/usr/bin/targetctl save ${LIO_CONFIG}
	/usr/bin/targetctl clear
	eend 0
	return 0
}
