#!/sbin/openrc-run # Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 configfile="${configfile:-/etc/h2o/h2o.conf}" extra_commands="configtest" extra_started_commands="reload" description="An optimized HTTP/1.x, HTTP/2 server" description_configtest="Run H2O' internal config check" description_reload="Reload the H2O configuration or upgrade the binary without losing connections" name="H2O" command="/usr/bin/h2o" command_args="-c \"${configfile}\"" command_args_background="-m daemon" pidfile="$(grep pid-file "${configfile}" | cut -d ' ' -f2)" required_files="${configfile}" depend() { use net after logger } start_pre() { if [ "${RC_CMD}" != "restart" ]; then configtest || return 1 fi } stop_pre() { if [ "${RC_CMD}" = "restart" ]; then configtest || return 1 fi } reload() { configtest || return 1 ebegin "Refreshing ${name} configuration" start-stop-daemon --signal HUP --pidfile "${pidfile}" eend $? "Failed to reload ${name}" } configtest() { ebegin "Checking ${name} configuration" if ! ${command} -c "${configfile}" -t >/dev/null 2>&1; then ${command} -c "${configfile}" -t fi eend $? "Failed, please correct the errors above" }