This patch adds pound 2.6  (www.apsis.ch/pound/) as a package. It has full UCI 
support. Pound 
needs a threaded OpenSSL library, thus the previous patch in the series.


Signed-off-by: Barnabás Králik <[email protected]>
---
Index: feeds/packages/net/pound/Makefile
===================================================================
--- feeds/packages/net/pound/Makefile    (revision 0)
+++ feeds/packages/net/pound/Makefile    (working copy)
@@ -0,0 +1,56 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=Pound
+PKG_VERSION:=2.6
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz
+PKG_SOURCE_URL:=http://www.apsis.ch/pound/
+PKG_MD5SUM:=8c913b527332694943c4c67c8f152071
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/pound
+  SECTION:=net
+  CATEGORY:=Network
+  SUBMENU:=Web Servers/Proxies
+  DEPENDS:=+libopenssl +libpthread +libpcre
+  TITLE:=Pound load balancer and reverse proxy
+  URL:=http://www.apsis.ch/pound/
+endef
+
+define Package/pound/description
+    The Pound program is a reverse proxy, load balancer and HTTPS front-end 
for Web server(s).
+    Pound was developed to enable distributing the load among several 
Web-servers and to allow 
+    for a convenient SSL wrapper for those Web servers that do not offer it 
natively.
+endef
+
+define Package/pound/config
+  select OPENSSL_THREADS
+endef
+
+define Package/pound/conffiles
+/etc/config/pound
+endef
+
+CONFIGURE_ARGS+= \
+    --with-ssl=$(STAGING_DIR)/usr \
+    --prefix=/usr/sbin
+
+define Build/Compile
+    mkdir -p $(PKG_INSTALL_DIR)/etc/pound
+    $(call Build/Compile/Default)
+endef
+
+define Package/pound/install
+    $(INSTALL_DIR) $(1)/usr/sbin
+    $(INSTALL_DIR) $(1)/etc/init.d
+    $(INSTALL_BIN) $(PKG_BUILD_DIR)/pound $(1)/usr/sbin/
+    $(INSTALL_BIN) $(PKG_BUILD_DIR)/poundctl $(1)/usr/sbin/
+    $(INSTALL_BIN) ./files/pound.init $(1)/etc/init.d/pound
+    $(INSTALL_DATA) ./files/pound.conf $(1)/etc/config/pound
+endef
+
+$(eval $(call BuildPackage,pound))
Index: feeds/packages/net/pound/files/pound.init
===================================================================
--- feeds/packages/net/pound/files/pound.init    (revision 0)
+++ feeds/packages/net/pound/files/pound.init    (working copy)
@@ -0,0 +1,258 @@
+#!/bin/sh /etc/rc.common
+START=99
+
+DAEMON=/usr/sbin/pound
+CFGFILE=/var/run/pound.cfg
+PIDFILE=/var/run/pound.pid
+TMPCFGFILE=/tmp/pound.cfg.new
+EXTRA_COMMANDS=generate_config
+PREFIX=0
+
+start() {
+    echo 'Pound is starting...'
+    generate_config || (echo 'Config file is bad, aborting.' >&2;return 1)
+    start-stop-daemon -S -x "$DAEMON" -p $PIDFILE -- -f "$CFGFILE"
+}
+
+stop() {
+    echo 'Pound is stopping...'
+    start-stop-daemon -K -q -x "$DAEMON" -p $PIDFILE
+}
+
+restart() {
+    generate_config && (
+      stop;
+      start
+    )
+}
+
+append_field() {
+    local cfg="$1"
+    local field="$2"
+    local _label="$3"
+    local default="$4"
+    config_get val "$cfg" "$field" "$default"
+    if [ -n "$val" ]
+    then
+        append_prefix
+        echo "$_label" $val >> $TMPCFGFILE
+    fi
+}
+
+append_quotes() {
+    local cfg="$1"
+    local field="$2"
+    local _label="$3"
+    local default="$4"
+    config_get val "$cfg" "$field" "$default"
+    if [ -n "$val" ]
+    then
+        append_prefix
+        echo "$_label" "\"$val\"" >> $TMPCFGFILE
+    fi
+}
+
+append_str() {
+    append_prefix
+    echo "$1" >> $TMPCFGFILE
+}
+
+begin_block() {
+    echo >> $TMPCFGFILE
+    append_str "$1"
+    PREFIX=`expr $PREFIX + 1`
+}
+
+end_block() {
+    PREFIX=`expr $PREFIX - 1`
+    append_str "End"
+}
+
+append_prefix() {
+    for i in `seq 1 $PREFIX`
+    do echo -n "  " >> $TMPCFGFILE
+    done
+}
+
+config_has() {
+    local cfg="$1"
+    local field="$2"
+    config_get val "$cfg" "$field"
+    [ -n "$val" ]
+}
+
+globals() {
+    local cfg="$1"
+    append_quotes "$cfg" user User
+    append_quotes "$cfg" group Group
+    append_quotes "$cfg" jail Jail
+    append_field "$cfg" daemon Daemon
+    append_field "$cfg" log_facility LogFacility
+    append_field "$cfg" log_level LogLevel
+    append_field "$cfg" ignore_case IgnoreCase
+    append_field "$cfg" dyn_scale DynScale
+    append_field "$cfg" alive Alive
+    append_field "$cfg" client Client
+    append_field "$cfg" timeout TimeOut
+    append_field "$cfg" connect_timeout ConnTO
+    append_field "$cfg" grace Grace
+    append_quotes "$cfg" ssl_engine SSLEngine
+    append_quotes "$cfg" control Control
+    
+    config_get rawfile "$cfg" raw
+    [ -n "$rawfile" ] && ( cat $rawfile >> $TMPCFGFILE )
+}
+
+CURRENT_LISTENER=
+
+listener() {
+    local cfg="$1"
+    CURRENT_LISTENER="$cfg"
+    
+    config_get proto "$cfg" proto
+    if [ "$proto" = "http" ]
+    then begin_block "ListenHTTP"
+    elif [ "$proto" = "https" ]
+    then begin_block "ListenHTTPS"
+    else 
+        echo "invalid proto $proto" >&2
+        exit 1
+    fi
+    
+    append_field "$cfg" address Address
+    append_field "$cfg" port Port
+    append_field "$cfg" xhttp xHTTP
+    append_field "$cfg" client Client
+    append_quotes "$cfg" check_url CheckURL
+    append_quotes "$cfg" err414 Err414
+    append_quotes "$cfg" err500 Err500
+    append_quotes "$cfg" err501 Err501
+    append_quotes "$cfg" err503 Err503
+    append_field "$cfg" max_request MaxRequest
+    append_quotes "$cfg" head_remove HeadRemove
+    append_quotes "$cfg" add_header AddHeader
+    append_field "$cfg" rewrite_location RewriteLocation
+    append_field "$cfg" log_level LogLevel
+    append_quotes "$cfg" cert Cert
+    append_field "$cfg" client_cert ClientCert
+    append_quotes "$cfg" ciphers Ciphers
+    append_quotes "$cfg" ca_list CAlist
+    append_quotes "$cfg" verify_list VerifyList 
+    append_quotes "$cfg" crl_list CRLlist
+    append_field "$cfg" no_https11 NoHTTPS11
+    
+    config_foreach service service
+    
+    end_block    
+}
+
+CURRENT_SERVICE=
+HAS_LISTENER=0
+
+check_has_listener() {
+    if [ "$1" = "$CURRENT_LISTENER" ]
+    then HAS_LISTENER=1
+    fi
+}
+
+service() {
+    local cfg="$1"
+    
+    CURRENT_SERVICE="$cfg"
+
+    HAS_LISTENER=0
+    
+    config_list_foreach "$cfg" listener check_has_listener
+    
+    if [ $HAS_LISTENER = 1 ]
+    then    
+        if ! config_has "$cfg" hostname
+        then service_hostname ""
+        else config_list_foreach "$cfg" hostname service_hostname
+        fi
+    fi
+}
+
+service_hostname() {
+    local cfg="$CURRENT_SERVICE"
+    local hostname="$1"
+    
+    begin_block "Service"
+    
+    if [ -n "$hostname" ]
+    then append_str "HeadRequire \"Host: $1\""
+    fi
+    
+    append_quotes "$cfg" url URL
+    append_field "$cfg" ignore_case IgnoreCase
+    append_field "$cfg" dyn_scale DynScale
+    append_quotes "$cfg" head_require HeadRequire
+    append_quotes "$cfg" head_deny HeadDeny
+
+    config_get cfg_f "$cfg" force_listener
+    if [ -n "$cfg_f" ] && [ "$cfg_f" != "$CURRENT_LISTENER" ] 
+    then
+        config_get proto "$cfg_f" proto
+        config_get port "$cfg_f" port 80
+        append_str "Redirect 301 \"$proto://$hostname:$port\""
+    else
+        append_field "$cfg" redirect Redirect
+        config_list_foreach "$cfg" backend backend
+        config_list_foreach "$cfg" emergency emergency
+        config_list_foreach "$cfg" session session    
+    fi
+    
+    end_block
+}
+
+backend() {
+    backend_emergency "$1" "Backend"
+}
+
+emergency() {
+    backend_emergency "$1" "Emergency"
+}
+
+backend_emergency() {
+    local cfg="$1"
+
+    config_get addrs "$cfg" address
+    config_get ports "$cfg" port
+    
+    for addr in $addrs
+    do     for port in $ports
+        do
+            begin_block "$2"    
+            
+            append_str "Address $addr"
+            append_str "Port $port"
+            append_quotes "$cfg" https HTTPS 
+            append_field "$cfg" priority Priority
+            append_field "$cfg" timeout TimeOut
+            append_field "$cfg" connto ConnTO
+            append_field "$cfg" ha_port HAport    
+            
+            end_block
+        done
+    done
+}
+
+session() {
+    local cfg="$1"
+    
+    begin_block "Session"
+    
+    append_field "$cfg" type Type
+    append_field "$cfg" ttl TTL
+    append_quotes "$cfg" id ID
+    
+    end_block
+}
+
+generate_config() {
+    config_load pound
+    echo "# auto-generated from /etc/config/pound" > $TMPCFGFILE    
+    config_foreach globals pound
+    config_foreach listener listener
+    mv "$TMPCFGFILE" "$CFGFILE"
+}
Index: feeds/packages/net/pound/files/pound.conf
===================================================================
--- feeds/packages/net/pound/files/pound.conf    (revision 0)
+++ feeds/packages/net/pound/files/pound.conf    (working copy)
@@ -0,0 +1,63 @@
+# UCI configuration file info for pound
+# Most configuration options map directly to directives described in pound(8).
+# For multi-parameter directives, enclose all parameters in ' ', e.g.
+#  Redirect 301 "google.com"
+# should be
+#  redirect '301 "google.com"'
+
+
+config pound
+# Uncomment and edit the next line to use a conventional pound config file:
+#    option raw '/etc/pound.cfg' # do not forget to comment out all other 
sections
+
+# possible options alike to those in pound(8), Global Directives are: 
+#  user group jail daemon log_facility log_level ignore_case dyn_scale 
+#  alive client timeout connect_timeout grace ssl_engine control
+
+config listener 'listener_1'
+    option proto http        # or https
+
+# possible options alike to those in pound(8), HTTP Listener and HTTPS 
Listener are:
+#  address port xhttp client check_url err414 err500 err501 err503 
+#  max_request head_remove add_header rewrite_location rewrite_destination
+#  log_level redirect
+# only for proto https
+#  cert client_cert ciphers ca_list verify_list crl_list no_https11
+
+config service
+# possible options alike to those in pound(8), Service are:
+#  url ignore_case head_require head_deny dyn_scale redirect
+
+# list hostname 'hostname1.com'        # service will match only for requests 
that have a Host:
+                    # header that matches one of the items in this list
+                    
+  list listener 'listener_1'
+  list listener 'listener_2' 
+  
+#  option force_listener 'listener_1'   # if list hostname is not empty, 
+                    # this will redirect with 301 to the given listener
+
+  list backend 'backend_name'
+  list backend 'backend_name_1'
+  list emergency 'emergency_backend_name'
+  list emergency 'emergency_backend_name_1'
+  
+  list session 'session_1'
+  list session 'session_2'
+
+config backend 'backend_name'
+# possible options alike to pound(8), section BackEnd are:
+#  address port https priority timeout connto ha_port
+
+#  address and port may be lists in which case a back-end will be 
+#  considered for every combination thereof
+
+config emergency 'emergency_backend_name'
+# possible options alike to pound(8), section Emergency are:
+#  address port
+
+#  address and port may be lists as for regular backends
+
+config session 'session_1'
+# possible options alike to pound(8), section Session are:
+#  type ttl id                                           
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to