Blob Blame History Raw
Name:           fsniper
Version:        1.3.1
Release:        7%{?dist}
Summary:        A tool that monitors directories for new files and invokes scripts on them

Group:          Applications/File
License:        GPLv3+
URL:            https://github.com/l3ib/fsniper
Source0:        http://projects.l3ib.org/fsniper/files/fsniper-%{version}.tar.gz
Source1:        fsniper.service
Source2:        fsniper.conf
Source3:        fsniper.sysconfig

# Fix umask permissions - http://bugs.l3ib.org/index.php?do=details&task_id=21
Patch1:         fsniper-umask.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  file-devel
BuildRequires:  pcre-devel
BuildRequires:  systemd-units

Requires(post):   systemd-units systemd-sysv
Requires(preun):  systemd-units
Requires(postun): systemd-units
Requires(pre):    /usr/sbin/useradd /usr/sbin/groupadd

%define servicename fsniper.service
%define fsdir       %{_localstatedir}/lib/%{name}

%description
fsniper is a tool that monitors a given set of directories for new
files. Then, based on the new file's type or name, it invokes a script to
be run (any executable via the shell) on that file.  Common uses include
making a single drop directory for all things from a webbrowser etc, and
having semi-intelligent scripts figure out what to do with those files. You
write the scripts yourself.


%prep
%setup -q
%patch1 -p1 -b .umask


%build
%configure
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
mkdir -p $RPM_BUILD_ROOT%{fsdir}

make install DESTDIR=$RPM_BUILD_ROOT

install -pm 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{servicename}
install -pm 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/fsniper.conf
install -pm 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/fsniper
install -pm 0644 doc/doc.txt $RPM_BUILD_ROOT%{docdir}

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/fsniper
%{_unitdir}/%{servicename}
%attr(-,%{name},%{name}) %dir %{fsdir}/
%config(noreplace) %{_sysconfdir}/fsniper.conf
%config(noreplace) %{_sysconfdir}/sysconfig/fsniper
%doc AUTHORS COPYING INSTALL README
%doc doc/doc.txt doc/keyvalcfg.txt example.conf

%pre
if [ $1 = 1 ]; then
    getent group %{name} >/dev/null || groupadd -r %{name}
    getent passwd %{name} >/dev/null || \
           useradd -r -g %{name} -d %{_localstatedir}/lib/%{name} -s /sbin/nologin \
           -c "%{name} user" %{name}
    exit 0
fi

%post
if [ $1 -eq 1 ] ; then 
    # Initial installation 
    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi

%preun
if [ $1 -eq 0 ] ; then
    # Package removal, not upgrade
    /bin/systemctl --no-reload disable %{servicename} > /dev/null 2>&1 || :
    /bin/systemctl stop %{servicename} > /dev/null 2>&1 || :
fi

%postun
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
    # Package upgrade, not uninstall
    /bin/systemctl try-restart %{servicename} >/dev/null 2>&1 || :
fi

%triggerun -- fsniper < 1.0-2
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply fsniper
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save fsniper >/dev/null 2>&1 ||:

# If the package is allowed to autostart:
/bin/systemctl --no-reload enable %{servicename} >/dev/null 2>&1 ||:

# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del fsniper >/dev/null 2>&1 || :
/bin/systemctl try-restart %{servicename} >/dev/null 2>&1 || :

%changelog
* Mon Jan 02 2012 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-7
- systemd support
- fix the upstream URL. The source0 URL stays the same until upstream
  releases a new version

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Mon Jan 12 2009 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-3
- apply the correct patch from upstream VCS (Manuel Wolfshant)

* Wed Oct 22 2008 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-2
- issues found during review (#467627):
- add link to upstream bugtracker for patch
- exit with 0 after useradd

* Sun Oct 19 2008 Jakub Hrozek <jhrozek@redhat.com> 1.3.1-1
- Initial packaging