#!/sbin/openrc-run

name="GitLab"
description="Meta script for starting/stopping all the GitLab components"

: ${mailroom_enabled:="no"}
: ${pages_enabled:="yes"}

subservices="gitlab.rails gitlab.gitaly gitlab.sidekiq gitlab.workhorse"
if yesno "$mailroom_enabled"; then
	subservices="$subservices gitlab.mailroom"
fi
if yesno "$pages_enabled" && [ -e /etc/init.d/gitlab.pages ]; then
	subservices="$subservices gitlab.pages"
fi

depend() {
	need redis postgresql
	use net
}

start() {
	local ret=0

	ebegin "Starting all GitLab components"
	local svc; for svc in $subservices; do
		service $svc start || ret=1
	done
	eend $ret
}

stop() {
	local ret=0

	ebegin "Stopping all GitLab components"
	local svc; for svc in $subservices; do
		service $svc stop || ret=1
	done
	eend $ret
}

status() {
	local ret=0

	local svc; for svc in $subservices; do
		echo "$svc:"
		service $svc status || ret=1
	done
	eend $ret
}
