diff --git a/haproxy.init b/haproxy.init deleted file mode 100644 index 5963b2a..0000000 --- a/haproxy.init +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh -# -# haproxy -# -# chkconfig: - 85 15 -# description: HAProxy is a free, very fast and reliable solution \ -# offering high availability, load balancing, and \ -# proxying for TCP and HTTP-based applications -# processname: haproxy -# config: /etc/haproxy/haproxy.cfg -# pidfile: /var/run/haproxy.pid - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. -[ "$NETWORKING" = "no" ] && exit 0 - -exec="/usr/sbin/haproxy" -prog=$(basename $exec) - -[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog - -lockfile=/var/lock/subsys/haproxy - -check() { - $exec -c -V -f /etc/$prog/$prog.cfg -} - -start() { - $exec -c -q -f /etc/$prog/$prog.cfg - if [ $? -ne 0 ]; then - echo "Errors in configuration file, check with $prog check." - return 1 - fi - - echo -n $"Starting $prog: " - # start it up here, usually something like "daemon $exec" - daemon $exec -D -f /etc/$prog/$prog.cfg -p /var/run/$prog.pid - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - # stop it here, often "killproc $prog" - killproc $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - $exec -c -q -f /etc/$prog/$prog.cfg - if [ $? -ne 0 ]; then - echo "Errors in configuration file, check with $prog check." - return 1 - fi - stop - start -} - -reload() { - $exec -c -q -f /etc/$prog/$prog.cfg - if [ $? -ne 0 ]; then - echo "Errors in configuration file, check with $prog check." - return 1 - fi - echo -n $"Reloading $prog: " - $exec -D -f /etc/$prog/$prog.cfg -p /var/run/$prog.pid -sf $(cat /var/run/$prog.pid) - retval=$? - echo - return $retval -} - -force_reload() { - restart -} - -fdr_status() { - status $prog -} - -case "$1" in - start|stop|restart|reload) - $1 - ;; - force-reload) - force_reload - ;; - check) - check - ;; - status) - fdr_status - ;; - condrestart|try-restart) - [ ! -f $lockfile ] || restart - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}" - exit 2 -esac diff --git a/haproxy.service b/haproxy.service new file mode 100644 index 0000000..50d94fc --- /dev/null +++ b/haproxy.service @@ -0,0 +1,13 @@ +[Unit] +Description=HAProxy For TCP And HTTP Based Applications +After=nsyslog.target etwork.target + +[Service] +Type=forking +PIDFile=/run/haproxy.pid +ExecStartPre=/usr/sbin/haproxy -c -q -f /etc/haproxy/haproxy.cfg +ExecStart=/usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid +ExecReload=/usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -sf $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/haproxy.spec b/haproxy.spec index 4ad68ed..b80bf4a 100644 --- a/haproxy.spec +++ b/haproxy.spec @@ -6,7 +6,7 @@ Name: haproxy Version: 1.4.19 -Release: 2%{?dist} +Release: 3%{?dist} Summary: HA-Proxy is a TCP/HTTP reverse proxy for high availability environments Group: System Environment/Daemons @@ -14,18 +14,19 @@ License: GPLv2+ URL: http://haproxy.1wt.eu/ Source0: http://haproxy.1wt.eu/download/1.4/src/haproxy-%{version}.tar.gz -Source1: %{name}.init +Source1: %{name}.service Source2: %{name}.cfg Source3: %{name}.logrotate BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: pcre-devel +BuildRequires: pcre-devel +BuildRequires: systemd-units -Requires(pre): %{_sbindir}/useradd -Requires(post): /sbin/chkconfig -Requires(preun): /sbin/chkconfig, /sbin/service -Requires(postun): /sbin/service +Requires(pre): shadow-utils +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units %description HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high @@ -74,7 +75,7 @@ rm -rf %{buildroot} make install-bin DESTDIR=%{buildroot} PREFIX=%{_prefix} make install-man DESTDIR=%{buildroot} PREFIX=%{_prefix} -%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name} +%{__install} -p -D -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service %{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{haproxy_confdir}/%{name}.cfg %{__install} -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} %{__install} -d -m 0755 %{buildroot}%{haproxy_home} @@ -101,25 +102,33 @@ rm -rf %{buildroot} %pre -%{_sbindir}/useradd -c "HAProxy user" -s /bin/false -r -d %{haproxy_home} %{haproxy_user} 2>/dev/null || : +getent group %{haproxy_group} >/dev/null || groupadd -r %{haproxy_group} +getent passwd %{haproxy_user} >/dev/null || \ + useradd -r -g %{haproxy_user} -d %{haproxy_home} -s /sbin/nologin \ + -c "HAProxy user" %{haproxy_user} +exit 0 %post -/sbin/chkconfig --add %{name} - +if [ $1 -eq 1 ]; then + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi %preun -if [ $1 = 0 ]; then - /sbin/service %{name} stop >/dev/null 2>&1 - /sbin/chkconfig --del %{name} -fi - +if [ $1 -eq 0 ]; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || : + /bin/systemctl stop %{name}.service > /dev/null 2>&1 || : +fi + %postun -if [ $1 -ge 1 ]; then -/sbin/service %{name} condrestart > /dev/null 2>&1 || : -fi - +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : +fi + %files %defattr(-,root,root,-) @@ -136,7 +145,7 @@ fi %dir %{haproxy_confdir} %config(noreplace) %{haproxy_confdir}/%{name}.cfg %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} -%{_initrddir}/%{name} +%{_unitdir}/%{name}.service %{_sbindir}/%{name} %{_bindir}/halog %{_mandir}/man1/%{name}.1.gz @@ -144,6 +153,9 @@ fi %changelog +* Sun Feb 19 2012 Jeremy Hinegardner - 1.4.19-3 +- Update to use systemd fixing bug #770305 + * Fri Feb 10 2012 Petr Pisar - 1.4.19-2 - Rebuild against PCRE 8.30