#!/sbin/openrc-run

: ${command_user:="nobody"}
: ${cfgfile:="/etc/git-mirror-syncd/config.lua"}
: ${logfile:="/var/log/$RC_SVCNAME.log"}
: ${cachedir:="/var/tmp/git-mirror-syncd"}

command="/usr/bin/git-mirror-syncd"
command_background="yes"

start_stop_daemon_args="
	--interpreted
	--user $command_user
	--env CONFIG=$cfgfile
	--env CACHE_DIR=$cachedir
	--stdout=$logfile
	--stderr=$logfile"
pidfile="/run/$RC_SVCNAME.pid"

required_files="$cfgfile"

depend() {
	need net
}

start_pre() {
	checkpath -f -o "$command_user" "$logfile" || return 1

	if [ "$cachedir" ]; then
		checkpath -d -m 750 -o "$command_user" "$cachedir"
	fi
}
