null+****@clear*****
null+****@clear*****
2010年 9月 3日 (金) 10:28:40 JST
Kouhei Sutou 2010-09-03 01:28:40 +0000 (Fri, 03 Sep 2010) New Revision: 05e5ab8fe9bbd62076def9cfeeb1f1517af2268c Log: add init script for RedHat. Added files: data/init.d/Makefile.am data/init.d/redhat/Makefile.am data/init.d/redhat/groonga data/init.d/redhat/sysconfig/Makefile.am data/init.d/redhat/sysconfig/groonga Modified files: configure.ac data/Makefile.am Modified: configure.ac (+3 -0) =================================================================== --- configure.ac 2010-09-03 01:13:22 +0000 (9034263) +++ configure.ac 2010-09-03 01:28:40 +0000 (1b0054a) @@ -100,6 +100,9 @@ AC_CONFIG_FILES([Makefile yum/Makefile data/Makefile data/munin/Makefile + data/init.d/Makefile + data/init.d/redhat/Makefile + data/init.d/redhat/sysconfig/Makefile resource/Makefile doc/Makefile doc/ja/Makefile Modified: data/Makefile.am (+2 -1) =================================================================== --- data/Makefile.am 2010-09-03 01:13:22 +0000 (d7fa449) +++ data/Makefile.am 2010-09-03 01:28:40 +0000 (f22d86d) @@ -1,5 +1,6 @@ SUBDIRS = \ - munin + munin \ + init.d pkgsysconfdir = $(sysconfdir)/$(PACKAGE) dist_pkgsysconf_DATA = \ Added: data/init.d/Makefile.am (+1 -0) 100644 =================================================================== --- /dev/null +++ data/init.d/Makefile.am 2010-09-03 01:28:40 +0000 (5a641a9) @@ -0,0 +1 @@ +SUBDIRS = redhat Added: data/init.d/redhat/Makefile.am (+5 -0) 100644 =================================================================== --- /dev/null +++ data/init.d/redhat/Makefile.am 2010-09-03 01:28:40 +0000 (8aac9d1) @@ -0,0 +1,5 @@ +SUBDIRS = sysconfig + +initdir = $(sysconfdir)/init.d/redhat +dist_init_SCRIPTS = \ + groonga Added: data/init.d/redhat/groonga (+140 -0) 100755 =================================================================== --- /dev/null +++ data/init.d/redhat/groonga 2010-09-03 01:28:40 +0000 (1cccb49) @@ -0,0 +1,140 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/groonga +# +# chkconfig: 2345 80 20 +# description: A full-text search engine and column store. +# processname: groonga +# config: /etc/sysconfig/groonga +# pidfile: /var/run/groonga/groonga.pid +# +### BEGIN INIT INFO +# Provides: groonga +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: groonga's init script +# Description: groonga is a full-text search engine and column store. +### END INIT INFO + +# Source function library. +. /etc/init.d/functions + +name="groonga" +prog="groonga" +groonga=/usr/bin/$prog +USER=groonga +GROUP=groonga +DATABASE=/var/lib/groonga/db/db +ADDRESS=127.0.0.1 +PIDFILE=/var/run/groonga/$prog.pid +PROTOCOL= +LOG_PATH= +QUERY_LOG_PATH= +OPTION_ARGS="" + +if [ -f /etc/sysconfig/$name ]; then + . /etc/sysconfig/$name +fi + +DAEMON_ARGS="-s" +if [ -n "${PIDFILE}" ]; then + DAEMON_ARGS="${DAEMON_ARGS} --pid-path ${PIDFILE}" +fi +if [ -n "${ADDRESS}" ]; then + DAEMON_ARGS="${DAEMON_ARGS} -a ${ADDRESS}" +fi +if [ -n "${LOG_PATH}" ]; then + DAEMON_ARGS="${DAEMON_ARGS} --log-path ${LOG_PATH}" +fi +if [ -n "${QUERY_LOG_PATH}" ]; then + DAEMON_ARGS="${DAEMON_ARGS} --query-log-path ${QUERY_LOG_PATH}" +fi +if [ -n "${PROTOCOL}" ]; then + DAEMON_ARGS="${DAEMON_ARGS} --protocol ${PROTOCOL}" +fi +if [ -n "${USER}" ]; then + if ! getent passwd | grep -q "^${USER}:"; then + echo "$0: user for running $prog doesn't exist: ${USER}" >&2 + exit 1 + fi + if [ -n "${PIDFILE}" ]; then + mkdir -p `dirname ${PIDFILE}` + chown -R ${USER} `dirname ${PIDFILE}` + fi + DAEMON_ARGS="${DAEMON_ARGS} --user-name ${USER}" +fi +if [ -n "${GROUP}" ]; then + if ! getent group | grep -q "^${GROUP}:"; then + echo "$0: group for running $prog doesn't exist: ${GROUP}" >&2 + exit 1 + fi + DAEMON_ARGS="${DAEMON_ARGS} --group-name ${GROUP}" +fi +DAEMON_ARGS="${DAEMON_ARGS} ${OPTION_ARGS}" + +if [ -z "${DATABASE}" ]; then + echo "$0: DATABASE should not be empty" >&2 + exit 1 +fi + +if [ -f "${DATABASE}" ]; then + DAEMON_ARGS="${DAEMON_ARGS} ${DATABASE}" +else + mkdir -p $(dirname ${DATABASE}) + if [ -n "${USER}" ]; then + chown -R ${USER} $(dirname ${DATABASE}) + fi + if [ -n "${GROUP}" ]; then + chgrp -R ${GROUP} $(dirname ${DATABASE}) + fi + DAEMON_ARGS="${DAEMON_ARGS} -n ${DATABASE}" +fi + +RETVAL=0 + + +start() { + echo -n "Starting $name: " + daemon $groonga "$DAEMON_ARGS" + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog + return $RETVAL +} + +stop() { + echo -n "Shutting down $name: " + killproc $prog + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog + return $RETVAL +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + reload) + killproc $groonga -HUP + ;; + condrestart) + [ -f /var/lock/subsys/$prog ] && restart || : + ;; + *) + echo "Usage: $prog {start|stop|reload|restart|condrestart}" + exit 1 + ;; +esac +exit $? Added: data/init.d/redhat/sysconfig/Makefile.am (+3 -0) 100644 =================================================================== --- /dev/null +++ data/init.d/redhat/sysconfig/Makefile.am 2010-09-03 01:28:40 +0000 (56bd972) @@ -0,0 +1,3 @@ +sysconfigdir = $(sysconfdir)/init.d/redhat/sysconfig +dist_sysconfig_DATA = \ + groonga Added: data/init.d/redhat/sysconfig/groonga (+8 -0) 100644 =================================================================== --- /dev/null +++ data/init.d/redhat/sysconfig/groonga 2010-09-03 01:28:40 +0000 (7e7ef93) @@ -0,0 +1,8 @@ +# Default +#USER=groonga +#GROUP=groonga +#ADDRESS=127.0.0.1 +#DATABASE=/var/lib/groonga/db/db +#LOG_PATH=/var/log/groonga/groonga.log +#QUERY_LOG_PATH=/var/log/groonga/query.log +#PROTOCOL=gqtp