#!/bin/sh # $FreeBSD: head/devel/zookeeper/files/zookeeper.in 552569 2020-10-17 13:20:21Z rhurlin $ # # PROVIDE: zookeeper # REQUIRE: NETWORKING SERVERS DAEMON # KEYWORD: shutdown # # Add the following line to /etc/rc.conf to enable zookeeper: # # zookeeper_enable="YES" . /etc/rc.subr name=zookeeper rcvar=zookeeper_enable load_rc_config "${name}" : ${zookeeper_enable:="NO"} : ${zookeeper_user:="%%ZOOKEEPER_USER%%"} : ${zookeeper_group:="%%ZOOKEEPER_GROUP%%"} : ${zookeeper_config:="%%ETCDIR%%/zoo.cfg"} : ${zookeeper_log4j_config:="%%ETCDIR%%/log4j.properties"} : ${zookeeper_rootlogger:="INFO,ROLLINGFILE"} : ${zookeeper_logdir:="%%ZOOKEEPER_LOGDIR%%"} : ${zookeeper_syslog_output_enable:="YES"} start_precmd="zookeeper_start_precmd" # backwards compatibility if [ -n "${zookeeper_jvmopts}" ]; then zookeeper_java_opts=${zookeeper_jvmopts} fi if [ -n "${zookeeper_log4jpropfile}" ]; then zookeeper_log4j_config="${zookeeper_log4jpropfile#file:}" fi if checkyesno zookeeper_syslog_output_enable; then if [ -n "${zookeeper_syslog_output_tag}" ]; then zookeeper_syslog_output_flags="-T ${zookeeper_syslog_output_tag}" else zookeeper_syslog_output_flags="-T ${name}" fi if [ -n "${zookeeper_syslog_output_priority}" ]; then zookeeper_syslog_output_flags="${zookeeper_syslog_output_flags} -s ${zookeeper_syslog_output_priority}" fi if [ -n "${zookeeper_syslog_output_facility}" ]; then zookeeper_syslog_output_flags="${zookeeper_syslog_output_flags} -l ${zookeeper_syslog_output_facility}" fi fi JAVA="%%JAVA%%" CLASSPATH=":%%DATADIR%%/*" log4j_params="-Dzookeeper.root.logger=${zookeeper_rootlogger} -Dzookeeper.log.dir=${zookeeper_logdir} -Dlog4j.configuration=file:${zookeeper_log4j_config}" zookeeper_main="${zookeeper_java_opts} ${log4j_params} -cp ${CLASSPATH} org.apache.zookeeper.server.quorum.QuorumPeerMain ${zookeeper_config}" pidfile="/var/run/${name}.pid" required_dirs="${zookeeper_logdir}" required_files="${zookeeper_config} ${zookeeper_log4j_config}" command="/usr/sbin/daemon" command_args="-f ${zookeeper_syslog_output_flags} -P ${pidfile} -t ${name} ${JAVA} ${zookeeper_main}" zookeeper_start_precmd() { if [ ! -e "${pidfile}" ]; then install -m 0600 -o "${zookeeper_user}" -g "${zookeeper_group}" /dev/null "${pidfile}" fi } run_rc_command "$1"