convert from init.d to systemd
This commit is contained in:
		
							parent
							
								
									13c47d1a96
								
							
						
					
					
						commit
						8497ace486
					
				
							
								
								
									
										109
									
								
								haproxy.init
									
									
									
									
									
								
							
							
						
						
									
										109
									
								
								haproxy.init
									
									
									
									
									
								
							| @ -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 |  | ||||||
							
								
								
									
										13
									
								
								haproxy.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								haproxy.service
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||||
							
								
								
									
										44
									
								
								haproxy.spec
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								haproxy.spec
									
									
									
									
									
								
							| @ -6,7 +6,7 @@ | |||||||
| 
 | 
 | ||||||
| Name:           haproxy | Name:           haproxy | ||||||
| Version:        1.4.19 | Version:        1.4.19 | ||||||
| Release:        2%{?dist} | Release:        3%{?dist} | ||||||
| Summary:        HA-Proxy is a TCP/HTTP reverse proxy for high availability environments | Summary:        HA-Proxy is a TCP/HTTP reverse proxy for high availability environments | ||||||
| 
 | 
 | ||||||
| Group:          System Environment/Daemons | Group:          System Environment/Daemons | ||||||
| @ -14,18 +14,19 @@ License:        GPLv2+ | |||||||
| 
 | 
 | ||||||
| URL:            http://haproxy.1wt.eu/ | URL:            http://haproxy.1wt.eu/ | ||||||
| Source0:        http://haproxy.1wt.eu/download/1.4/src/haproxy-%{version}.tar.gz | Source0:        http://haproxy.1wt.eu/download/1.4/src/haproxy-%{version}.tar.gz | ||||||
| Source1:        %{name}.init | Source1:        %{name}.service | ||||||
| Source2:        %{name}.cfg | Source2:        %{name}.cfg | ||||||
| Source3:        %{name}.logrotate | Source3:        %{name}.logrotate | ||||||
| 
 | 
 | ||||||
| BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | ||||||
| BuildRequires:  pcre-devel | BuildRequires:  pcre-devel | ||||||
|  | BuildRequires:  systemd-units | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Requires(pre):      %{_sbindir}/useradd | Requires(pre):      shadow-utils | ||||||
| Requires(post):     /sbin/chkconfig | Requires(post):     systemd-units | ||||||
| Requires(preun):    /sbin/chkconfig, /sbin/service | Requires(preun):    systemd-units | ||||||
| Requires(postun):   /sbin/service | Requires(postun):   systemd-units | ||||||
| 
 | 
 | ||||||
| %description | %description | ||||||
| HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high | 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-bin DESTDIR=%{buildroot} PREFIX=%{_prefix} | ||||||
| make install-man 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 %{SOURCE2} %{buildroot}%{haproxy_confdir}/%{name}.cfg | ||||||
| %{__install} -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} | %{__install} -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} | ||||||
| %{__install} -d -m 0755 %{buildroot}%{haproxy_home} | %{__install} -d -m 0755 %{buildroot}%{haproxy_home} | ||||||
| @ -101,23 +102,31 @@ rm -rf %{buildroot} | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| %pre | %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 | %post | ||||||
| /sbin/chkconfig --add %{name} | if [ $1 -eq 1 ]; then | ||||||
|      |     /bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
| %preun | %preun | ||||||
| if [ $1 = 0 ]; then | if [ $1 -eq 0 ]; then | ||||||
|     /sbin/service %{name} stop >/dev/null 2>&1 |     # Package removal, not upgrade | ||||||
|     /sbin/chkconfig --del %{name} |     /bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || : | ||||||
|  |     /bin/systemctl stop %{name}.service > /dev/null 2>&1 || : | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| %postun | %postun | ||||||
| if [ $1 -ge 1 ]; then | /bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||||||
| /sbin/service %{name} condrestart > /dev/null 2>&1 || : | if [ $1 -ge 1 ] ; then | ||||||
|  |     # Package upgrade, not uninstall | ||||||
|  |     /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -136,7 +145,7 @@ fi | |||||||
| %dir %{haproxy_confdir} | %dir %{haproxy_confdir} | ||||||
| %config(noreplace) %{haproxy_confdir}/%{name}.cfg | %config(noreplace) %{haproxy_confdir}/%{name}.cfg | ||||||
| %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} | %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} | ||||||
| %{_initrddir}/%{name} | %{_unitdir}/%{name}.service | ||||||
| %{_sbindir}/%{name} | %{_sbindir}/%{name} | ||||||
| %{_bindir}/halog | %{_bindir}/halog | ||||||
| %{_mandir}/man1/%{name}.1.gz | %{_mandir}/man1/%{name}.1.gz | ||||||
| @ -144,6 +153,9 @@ fi | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| %changelog | %changelog | ||||||
|  | * Sun Feb 19 2012 Jeremy Hinegardner <jeremy at hinegardner dot org> - 1.4.19-3 | ||||||
|  | - Update to use systemd fixing bug #770305 | ||||||
|  | 
 | ||||||
| * Fri Feb 10 2012 Petr Pisar <ppisar@redhat.com> - 1.4.19-2 | * Fri Feb 10 2012 Petr Pisar <ppisar@redhat.com> - 1.4.19-2 | ||||||
| - Rebuild against PCRE 8.30 | - Rebuild against PCRE 8.30 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user