[svn] r9769 - in /trunk/rpms/lsyncd: lsyncd.init lsyncd.spec lsyncd.sysconfig

Yury V. Zaytsev yury at shurup.com
Tue Mar 22 19:56:29 CET 2011


Author: yury
Date: Tue Mar 22 18:56:29 2011
New Revision: 9769

URL: http://svn.rpmforge.net/viewvc/rpmforge?rev=9769&view=rev
Log:
Added an init script for lsyncd


Added:
    trunk/rpms/lsyncd/lsyncd.init
    trunk/rpms/lsyncd/lsyncd.sysconfig
Modified:
    trunk/rpms/lsyncd/lsyncd.spec

Added: trunk/rpms/lsyncd/lsyncd.init
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/rpms/lsyncd/lsyncd.init?rev=9769&view=markup
==============================================================================
--- trunk/rpms/lsyncd/lsyncd.init (added)
+++ trunk/rpms/lsyncd/lsyncd.init Tue Mar 22 18:56:29 2011
@@ -1,0 +1,102 @@
+#!/bin/bash
+#
+# chkconfig: - 85 15
+# description: Lightweight inotify based sync daemon
+#
+# processname:  lsyncd
+# config:       /etc/lsyncd.conf
+# config:       /etc/sysconfig/lsyncd
+# pidfile:      /var/run/lsyncd.pid
+
+# Source function library
+. /etc/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ "$NETWORKING" = "no" ] && exit 0
+
+OPTIONS="-pidfile /var/run/lsyncd.pid /etc/lsyncd.conf"
+
+if [ -e /etc/sysconfig/lsyncd.options ]; then
+  . /etc/sysconfig/lsyncd.options
+fi
+
+RETVAL=0
+
+prog="lsyncd"
+thelock=/var/lock/subsys/lsyncd
+
+start() {
+        echo -n $"Starting $prog: "
+        if [ $UID -ne 0 ]; then
+                RETVAL=1
+                failure
+        else
+                daemon /usr/bin/lsyncd $OPTIONS
+                RETVAL=$?
+                [ $RETVAL -eq 0 ] && touch $thelock
+        fi;
+        echo
+        return $RETVAL
+}
+
+stop() {
+        echo -n $"Stopping $prog: "
+        if [ $UID -ne 0 ]; then
+                RETVAL=1
+                failure
+        else
+                killproc /usr/bin/lsyncd
+                RETVAL=$?
+                [ $RETVAL -eq 0 ] && rm -f $thelock
+        fi;
+        echo
+        return $RETVAL
+}
+
+reload(){
+        echo -n $"Reloading $prog: "
+        killproc /usr/bin/lsyncd -HUP
+        RETVAL=$?
+        echo
+        return $RETVAL
+}
+
+restart(){
+        stop
+        start
+}
+
+condrestart(){
+    [ -e $thelock ] && restart
+    return 0
+}
+
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  restart)
+        restart
+        ;;
+  reload)
+        reload
+        ;;
+  condrestart)
+        condrestart
+        ;;
+  status)
+        status lsyncd
+        RETVAL=$?
+        ;;
+  *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+        RETVAL=1
+esac
+
+exit $RETVAL

Modified: trunk/rpms/lsyncd/lsyncd.spec
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/rpms/lsyncd/lsyncd.spec?rev=9769&r1=9768&r2=9769&view=diff
==============================================================================
--- trunk/rpms/lsyncd/lsyncd.spec (original)
+++ trunk/rpms/lsyncd/lsyncd.spec Tue Mar 22 18:56:29 2011
@@ -5,16 +5,21 @@
 Summary: Live syncing (mirroring) daemon
 Name: lsyncd
 Version: 2.0.2
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPL
 Group: Applications/File
 URL: http://code.google.com/p/lsyncd/
 
-Source: http://lsyncd.googlecode.com/files/lsyncd-%{version}.tar.gz
+Source0: http://lsyncd.googlecode.com/files/lsyncd-%{version}.tar.gz
+Source1: %{name}.init
+Source2: %{name}.sysconfig
+
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 BuildRequires: lua-devel
 
+Requires: /sbin/chkconfig
+Requires: /sbin/service
 Requires: lua
 Requires: rsync
 
@@ -40,8 +45,27 @@
 %{__rm} -rf %{buildroot}
 %{__make} install DESTDIR="%{buildroot}"
 
+%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
+%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
+
 %clean
 %{__rm} -rf %{buildroot}
+
+%post
+if [ $1 -eq 1 ]; then
+    /sbin/chkconfig --add %{name}
+fi
+
+%preun
+if [ $1 -eq 0 ]; then
+    /sbin/service %{name} stop &>/dev/null || :
+    /sbin/chkconfig --del %{name}
+fi
+
+%postun
+if [ $1 -ge 1 ]; then
+    /sbin/service %{name} condrestart &>/dev/null || :
+fi
 
 %files
 %defattr(-, root, root, 0755)
@@ -49,8 +73,13 @@
 %doc %{_defaultdocdir}/lsyncd/
 %doc %{_mandir}/man1/lsyncd.1.gz
 %{_bindir}/lsyncd
+%{_initrddir}/%{name}
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
 
 %changelog
+* Tue Mar 22 2011 Yury V. Zaytsev <yury at shurup.com> - 2.0.2-2
+- Added an init script (thanks to Aleksandar Ivanisevic!)
+
 * Tue Feb 22 2011 Yury V. Zaytsev <yury at shurup.com> - 2.0.2-1
 - Updated to release 2.0.2 (thanks to Aleksandar Ivanisevic!)
 

Added: trunk/rpms/lsyncd/lsyncd.sysconfig
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/rpms/lsyncd/lsyncd.sysconfig?rev=9769&view=markup
==============================================================================
--- trunk/rpms/lsyncd/lsyncd.sysconfig (added)
+++ trunk/rpms/lsyncd/lsyncd.sysconfig Tue Mar 22 18:56:29 2011
@@ -1,0 +1,3 @@
+# Put your lsyncd options here
+
+#OPTIONS="-pidfile /var/run/lsyncd.pid /etc/lsyncd.conf"




More information about the commits mailing list