#!/sbin/openrc-run
#
# Open-RC init.d file for Kiwi IRC
# Copyright (c) 2016 - Francesco Colista (fcolista@alpinelinux.org)

description="Kiwi IRC Daemon"
command="/usr/bin/kiwi"
pidfile="/var/run/kiwiirc/kiwiirc.pid"

depend() {
	use net
	after firewall
}

start_pre() {
	checkpath -d -m 0755 -o kiwiirc:kiwiirc -q /run/kiwiirc
}

start() {
	if ! [ -f /var/lib/kiwiirc/index.html ]; then
		$command build
	fi
	$command start
	eend $?
}

stop() {
	$command stop
	eend $?
}

status() {
	$command status
	eend $?
}

build() {
	$command build
	eend $?
}
