From c378a2e0c021be1870e8d0a932796d2c4c70c1c3 Mon Sep 17 00:00:00 2001 From: Nick Bebout Date: Sat, 13 Aug 2011 16:56:51 -0500 Subject: [PATCH 1/3] Rediff patch --- znc-release.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/znc-release.patch b/znc-release.patch index 6e8c727..cacd27c 100644 --- a/znc-release.patch +++ b/znc-release.patch @@ -1,10 +1,10 @@ ---- znc-0.2-alpha1-original/znc.cpp 2011-08-05 16:27:44.000000000 -0500 -+++ znc-0.2-alpha1/znc.cpp 2011-08-05 17:14:15.293147148 -0500 +--- znc-0.200-rc1-orig/znc.cpp 2011-08-13 01:36:13.000000000 -0500 ++++ znc-0.200-rc1/znc.cpp 2011-08-13 16:56:21.118177776 -0500 @@ -84,7 +84,7 @@ } char szBuf[128]; -- snprintf(szBuf, sizeof(szBuf), "ZNC %1.1f"VERSION_EXTRA" - http://znc.in", VERSION); +- snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f"VERSION_EXTRA" - http://znc.in", VERSION); + snprintf(szBuf, sizeof(szBuf), "ZNC %1.3f - http://znc.in", VERSION); // If snprintf overflows (which I doubt), we want to be on the safe side szBuf[sizeof(szBuf) - 1] = '\0'; From fa53c07e29d2776760fb6261e4520655115d652b Mon Sep 17 00:00:00 2001 From: Nick Bebout Date: Sat, 13 Aug 2011 17:34:31 -0500 Subject: [PATCH 2/3] Add systemd file for znc --- .gitignore | 1 + sources | 2 +- znc.init | 90 ++++++++++++++++++++++++++++++++++++++ znc.service | 11 +++++ znc.spec | 122 +++++++++++++++++++++++++++++++++++----------------- 5 files changed, 186 insertions(+), 40 deletions(-) create mode 100644 znc.init create mode 100644 znc.service diff --git a/.gitignore b/.gitignore index 9b349ed..53eabc6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ znc-0.094.tar.gz /znc-0.099.tar.xz /znc-0.2-alpha1.tar.gz /znc-0.2-beta1.tar.gz +/znc-0.200-rc1.tar.gz diff --git a/sources b/sources index 9aba4f9..a8fb2bf 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -fc93f5a66ace23aa6d8b289a50213008 znc-0.2-beta1.tar.gz +40b99830fac3f5ee813d3ab04b4b9e74 znc-0.200-rc1.tar.gz diff --git a/znc.init b/znc.init new file mode 100644 index 0000000..64880df --- /dev/null +++ b/znc.init @@ -0,0 +1,90 @@ +#!/bin/sh +# +# znc - Advanced IRC Bouncer INIT script for Fedora # +# chkconfig: 35 99 14 +# description: An Advanced IRC bouncer INIT script for +# Fedora-CentOS Variants +# Source function library. +. /etc/rc.d/init.d/functions + +exec=/usr/bin/znc +prog=znc +config=/home/znc/.znc +runas=znc + +lockfile=/var/lock/subsys/$prog + +start() { +[ -x $exec ] || exit 5 +echo -n $"Starting $prog: " +# if not running, start it up here, usually something like "daemon $exec" +daemon --user $runas "$exec -d $config >/dev/null 2>&1" +# If you're reckless with your system, comment the line above and +# uncomment this one below... I just don't get it why +# daemon "$exec -r -d $config >/dev/null 2>&1" +retval=$? +echo +[ $retval -eq 0 ] && touch $lockfile +return $retval +} + +stop() { +echo -n $"Stopping $prog: " +# stop it here, often "killproc $prog" +killproc $prog -TERM +retval=$? +echo +[ $retval -eq 0 ] && rm -f $lockfile +return $retval +} + +reload() { +echo -n $"Reloading $prog: " +# stop it here, often "killproc $prog" +killproc $prog -HUP +retval=$? +echo +} + +restart() { +stop +start +} + +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 +;; +status) +rh_status +;; +condrestart|try-restart) +rh_status_q || exit 0 +restart +;; +*) +echo $"Usage: $0 {start|stop|status|reload|restart|condrestart|try-restart}" +exit 2 +esac +exit $? diff --git a/znc.service b/znc.service new file mode 100644 index 0000000..e2c92b2 --- /dev/null +++ b/znc.service @@ -0,0 +1,11 @@ +[Unit] +Description=Daemon to do something +After=network.target + +[Service] +ExecStart=/usr/bin/znc +User=znc +Type=forking + +[Install] +WantedBy=multi-user.target diff --git a/znc.spec b/znc.spec index 0ba2037..0f5145a 100644 --- a/znc.spec +++ b/znc.spec @@ -1,14 +1,24 @@ +# Define variables to use in conditionals +%define use_systemd 0 + +%if 0%{?fedora} >= 15 +%define use_systemd 1 +%endif + Summary: An advanced IRC bouncer Name: znc -Version: 0.2 +Version: 0.200 #Release: 0.1.20110801git%{?dist} -Release: 0.2.beta1%{?dist} +Release: 0.1.rc1%{?dist} #Release: 1%{?dist} License: GPLv2 with exceptions Group: System Environment/Daemons URL: http://znc.in #Source0: znc-0.099.tar.xz -Source0: http://people.znc.in/~psychon/znc/releases/znc-0.2-beta1.tar.gz +Source0: http://people.znc.in/~psychon/znc/releases/znc-0.200-rc1.tar.gz +%if %{use_systemd} +Source1: znc.service +%endif #Source0: http://people.znc.in/~psychon/znc/releases/znc-0.098.tar.gz Patch0: znc-release.patch #Patch1: znc-modperl.patch @@ -20,9 +30,19 @@ Patch0: znc-release.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: perl gcc-c++ BuildRequires: openssl-devel >= 0.9.8 -BuildRequires: cyrus-sasl-devel python3-devel +BuildRequires: cyrus-sasl-devel BuildRequires: c-ares-devel automake BuildRequires: perl(ExtUtils::Embed) swig tcl-devel +%if %{use_systemd} +BuildRequires: systemd-units +%endif +Requires(pre): shadow-utils +%if %{use_systemd} +Requires(post): systemd-units +Requires(post): systemd-sysv +Requires(preun): systemd-units +Requires(postun): systemd-units +%endif %description ZNC is an IRC bouncer with many advanced features like detaching, @@ -56,32 +76,19 @@ Requires: tcl %description modtcl TCL module for ZNC -%package modperl -Summary: perl module for ZNC -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} -Requires: perl -Provides: perl(ZNC::Module) = %{version}-%{release} +#%package modperl +#Summary: perl module for ZNC +#Group: Development/Libraries +#Requires: %{name} = %{version}-%{release} +#Requires: perl +#Provides: perl(ZNC::Module) = %{version}-%{release} -%description modperl -perl module for ZNC - -%package modpython -Summary: python module for ZNC -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} -Requires: python3 - -%description modpython -python module for ZNC +#%description modperl +#perl module for ZNC %prep -#%setup -q -n %{name}-alpha1 -%setup -q -n znc-0.2-beta1 -#%setup -q -n %{name}-%{version}-rc1 +%setup -q -n %{name}-%{version}-rc1 %patch0 -p1 -#%patch1 -p1 -#%patch2 -p1 %__perl -pi.add_release -e 's|(?<="ZNC \%1\.3f)|-%{release}|' znc.cpp chmod -x modules/q.cpp @@ -89,17 +96,53 @@ chmod -x modules/q.cpp ./autogen.sh %configure \ --with-module-prefix=%{_libdir}/znc \ - --enable-ipv6 --enable-extra --enable-sasl --enable-perl \ - --enable-tcl --enable-python + --enable-ipv6 --enable-extra --enable-sasl --disable-perl --enable-tcl %__make %{?_smp_mflags} +%pre +getent group znc >/dev/null || groupadd -r znc +getent passwd znc >/dev/null || \ + useradd -r -g znc -d /home/znc -s /sbin/nologin \ + -c "Account for ZNC to run as" znc +exit 0 + %install %__rm -Rf "%{buildroot}" %__make install DESTDIR="%{buildroot}" +%if %{use_systemd} +mkdir -p %buildroot%{_unitdir} +install -m 0644 %{SOURCE1} %buildroot%{_unitdir}/znc.service +%endif %clean %__rm -Rf "%{buildroot}" +%post +%if %{use_systemd} +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi +%endif + +%postun +%if %{use_systemd} +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart znc.service >/dev/null 2>&1 || : +fi +%endif + +%preun +%if %{use_systemd} +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable znc.service > /dev/null 2>&1 || : + /bin/systemctl stop znc.service > /dev/null 2>&1 || : +fi +%endif + %files %defattr(-,root,root) %doc AUTHORS LICENSE LICENSE.OpenSSL README.md @@ -144,6 +187,9 @@ chmod -x modules/q.cpp %{_libdir}/znc/watch.so %{_libdir}/znc/webadmin.so %{_datadir}/znc/ +%if %{use_systemd} +%{_unitdir}/znc.service +%endif %files devel %defattr(-,root,root) @@ -178,20 +224,18 @@ chmod -x modules/q.cpp %defattr(-,root,root) %{_libdir}/znc/modtcl.so -%files modperl -%defattr(-,root,root) -%{_libdir}/znc/modperl/ -%{_libdir}/znc/modperl.so -%{_libdir}/znc/perleval.pm - -%files modpython -%defattr(-,root,root) -%{_libdir}/znc/modpython/ -%{_libdir}/znc/modpython.so +#%files modperl +#%defattr(-,root,root) +#%{_libdir}/znc/modperl/ +#%{_libdir}/znc/modperl.so +#%{_libdir}/znc/perleval.pm %changelog +* Sat Aug 13 2011 Nick Bebout - 0.200-0.1.rc1 +- Update to 0.200-rc1 + * Sat Aug 6 2011 Nick Bebout - 0.2-0.2.beta1 -- Update to 0.2-beta1 +- Update to 0.2-beta1, disable perl for now * Fri Aug 5 2011 Nick Bebout - 0.2-0.1.alpha1 - Update to 0.2-alpha1 From ebf1137280cce589daaeb09debd30f1d71ad7664 Mon Sep 17 00:00:00 2001 From: Nick Bebout Date: Sun, 14 Aug 2011 15:06:56 -0500 Subject: [PATCH 3/3] Create /home/znc when installed --- znc.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/znc.spec b/znc.spec index 0f5145a..93053b2 100644 --- a/znc.spec +++ b/znc.spec @@ -9,7 +9,7 @@ Summary: An advanced IRC bouncer Name: znc Version: 0.200 #Release: 0.1.20110801git%{?dist} -Release: 0.1.rc1%{?dist} +Release: 0.2.rc1%{?dist} #Release: 1%{?dist} License: GPLv2 with exceptions Group: System Environment/Daemons @@ -104,6 +104,8 @@ getent group znc >/dev/null || groupadd -r znc getent passwd znc >/dev/null || \ useradd -r -g znc -d /home/znc -s /sbin/nologin \ -c "Account for ZNC to run as" znc +mkdir -p /home/znc +chown znc:znc /home/znc exit 0 %install @@ -231,6 +233,9 @@ fi #%{_libdir}/znc/perleval.pm %changelog +* Sun Aug 14 2011 Nick Bebout - 0.200-0.2.rc1 +- Create /home/znc upon install + * Sat Aug 13 2011 Nick Bebout - 0.200-0.1.rc1 - Update to 0.200-rc1