rpms/flow-tools/devel flow-capture.init, NONE, 1.1 flow-capture.sysconfig, NONE, 1.1 flow-tools.spec, 1.18, 1.19

Paul P Komkoff Jr (stingray) fedora-extras-commits at redhat.com
Fri Sep 14 18:36:48 UTC 2007


Author: stingray

Update of /cvs/extras/rpms/flow-tools/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22692

Modified Files:
	flow-tools.spec 
Added Files:
	flow-capture.init flow-capture.sysconfig 
Log Message:
Add user and init scripts



--- NEW FILE flow-capture.init ---
#!/bin/sh
#
# flow-capture Capture traffic flow data
#
# chkconfig: - 90 10
# description: Capture traffic flow data

### BEGIN INIT INFO
# Provides: flow-capture
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: Capture traffic flow data
# Description: Capture traffic flow data
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

prog="flow-capture"
exec="/usr/bin/$prog"
config="/etc/sysconfig/$prog"
lockfile=/var/lock/subsys/$prog

[ -e $config ] && . $config

# Define the flow-tools username
FLOWTOOLS_USER="${FLOWTOOLS_USER:-flow-tools}"

# Add pidfile
OPTIONS="-p /var/run/flow-capture.pid $OPTIONS"

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
        exit 0
fi

start() {
    [ -x $exec ] || exit 5
    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    # if not running, start it up here, usually something like "daemon $exec"
    daemon --user=$FLOWTOOLS_USER $exec $OPTIONS
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}	

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

rh_status() {
    # run checks to determine if the service is running or use generic status
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?


--- NEW FILE flow-capture.sysconfig ---
# Change the source IP and port to what is used on your network
OPTIONS="-n 287 -N 0 -w /var/flow-tools -S 5 0/0/8818"


Index: flow-tools.spec
===================================================================
RCS file: /cvs/extras/rpms/flow-tools/devel/flow-tools.spec,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- flow-tools.spec	5 Aug 2007 10:20:27 -0000	1.18
+++ flow-tools.spec	14 Sep 2007 18:36:16 -0000	1.19
@@ -1,15 +1,32 @@
+%bcond_without  fedora
+
+%global uid 40
+%global username flow-tools
+%global homedir %{_localstatedir}/%{name}
+%global gecos "Network flow monitoring"
+
 Version: 0.68.1
 Name: flow-tools
 Summary: Tool set for working with NetFlow data
-Release: 1%{?dist}
+Release: 2%{?dist}
 Group: Applications/System
 License: BSD 
 URL: http://code.google.com/p/%{name}/
 Source0: http://%{name}.googlecode.com/files/%{name}-%{version}.tar.bz2
+Source1: flow-capture.init
+Source2: flow-capture.sysconfig
 Requires: rrdtool-python
 BuildRequires: openssl-devel mysql-devel postgresql-devel zlib-devel 
 BuildRequires: bison flex tcp_wrappers
+BuildRequires: fedora-usermgmt-devel
+%{?FE_USERADD_REQ}
 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+Requires(post): initscripts chkconfig
+Requires(preun): initscripts chkconfig
+Requires(postun): initscripts
+Provides: group(%username) = %uid
+Provides: user(%username) = %uid
+
 
 %description
 Flow-tools is library and a collection of programs used to collect, 
@@ -56,13 +73,37 @@
 make DESTDIR=$RPM_BUILD_ROOT install
 find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
 mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/%{name}
+install -d $RPM_BUILD_ROOT%{_initrddir}
+install -m 0755 %SOURCE1 $RPM_BUILD_ROOT%{_initrddir}/flow-capture
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
+install -m 0644 %SOURCE2 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/flow-capture
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post -p /sbin/ldconfig
+%pre
+%__fe_groupadd %uid -r %username &>/dev/null || :
+%__fe_useradd  %uid -r -s /sbin/nologin -d %homedir -M          \
+                    -c '%gecos' -g %username %username &>/dev/null || :
+
+%post
+/sbin/ldconfig
+/sbin/chkconfig --add flow-capture
+
+%preun
+if [ $1 = 0 ]; then
+        /sbin/service flow-capture stop >/dev/null 2>&1
+        /sbin/chkconfig --del flow-capture
+fi
+
+%postun
+/sbin/ldconfig
+if [ "$1" -ge "1" ]; then
+        /sbin/service flow-capture condrestart >/dev/null 2>&1 || :
+fi
 
-%postun -p /sbin/ldconfig
+%__fe_userdel  %username &>/dev/null || :
+%__fe_groupdel %username &>/dev/null || :
 
 %files 
 %defattr(-,root,root)
@@ -76,7 +117,9 @@
 %dir %{_sysconfdir}/%{name}/sym/
 %config(noreplace) %{_sysconfdir}/%{name}/cfg/*
 %config(noreplace) %{_sysconfdir}/%{name}/sym/*
-%{_localstatedir}/%{name}/
+%config(noreplace) %{_sysconfdir}/sysconfig/flow-capture
+%{_initrddir}/flow-capture
+%attr(-,flow-tools,flow-tools) %{_localstatedir}/%{name}/
 %dir %{_datadir}/%{name}/
 %{_datadir}/%{name}/*
 
@@ -86,6 +129,9 @@
 %{_includedir}/*.h
 
 %changelog
+* Thu Sep 13 2007 Orion Poplawski <orion at cora.nwra.com> - 0.68.1-2
+- Add user and init scripts
+
 * Sun Aug  5 2007 Paul P Komkoff Jr <i at stingr.net> - 0.68.1-1
 - New upstream release
 




More information about the fedora-extras-commits mailing list