[znc] Add init file to use for EL6 and EL5

Nick Bebout nb at fedoraproject.org
Mon Jan 23 21:10:17 UTC 2012


commit 62132cff81765d0cded934557521c69f8f54406f
Author: Nick Bebout <nb at fedoraproject.org>
Date:   Mon Jan 23 15:10:00 2012 -0600

    Add init file to use for EL6 and EL5

 znc.init |    2 +-
 znc.spec |   52 ++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 49 insertions(+), 5 deletions(-)
---
diff --git a/znc.init b/znc.init
index 64880df..aaabbd0 100644
--- a/znc.init
+++ b/znc.init
@@ -9,7 +9,7 @@
 
 exec=/usr/bin/znc
 prog=znc
-config=/home/znc/.znc
+config=/var/lib/znc
 runas=znc
 
 lockfile=/var/lock/subsys/$prog
diff --git a/znc.spec b/znc.spec
index dcee908..21cbdd3 100644
--- a/znc.spec
+++ b/znc.spec
@@ -11,14 +11,20 @@ Summary:        An advanced IRC bouncer
 Name:           znc
 Version:        0.204
 #Release:        0.1.20110801git%{?dist}
-Release:        1%{?dist}
+Release:        2%{?dist}
 License:        GPLv2 with exceptions
 Group:          System Environment/Daemons
 URL:            http://znc.in
 Source0:        http://znc.in/releases/znc-0.204.tar.gz
+
 %if %{use_systemd}
 Source1:        znc.service
 %endif
+
+%if !%{use_systemd}
+Source1:	znc.init
+%endif
+
 # git clone https://github.com/znc/znc.git
 # cd znc
 # git archive --prefix=znc/ HEAD | xz > ../znc-0.097.tar.xz
@@ -40,6 +46,13 @@ Requires(preun): systemd-units
 Requires(postun): systemd-units
 %endif
 
+%if !%{use_systemd}
+Requires(post): chkconfig
+Requires(preun): chkconfig
+# This is for /sbin/service
+Requires(preun): initscripts
+%endif
+
 %description
 ZNC is an IRC bouncer with many advanced features like detaching,
 multiple users, per channel playback buffer, SSL, IPv6, transparent
@@ -106,15 +119,15 @@ chmod -x modules/q.cpp
 %__make %{?_smp_mflags}
 
 %pre
-%if %{use_systemd}
+#%if %{use_systemd}
 getent group znc >/dev/null || groupadd -r znc
 getent passwd znc >/dev/null || \
     useradd -r -g znc -d /var/lib/znc -s /sbin/nologin \
     -c "Account for ZNC to run as" znc
 mkdir -p /var/lib/znc
 chown znc:znc /var/lib/znc
-exit 0
-%endif
+#exit 0
+#%endif
 
 %install
 %__rm -Rf "%{buildroot}"
@@ -123,11 +136,16 @@ exit 0
 mkdir -p %buildroot%{_unitdir}
 install -m 0644 %{SOURCE1} %buildroot%{_unitdir}/znc.service
 %endif
+%if !%{use_systemd}
+mkdir -p %buildroot%{_initrddir}
+install -Dp -m0755 %{SOURCE1} %{buildroot}%{_initrddir}/znc
+%endif
 
 %clean
 %__rm -Rf "%{buildroot}"
 
 %post
+
 %if %{use_systemd}
 if [ $1 -eq 1 ] ; then
     # Initial installation 
@@ -135,7 +153,13 @@ if [ $1 -eq 1 ] ; then
 fi
 %endif
 
+%if !%{use_systemd}
+# This adds the proper /etc/rc*.d links for the script
+/sbin/chkconfig --add znc
+%endif
+
 %postun
+
 %if %{use_systemd}
 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
 if [ $1 -ge 1 ] ; then
@@ -144,7 +168,14 @@ if [ $1 -ge 1 ] ; then
 fi
 %endif
 
+%if !%{use_systemd}
+if [ "$1" -ge "1" ] ; then
+    /sbin/service znc condrestart >/dev/null 2>&1 || :
+fi
+%endif
+
 %preun
+
 %if %{use_systemd}
 if [ $1 -eq 0 ] ; then
     # Package removal, not upgrade
@@ -153,6 +184,13 @@ if [ $1 -eq 0 ] ; then
 fi
 %endif
 
+%if !%{use_systemd}
+if [ $1 -eq 0 ] ; then
+    /sbin/service znc stop >/dev/null 2>&1
+    /sbin/chkconfig --del znc
+fi
+%endif
+
 %files
 %defattr(-,root,root)
 %doc AUTHORS LICENSE LICENSE.OpenSSL README.md
@@ -200,6 +238,9 @@ fi
 %if %{use_systemd}
 %{_unitdir}/znc.service
 %endif
+%if !%{use_systemd}
+%{_initrddir}/znc
+%endif
 
 %files devel
 %defattr(-,root,root)
@@ -246,6 +287,9 @@ fi
 %{_libdir}/znc/modpython.so
 
 %changelog
+* Mon Jan 23 2012 Nick Bebout <nb at fedoraproject.org> - 0.204-2
+- Add init script for EPEL
+
 * Mon Jan 23 2012 Nick Bebout <nb at fedoraproject.org> - 0.204-1
 - Update to 0.204 to fix security issue CVE-2012-0033
 


More information about the scm-commits mailing list