Add systemd file for znc

This commit is contained in:
Nick Bebout 2011-08-13 17:34:31 -05:00
parent c378a2e0c0
commit fa53c07e29
5 changed files with 186 additions and 40 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -1 +1 @@
fc93f5a66ace23aa6d8b289a50213008 znc-0.2-beta1.tar.gz
40b99830fac3f5ee813d3ab04b4b9e74 znc-0.200-rc1.tar.gz

90
znc.init Normal file
View File

@ -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 $?

11
znc.service Normal file
View File

@ -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

122
znc.spec
View File

@ -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 <nb@fedoraproject.org> - 0.200-0.1.rc1
- Update to 0.200-rc1
* Sat Aug 6 2011 Nick Bebout <nb@fedoraproject.org> - 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 <nb@fedoraproject.org> - 0.2-0.1.alpha1
- Update to 0.2-alpha1