haproxy: New package
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 5 Mar 2015 13:48:16 +0000 (14:48 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 5 Mar 2015 13:48:16 +0000 (14:48 +0100)
config/backup/includes/haproxy [new file with mode: 0644]
config/haproxy/haproxy.cfg [new file with mode: 0644]
config/rootfiles/packages/haproxy [new file with mode: 0644]
lfs/haproxy [new file with mode: 0644]
make.sh
src/initscripts/init.d/haproxy [new file with mode: 0644]

diff --git a/config/backup/includes/haproxy b/config/backup/includes/haproxy
new file mode 100644 (file)
index 0000000..4516e18
--- /dev/null
@@ -0,0 +1 @@
+/etc/haproxy/haproxy.cfg
diff --git a/config/haproxy/haproxy.cfg b/config/haproxy/haproxy.cfg
new file mode 100644 (file)
index 0000000..324ad5e
--- /dev/null
@@ -0,0 +1,86 @@
+#---------------------------------------------------------------------
+# Example configuration for a possible web application.  See the
+# full configuration options online.
+#
+#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
+#
+#---------------------------------------------------------------------
+
+#---------------------------------------------------------------------
+# Global settings
+#---------------------------------------------------------------------
+global
+    # to have these messages end up in /var/log/haproxy.log you will
+    # need to:
+    #
+    # 1) configure syslog to accept network log events.  This is done
+    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
+    #    /etc/sysconfig/syslog
+    #
+    # 2) configure local2 events to go to the /var/log/haproxy.log
+    #   file. A line like the following can be added to
+    #   /etc/sysconfig/syslog
+    #
+    #    local2.*                       /var/log/haproxy.log
+    #
+    log         127.0.0.1 local2
+
+    chroot      /var/lib/haproxy
+    pidfile     /var/run/haproxy.pid
+    maxconn     4000
+    user        haproxy
+    group       haproxy
+    daemon
+
+    # turn on stats unix socket
+    stats socket /var/lib/haproxy/stats
+
+#---------------------------------------------------------------------
+# common defaults that all the 'listen' and 'backend' sections will
+# use if not designated in their block
+#---------------------------------------------------------------------
+defaults
+    mode                    http
+    log                     global
+    option                  httplog
+    option                  dontlognull
+    option http-server-close
+    option forwardfor       except 127.0.0.0/8
+    option                  redispatch
+    retries                 3
+    timeout http-request    10s
+    timeout queue           1m
+    timeout connect         10s
+    timeout client          1m
+    timeout server          1m
+    timeout http-keep-alive 10s
+    timeout check           10s
+    maxconn                 3000
+
+#---------------------------------------------------------------------
+# main frontend which proxys to the backends
+#---------------------------------------------------------------------
+frontend  main *:5000
+    acl url_static       path_beg       -i /static /images /javascript /stylesheets
+    acl url_static       path_end       -i .jpg .gif .png .css .js
+
+    use_backend static          if url_static
+    default_backend             app
+
+#---------------------------------------------------------------------
+# static backend for serving up images, stylesheets and such
+#---------------------------------------------------------------------
+backend static
+    balance     roundrobin
+    server      static 127.0.0.1:4331 check
+
+#---------------------------------------------------------------------
+# round robin balancing between the various backends
+#---------------------------------------------------------------------
+backend app
+    balance     roundrobin
+    server  app1 127.0.0.1:5001 check
+    server  app2 127.0.0.1:5002 check
+    server  app3 127.0.0.1:5003 check
+    server  app4 127.0.0.1:5004 check
+
diff --git a/config/rootfiles/packages/haproxy b/config/rootfiles/packages/haproxy
new file mode 100644 (file)
index 0000000..515145d
--- /dev/null
@@ -0,0 +1,8 @@
+#etc/haproxy
+etc/haproxy/haproxy.cfg
+etc/rc.d/init.d/haproxy
+usr/sbin/haproxy
+#usr/sbin/haproxy-systemd-wrapper
+#usr/share/man/man1/haproxy.1
+var/ipfire/backup/addons/includes/haproxy
+var/lib/haproxy
diff --git a/lfs/haproxy b/lfs/haproxy
new file mode 100644 (file)
index 0000000..febb65a
--- /dev/null
@@ -0,0 +1,99 @@
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2013  IPFire Team  <info@ipfire.org>                          #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 1.5.11
+
+THISAPP    = haproxy-$(VER)
+DL_FILE    = $(THISAPP).tar.gz
+DL_FROM    = $(URL_IPFIRE)
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+PROG       = haproxy
+PAK_VER    = 1
+
+DEPS       = ""
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = 5500a79d0d2b238d4a1e9749bd0c2cb2
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+dist:
+       @$(PAK)
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+       @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+       @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+       @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+       @$(PREBUILD)
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
+
+       cd $(DIR_APP) && make $(MAKETUNING) CPU="generic" TARGET="linux2628" \
+               USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1 USE_REGPARM=1 \
+               ADDINC="$(CFLAGS)" USE_LINUX_TPROXY=1 ADDLIB="$(LDFLAGS)"
+
+       cd $(DIR_APP) && make install-bin install-man PREFIX=/usr
+
+       -mkdir -pv /etc/haproxy /var/lib/haproxy
+       install -v -m 644 $(DIR_SRC)/config/haproxy/haproxy.cfg \
+               /etc/haproxy/haproxy.cfg
+
+       install -v -m 644 $(DIR_SRC)/config/backup/includes/haproxy \
+               /var/ipfire/backup/addons/includes/haproxy
+
+       # Restore initscript
+       install -v -m 754 $(DIR_SRC)/src/initscripts/init.d/haproxy \
+               /etc/rc.d/init.d/haproxy
+
+       @rm -rf $(DIR_APP)
+       @$(POSTBUILD)
diff --git a/make.sh b/make.sh
index 386403e..7d41b59 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -811,6 +811,7 @@ buildipfire() {
   ipfiremake pigz
   ipfiremake tmux
   ipfiremake swconfig
+  ipfiremake haproxy
 }
 
 buildinstaller() {
diff --git a/src/initscripts/init.d/haproxy b/src/initscripts/init.d/haproxy
new file mode 100644 (file)
index 0000000..78d64ce
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/haproxy
+#
+# Description : HAProxy init script
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+case "${1}" in
+       start)
+               boot_mesg "Starting HAProxy..."
+               loadproc /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg \
+                       -p /var/run/haproxy.pid
+               ;;
+
+       stop)
+               boot_mesg "Stopping HAProxy..."
+               killproc /usr/sbin/haproxy
+               ;;
+
+       reload)
+               boot_mesg "Reloading HAProxy..."
+               /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg \
+                       -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)
+               evaluate_retval
+               ;;
+
+       restart)
+               ${0} stop
+               sleep 1
+               ${0} start
+               ;;
+
+       status)
+               statusproc /usr/sbin/haproxy
+               ;;
+
+       *)
+               echo "Usage: ${0} {start|stop|reload|restart|status}"
+               exit 1
+               ;;
+esac
+
+# End $rc_base/init.d/haproxy