[sks/el6: 3/3] Add init scripts for sks
Nick Bebout
nb at fedoraproject.org
Mon Jan 23 17:29:12 UTC 2012
commit 4b04339bdca7bcf18ced2579d03f594edd80ab8f
Author: Nick Bebout <nb at fedoraproject.org>
Date: Mon Jan 23 11:28:36 2012 -0600
Add init scripts for sks
sks.spec | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/sks.spec b/sks.spec
index b17ee17..fdd8c5d 100644
--- a/sks.spec
+++ b/sks.spec
@@ -12,6 +12,10 @@ Patch0: sks-1.1.1-libdb.patch
#Patch1: sks-1.1.1-bdb.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: ocaml ocaml-camlp4-devel db4-devel zlib-devel chrpath
+Requires(pre): /usr/sbin/groupadd /usr/sbin/useradd
+Requires(post): /sbin/chkconfig
+Requires(preun): /sbin/chkconfig /sbin/service
+Requires(postun): /sbin/service
# ocaml only available on these:
ExclusiveArch: alpha armv4l %{ix86} ia64 x86_64 ppc ppc64 sparc sparcv9
@@ -37,14 +41,56 @@ chmod -x %{buildroot}%{_mandir}/man8/sks.8.gz
chrpath --delete %{buildroot}%{_bindir}/sks
install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/sks-db
install -Dp -m0755 %{SOURCE2} %{buildroot}%{_initrddir}/sks-recon
+mkdir -p %{buildroot}%{_sbindir}
for TYPE in db recon; do
- %{__ln_s} %{_bindir}/%{name} ${RPM_BUILD_ROOT}%{_sbindir}/%{name}-${TYPE}
+ %{__ln_s} %{_bindir}/%{name} %{buildroot}%{_sbindir}/%{name}-${TYPE}
done
%clean
%__rm -Rf "%{buildroot}"
+%pre
+if ! getent group %{name} >/dev/null 2>&1; then
+ /usr/sbin/groupadd -r %{name}
+fi
+if ! getent passwd %{name} >/dev/null 2>&1; then
+ /usr/sbin/useradd -r -g %{name} \
+ -d %{_localstatedir}/lib/%{name} \
+ -c "SKS Service user" \
+ -s /sbin/nologin %{name}
+fi
+exit 0 # Always pass
+
+
+%post
+/sbin/chkconfig --add %{name}-db
+/sbin/chkconfig --add %{name}-recon
+
+%preun
+if [ $1 -eq 0 ]; then # Remove
+ /sbin/service %{name}-recon stop >/dev/null 2>&1
+ /sbin/service %{name}-db stop >/dev/null 2>&1
+
+ /sbin/chkconfig --del %{name}-recon
+ /sbin/chkconfig --del %{name}-db
+fi
+
+
+%postun
+if [ $1 -ge 1 ]; then # Upgrade
+ /sbin/service %{name}-db condrestart >/dev/null 2>&1 || :
+ /sbin/service %{name}-recon condrestart >/dev/null 2>&1 || :
+fi
+
+
+%triggerin -- prelink, %{_sysconfdir}/prelink.conf
+# Prevent prelink from modifying programs
+if ! %{__grep} -q "%{_bindir}/{%{name}" %{_sysconfdir}/prelink.conf 2>/dev/null; then
+ echo -e "-b %{_bindir}/{%{name},sks_add_mail,spider}" \
+ >>%{_sysconfdir}/prelink.conf
+fi
+
%files
%defattr(-,root,root)
%doc BUGS CHANGELOG COPYING FILES README TODO VERSION
More information about the scm-commits
mailing list