From: Adam Dickmeiss Date: Mon, 18 Mar 2013 10:30:04 +0000 (+0100) Subject: RPM: idzebra-2.0 includes init.d script X-Git-Tag: v2.0.55~19 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=2d547427d07a921c603e9984f59135377f8b4680 RPM: idzebra-2.0 includes init.d script Also includes logrotate. The zebrasrv init script listens on port 2100 (IPv4 + IPv6). At this time, zebra.cfg, is not part of the package. Administrator must install or modify $CONFIG to point to a working zebra.cfg. --- diff --git a/Makefile.am b/Makefile.am index 972e98b..2150f38 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,6 +23,8 @@ dist-hook: cp $$i $(distdir)/win; \ fi; \ done + mkdir $(distdir)/rpm + -cp $(srcdir)/rpm/* $(distdir)/rpm dox: doxygen diff --git a/idzebra.spec b/idzebra.spec index 343baea..be7089b 100644 --- a/idzebra.spec +++ b/idzebra.spec @@ -2,7 +2,7 @@ Name: idzebra %define namev idzebra-2.0 Version: %{idmetaversion} -Release: 1indexdata +Release: 2indexdata License: GPL Vendor: Index Data ApS Source: idzebra-%{version}.tar.gz @@ -36,8 +36,6 @@ Group: Libraries Requires: libyaz4 bzip2-libs %description -n lib%{namev} Libraries for the Zebra search engine. -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig %package -n lib%{namev}-modules Summary: Zebra modules @@ -73,6 +71,11 @@ rm ${RPM_BUILD_ROOT}/%{_mandir}/man1/zebraidx.* rm ${RPM_BUILD_ROOT}/%{_bindir}/zebrasrv rm ${RPM_BUILD_ROOT}/%{_mandir}/man8/zebrasrv.* rm ${RPM_BUILD_ROOT}/%{_mandir}/man1/idzebra-config.* +mkdir -p ${RPM_BUILD_ROOT}/etc/idzebra +mkdir -p ${RPM_BUILD_ROOT}/etc/rc.d/init.d +install -m755 rpm/zebrasrv.init ${RPM_BUILD_ROOT}/etc/rc.d/init.d/zebrasrv +mkdir -p ${RPM_BUILD_ROOT}/etc/logrotate.d +install -m644 rpm/zebrasrv.logrotate ${RPM_BUILD_ROOT}/etc/logrotate.d/zebrasrv %clean rm -fr ${RPM_BUILD_ROOT} @@ -89,6 +92,9 @@ rm -fr ${RPM_BUILD_ROOT} %{_mandir}/*/zebrasrv-* %{_mandir}/*/idzebra-abs2dom* /usr/share/idzebra-2.0-examples +%dir %{_sysconfdir}/idzebra +%config %{_sysconfdir}/rc.d/init.d/zebrasrv +%config(noreplace) /etc/logrotate.d/zebrasrv %files -n lib%{namev} %{_libdir}/*.so.* @@ -104,3 +110,20 @@ rm -fr ${RPM_BUILD_ROOT} %{_mandir}/*/idzebra-config-* /usr/share/aclocal/*.m4 +%post -n lib%{namev} +/sbin/ldconfig +%postun -n lib%{namev} +/sbin/ldconfig +%post -n %{namev} +if [ $1 = 1 ]; then + /sbin/chkconfig --add zebrasrv + /sbin/service zebrasrv start > /dev/null 2>&1 +else + /sbin/service zebrasrv restart > /dev/null 2>&1 +fi +%preun -n %{namev} +if [ $1 = 0 ]; then + /sbin/service zebrasrv stop > /dev/null 2>&1 + /sbin/chkconfig --del zebrasrv +fi + diff --git a/rpm/zebrasrv.init b/rpm/zebrasrv.init new file mode 100755 index 0000000..c8c50eb --- /dev/null +++ b/rpm/zebrasrv.init @@ -0,0 +1,82 @@ +#!/bin/bash +# +# zebrasrv Startup script for zebrasrv +# +# chkconfig: 2345 85 15 +# description: Index Data Zebra server +# processname: zebrasrv-2.0 +# config: /etc/idzebra/zebra.cfg +# config: /etc/sysconfig/zebrasrv +# pidfile: /var/run/zebrasrv.pid + +. /etc/rc.d/init.d/functions + +OPTIONS="-l /var/log/zebrasrv.log -u nobody tcp:@6:2100 tcp:@:2100" + +if [ -f /etc/sysconfig/zebrasrv ]; then + . /etc/sysconfig/zebrasrv +fi +CONFIG=${CONFIG-/etc/idzebra/zebra.cfg} +DAEMON=${DAEMON-/usr/bin/zebrasrv-2.0} +prog=zebrasrv +pidfile=${PIDFILE-/var/run/zebrasrv.pid} +lockfile=${LOCKFILE-/var/lock/subsys/zebrasrv} +RETVAL=0 + +if [ ! -f $CONFIG ]; then + echo "$prog: No $CONFIG" + exit 0 +fi + +start() { + echo -n $"Starting $prog: " + daemon --pidfile=${pidfile} $DAEMON $OPTIONS -D -c $CONFIG -p ${pidfile} + RETVAL=$? + echo + [ $RETVAL = 0 ] && touch ${lockfile} + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p ${pidfile} -d 10 $DAEMON + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} +} +reload() { + stop + start +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status -p ${pidfile} $DAEMON + RETVAL=$? + ;; + restart) + stop + start + ;; + condrestart) + if [ -f ${pidfile} ] ; then + stop + start + fi + ;; + reload) + reload + ;; + *) + echo $"Usage: $prog {start|stop|restart|help}" + exit 1 +esac + +exit $RETVAL diff --git a/rpm/zebrasrv.logrotate b/rpm/zebrasrv.logrotate new file mode 100644 index 0000000..d005fbf --- /dev/null +++ b/rpm/zebrasrv.logrotate @@ -0,0 +1,13 @@ +/var/log/zebrasrv.log { + weekly + missingok + rotate 4 + compress + delaycompress + notifempty + postrotate + if [ -f /var/run/zebrasrv.pid ]; then + /sbin/service zebrasrv restart > /dev/null + fi + endscript +}