#!/bin/sh
###############################################################################
#                                                                             #
# IPFire.org - A linux based firewall                                         #
# Copyright (C) 2007-2025  IPFire Team  <info@ipfire.org>                     #
#                                                                             #
# This program is free software: you can redistribute it and/or modify        #
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation, either version 3 of the License, or           #
# (at your option) any later version.                                         #
#                                                                             #
# This program is distributed in the hope that it will be useful,             #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
#                                                                             #
###############################################################################

. /etc/sysconfig/rc
. ${rc_functions}

ARGS=(
	# Load the configuration file
	--configuration-file /etc/fort/config.json

	# Log to syslog
	--log.output=syslog
	--validation-log.output=syslog

	# Read TALs
	--tal /usr/share/fort/tals

	# Configure a cache directory
	--local-repository /var/cache/fort

	# Run as daemon
	--daemon

	# Listen on localhost
	--server.address 127.0.0.1
	--server.port 3323
)

case "${1}" in
	start)
		boot_mesg "Starting fort RPKI validator..."
		loadproc /usr/bin/fort "${ARGS[@]}"
		;;

	stop)
		boot_mesg "Stopping fort RPKI validator..."
		killproc /usr/bin/fort
		;;

	reload)
		boot_mesg "Reloading fort RPKI validator..."
		reloadproc /usr/bin/fort
		;;

	restart)
		${0} stop
		sleep 1
		${0} start
		;;

	status)
		statusproc /usr/bin/fort
		;;

	*)
		echo "Usage: ${0} {start|stop|reload|restart|status}"
		exit 1
		;;
esac
