[svn] r9771 - in /trunk/rpms/unfs3: unfs3.spec unfsd.init

Yury V. Zaytsev yury at shurup.com
Tue Mar 22 20:23:57 CET 2011


Author: yury
Date: Tue Mar 22 19:23:57 2011
New Revision: 9771

URL: http://svn.rpmforge.net/viewvc/rpmforge?rev=9771&view=rev
Log:
Init script


Added:
    trunk/rpms/unfs3/unfsd.init
Modified:
    trunk/rpms/unfs3/unfs3.spec

Modified: trunk/rpms/unfs3/unfs3.spec
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/rpms/unfs3/unfs3.spec?rev=9771&r1=9770&r2=9771&view=diff
==============================================================================
--- trunk/rpms/unfs3/unfs3.spec (original)
+++ trunk/rpms/unfs3/unfs3.spec Tue Mar 22 19:23:57 2011
@@ -1,20 +1,22 @@
 # $Id$
 # Authority: dag
-
-### FIXME: This package needs a sysv script
 
 Summary: UNFS3 user-space NFSv3 server
 Name: unfs3
 Version: 0.9.22
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: BSD
 Group: Applications/System
 URL: http://unfs3.sourceforge.net/
 
-Source: http://dl.sf.net/unfs3/unfs3-%{version}.tar.gz
+Source0: http://dl.sf.net/unfs3/unfs3-%{version}.tar.gz
+Source1: unfsd.init
+
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
-BuildRequires: byacc, bison, flex
+BuildRequires: byacc
+BuildRequires: bison
+BuildRequires: flex
 
 %description
 UNFS3 is a user-space implementation of the NFS (Network File System)
@@ -33,17 +35,39 @@
 %{__rm} -rf %{buildroot}
 %{__make} install DESTDIR="%{buildroot}"
 
+%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/unfsd
+
 %clean
 %{__rm} -rf %{buildroot}
+
+%post
+if [ $1 -eq 1 ]; then
+    /sbin/chkconfig --add unfsd
+fi
+
+%preun
+if [ $1 -eq 0 ]; then
+    /sbin/service unfsd stop &>/dev/null || :
+    /sbin/chkconfig --del unfsd
+fi
+
+%postun
+if [ $1 -ge 1 ]; then
+    /sbin/service unfsd condrestart &>/dev/null || :
+fi
 
 %files
 %defattr(-, root, root, 0755)
 %doc CREDITS LICENSE NEWS README contrib/ doc/
 %doc %{_mandir}/man7/tags.7*
 %doc %{_mandir}/man8/unfsd.8*
+%{_initrddir}/unfsd
 %{_sbindir}/unfsd
 
 %changelog
+* Tue Mar 22 2011 Yury V. Zaytsev <yury at shurup.com> - 0.9.22-2
+- Added an init script (thanks to Chris Butler!)
+
 * Tue Jan 06 2009 Dag Wieers <dag at wieers.com> - 0.9.22-1
 - Updated to release 0.9.22.
 

Added: trunk/rpms/unfs3/unfsd.init
URL: http://svn.rpmforge.net/viewvc/rpmforge/trunk/rpms/unfs3/unfsd.init?rev=9771&view=markup
==============================================================================
--- trunk/rpms/unfs3/unfsd.init (added)
+++ trunk/rpms/unfs3/unfsd.init Tue Mar 22 19:23:57 2011
@@ -1,0 +1,72 @@
+#!/bin/bash
+# -*- mode: shell-script; coding: UTF-8 -*-
+#
+# chkconfig: - 85 15
+# description: Start or stop the unfs3 server
+#
+# processname:  unfsd
+# pidfile:      /var/run/unfsd.pid
+#
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ "$NETWORKING" = "no" ] && exit 0
+
+description="unfs3 NFS server"
+
+lockfile="/var/lock/subsys/unfsd"
+pidfile="/var/run/unfsd.pid"
+
+case "$1" in
+    start)
+        echo "Starting" ${description}
+        /usr/sbin/unfsd -i ${pidfile}
+        RETVAL=$?
+        if [ "${RETVAL}" = "0" ]; then
+            touch ${lockfile} >/dev/null 2>&1
+        fi
+        ;;
+    stop)
+        echo "Shutting down" ${description}
+        if [ -s ${pidfile} ]; then
+            pid=`cat ${pidfile}`
+            kill -TERM ${pid} 2>/dev/null
+            sleep 2
+            if kill -0 ${pid} 2>/dev/null; then
+                kill -KILL ${pid}
+            fi
+        fi
+        rm -f ${lockfile} ${pidfile}
+        ;;
+    status)
+        if [ -s ${pidfile} ]; then
+                pid=`cat ${pidfile}`
+                if kill -0 ${pid} 2>/dev/null; then
+                    echo "${description} (pid ${pid}) is running"
+                    RETVAL=0
+                else
+                    echo "${description} is stopped"
+                    RETVAL=1
+                fi
+        else
+            echo "${description} is stopped"
+            RETVAL=1
+        fi
+        ;;
+    restart)
+        /etc/init.d/unfsd stop && /etc/init.d/unfsd start
+        RETVAL=$?
+        ;;
+    condrestart)
+        [ -f /var/lock/subsys/unfsd ] && /etc/init.d/unfsd stop && /etc/init.d/unfsd start
+        RETVAL=$?
+        ;;
+    *)
+        echo "Usage: $0 {start|stop|restart|condrestart|status}"
+        RETVAL=1
+        ;;
+esac
+
+exit $RETVAL




More information about the commits mailing list