Merge "Refactor patches for haproxy package."

This commit is contained in:
Zuul
2018-11-12 10:07:08 +00:00
committed by Gerrit Code Review
5 changed files with 186 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=1

View File

@@ -0,0 +1,41 @@
Summary: haproxy-config
Name: haproxy-config
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: StarlingX
URL: unknown
BuildArch: noarch
Source: %name-%version.tar.gz
Requires: haproxy
Summary: package StarlingX configuration files of haproxy to system folder.
%description
package StarlingX configuration files of haproxy to system folder.
%prep
%setup
%build
%install
%{__install} -d 755 %{buildroot}%{_sysconfdir}/haproxy/errors/
%{__install} -m 755 503.http %{buildroot}%{_sysconfdir}/haproxy/errors/503.http
%{__install} -d %{buildroot}%{_sysconfdir}/systemd/system
%{__install} -m 644 haproxy.service %{buildroot}%{_sysconfdir}/systemd/system
mkdir -p %{_sysconfdir}/init.d
%{__install} -p -D -m 0755 haproxy.sh %{buildroot}%{_sysconfdir}/init.d/haproxy
%post
/bin/systemctl disable haproxy.service
%files
%defattr(-,root,root,-)
%dir %{_sysconfdir}/haproxy/errors/
%{_sysconfdir}/haproxy/errors/*
%{_sysconfdir}/init.d/haproxy
%{_sysconfdir}/systemd/system/haproxy.service

View File

@@ -0,0 +1,9 @@
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

View File

@@ -0,0 +1,13 @@
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target
[Service]
EnvironmentFile=/etc/sysconfig/haproxy
ExecStart=/etc/init.d/haproxy start
ExecStop=/etc/init.d/haproxy stop
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,121 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: HA-Proxy
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: HA-Proxy TCP/HTTP reverse proxy
# Description: HA-Proxy is a TCP/HTTP reverse proxy
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/haproxy
NAME=haproxy
DESC="HA-Proxy TCP/HTTP reverse proxy"
PIDFILE="/var/run/$NAME.pid"
TPM_DATA_DIR="/var/run/TPM_haproxy/"
OPTS="-D -f /etc/haproxy/haproxy.cfg -p $PIDFILE"
RETVAL=0
# This is only needed till TPM In-Kernel
# ResourceMgr comes in
remove_TPM_transients () {
_HANDLES=`find $TPM_DATA_DIR -type f -name "hp*.bin" -printf "%f "`
for handle in $_HANDLES; do
handle_addr=`echo $handle | sed 's/hp\([0-9]*\)\.bin/\1/g'`
tss2_flushcontext -ha $handle_addr &> /dev/null
done
rm -f $TPM_DATA_DIR/*
}
start() {
if [ -e $PIDFILE ]; then
PIDDIR=/proc/$(cat $PIDFILE)
if [ -d $PIDDIR ]; then
echo "$DESC already running."
return
else
echo "Removing stale PID file $PIDFILE"
rm -f $PIDFILE
fi
fi
# TODO: This is a temporary workaround till
# we eventually add a resource manager for TPM
mkdir -p $TPM_DATA_DIR
echo -n "Starting $NAME: "
TPM_DATA_DIR=$TPM_DATA_DIR start-stop-daemon --start --pidfile $PIDFILE -x "$DAEMON" -- $OPTS
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "done."
else
remove_TPM_transients
echo "failed."
fi
}
stop() {
if [ ! -e $PIDFILE ]; then
return
fi
echo -n "Stopping $DESC..."
start-stop-daemon --stop --quiet --retry 3 --oknodo --pidfile $PIDFILE -x "$DAEMON"
if [ -n "`pidof $DAEMON`" ] ; then
pkill -KILL -f $DAEMON
fi
echo "done."
rm -f $PIDFILE
rm -f /var/lock/subsys/$NAME
remove_TPM_transients
}
status() {
pid=`cat $PIDFILE 2>/dev/null`
if [ -n "$pid" ]; then
if ps -p $pid &>/dev/null ; then
echo "$DESC is running"
RETVAL=0
return
else
RETVAL=1
fi
fi
echo "$DESC is not running"
RETVAL=1
}
check() {
/usr/sbin/$NAME -c -q -V -f /etc/$NAME/$NAME.cfg
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
stop
start
;;
status)
status
;;
check)
check
;;
*)
echo "Usage: $0 {start|stop|force-reload|restart|reload|status|check}"
RETVAL=1
;;
esac
exit $RETVAL