RPM: idzebra-2.0 includes init.d script
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 18 Mar 2013 10:30:04 +0000 (11:30 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 18 Mar 2013 10:31:07 +0000 (11:31 +0100)
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.

Makefile.am
idzebra.spec
rpm/zebrasrv.init [new file with mode: 0755]
rpm/zebrasrv.logrotate [new file with mode: 0644]

index 972e98b..2150f38 100644 (file)
@@ -23,6 +23,8 @@ dist-hook:
                        cp $$i $(distdir)/win; \
                fi; \
        done
+       mkdir $(distdir)/rpm
+       -cp $(srcdir)/rpm/* $(distdir)/rpm
 
 dox:
        doxygen
index 343baea..be7089b 100644 (file)
@@ -2,7 +2,7 @@
 Name: idzebra
 %define namev idzebra-2.0
 Version: %{idmetaversion}
-Release: 1indexdata
+Release: 2indexdata
 License: GPL
 Vendor: Index Data ApS <info@indexdata.dk>
 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 (executable)
index 0000000..c8c50eb
--- /dev/null
@@ -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 (file)
index 0000000..d005fbf
--- /dev/null
@@ -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
+}