0
This commit is contained in:
eleksir
2025-10-04 16:36:49 +03:00
parent 824969261a
commit e8b0196b15
9 changed files with 456 additions and 0 deletions

11
haproxy/README Normal file
View File

@@ -0,0 +1,11 @@
HAProxy is a free, very fast and reliable solution offering high
availability, load balancing, and proxying for TCP and HTTP-based
applications. It is particularly suited for very high traffic web sites.
Note that a default configuration file is no longer provided at
/etc/haproxy/haproxy.cfg. See /usr/doc/haproxy-*/examples
for some sample configuration files. The directory also contains
example files for logging.
The script supports optional variables for Lua, PCRE and QUIC.
See README.SLACKWARE for more information.

94
haproxy/README.SLACKWARE Normal file
View File

@@ -0,0 +1,94 @@
--------
Compiling, optional dependencies and variables
--------
This SlackBuild script supports additional variables.
1) Lua support
Lua is an optional dependency. Pass LUA=yes to this script
to enable Lua support.
2) Custom Perl Compatible Regular Expressions
Perl Compatible Regular Expressions version 2 without JIT
support is enabled by default. You can change this by passing
PCRE= to this script.
Currently supported settings are listed in the Makefile.
For example:
* Use PCRE=PCRE2_JIT to use libpcre2 with JIT support.
* Use PCRE=PCRE to use libpcre version 1.
You can also use the variables as they're written in the
Makefile, such as PCRE=USE_PCRE_JIT or PCRE=USE_PCRE=1.
The script will parse them correctly.
3) QUIC support (experimental)
Starting with version 2.6.0, HAProxy supports HTTP/3 over QUIC.
The QUIC support is currently experimental and requires QUICTLS.
OpenSSL package shipped with Slackware 15.0 is not compatible
with QUIC.
Pass QUIC=yes to this script to enable HTTP/3 support.
Check out these links for more information:
* https://github.com/quictls/
* https://www.haproxy.com/blog/announcing-haproxy-2-6/
--------
Logging
--------
If you want to enable logging, please first refer to HAProxy manual
on how to enable logging and how to select which events to log.
HAProxy log forwarding works fine with Slackware's sysklogd.
There are example files located in /usr/doc/haproxy-*/examples
The files are called syslog.example and logrotate.example.
You might want to add something like this to your haproxy.cfg file:
global
log /dev/log local0
Note that rotating logs does not require restarting HAProxy.
Instead, logrotate script should send a HUP signal to syslogger
when rotating. Example script is included in syslog.example.
Rotating has been tested with sysklogd (Slackware default) and
syslog-ng.
--------
Automatic starting/stopping upon system start/shutdown
--------
To start HAProxy automatically when system is booted,
add the following lines to /etc/rc.d/rc.local:
if [ -x /etc/rc.d/rc.haproxy ]; then
/etc/rc.d/rc.haproxy start
fi
To stop HAProxy on system shutdown, add following lines
to /etc/rc.d/rc.local_shutdown
if [ -x /etc/rc.d/rc.haproxy ]; then
/etc/rc.d/rc.haproxy stop
fi
--------
Privileges
--------
Like with the most rc scripts /etc/rc.d/rc.haproxy should be
run as root. You can easily drop process privileges by specifying
another user (and group) in the main configuration file.
Add something like this to haproxy.cfg:
global
user nobody
group nogroup

25
haproxy/doinst.sh Normal file
View File

@@ -0,0 +1,25 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
preserve_perms() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD ${NEW}.incoming
cat $NEW > ${NEW}.incoming
mv ${NEW}.incoming $NEW
fi
config $NEW
}
preserve_perms etc/rc.d/rc.haproxy.new

169
haproxy/haproxy.SlackBuild Normal file
View File

@@ -0,0 +1,169 @@
#!/bin/bash
# Slackware build script for haproxy
# Copyright 2018 T3slider <t3slider@gmail.com>
# All rights reserved.
#
# Copyright 2025 Badchay <badchay@protonmail.com>
# All rights reserved.
#
# Copyright 2025 Sergei Fedosoff <eleksir@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=haproxy
VERSION=${VERSION:-3.2.4}
BUILD=${BUILD:-1}
TAG=${TAG:-_EXs}
PKGTYPE=${PKGTYPE:-tgz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/$TAG}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
# This should work with Slackware-provided kernels, but you may wish to
# use 'generic' instead
TARGET=${TARGET:-linux-glibc}
# Include lua support? (Requires lua)
LUA=${LUA:-no}
# Perl Compatible Regular Expressions version 2 is enabled by default.
# You might want to use libpcre1 and/or JIT-enabled version instead.
PCRE=${PCRE:-PCRE2}
# Include QUIC (HTTP/3) support?
# This requires QUICTLS or wolfSSL.
QUIC=${QUIC:-no}
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
LUAOPT=""
if [ "$LUA" == "yes" ]; then
LUAOPT="USE_LUA=1"
else
LUAOPT="USE_LUA="
fi
PCREOPT=""
if [ "$PCRE" != "PCRE2" ]; then
PCREOPT=$(echo $PCRE | sed -e 's/USE_//' -e 's/=1//')
else
PCREOPT="PCRE2"
fi
QUICOPT=""
if [ "$QUIC" == "yes" ]; then
LUAOPT="USE_QUIC=1"
else
LUAOPT="USE_QUIC="
fi
make -j$(nproc) \
TARGET=$TARGET \
USE_$PCREOPT=1 \
$QUICOPT \
USE_OPENSSL=1 \
USE_ENGINE=1 \
USE_ZLIB=1 \
USE_NS=1 \
USE_PROMEX=1 \
$LUAOPT \
EXTRA=""
make install \
PREFIX=/usr \
MANDIR=/usr/man \
DOCDIR=/usr/doc/$PRGNAM-$VERSION \
EXTRA="" \
DESTDIR=$PKG
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
install -D -m 0644 $CWD/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new
cp -a CONTRIBUTING LICENSE MAINTAINERS README.md BRANCHES SUBVERS VERDATE VERSION examples \
$PKG/usr/doc/$PRGNAM-$VERSION
# If there's a CHANGELOG, installing at least part of the recent history
# is useful, but don't let it get totally out of control:
if [ -r CHANGELOG ]; then
head -n 1000 CHANGELOG > $PKG/usr/doc/$PRGNAM-$VERSION/CHANGELOG
touch -r CHANGELOG $PKG/usr/doc/$PRGNAM-$VERSION/CHANGELOG
fi
cp $CWD/{syslog.example,logrotate.example} $PKG/usr/doc/$PRGNAM-$VERSION/examples/
mkdir -p $PKG/etc/haproxy
mv $PKG/usr/doc/$PRGNAM-$VERSION/examples/errorfiles $PKG/etc/haproxy/errors
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE

10
haproxy/haproxy.info Normal file
View File

@@ -0,0 +1,10 @@
PRGNAM="haproxy"
VERSION="3.2.4"
HOMEPAGE="https://www.haproxy.org/"
DOWNLOAD="https://www.haproxy.org/download/3.2/src/haproxy-3.2.4.tar.gz"
MD5SUM="35a9600a063df8d85fd845dc330cb111"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="Badchay"
EMAIL="badchay@protonmail.com"

View File

@@ -0,0 +1,9 @@
/var/log/haproxy {
notifempty
weekly
missingok
rotate 4
postrotate
/bin/kill -HUP $(cat /run/syslogd.pid 2>/dev/null) 2>/dev/null || true
endscript
}

99
haproxy/rc.haproxy Normal file
View File

@@ -0,0 +1,99 @@
#!/bin/bash
#
# Slackware initialization script for HAProxy.
#
# This script was made by T3slider.
# Slight modifications by Badchay.
#
HAPROXY=/usr/sbin/haproxy
CONFIG=/etc/haproxy/haproxy.cfg
PIDFILE=/run/haproxy.pid
if [[ ! -f $CONFIG && "$1" == "start" ]]; then
echo "No configuration file found. Cannot continue."
echo "The script looks for the configuration file placed in $CONFIG"
exit 1
fi
start() {
if [ -r $PIDFILE ]; then
echo 'HAProxy is already running!'
return
else
echo "Starting HAProxy..."
$HAPROXY -f $CONFIG -D -p $PIDFILE
fi
}
stop() {
if [ ! -r $PIDFILE ]; then
echo 'HAProxy is not running!'
return
fi
echo "Soft-stopping HAProxy..."
kill -USR1 $(cat $PIDFILE)
# Even with the right permissions the PID file will not be removed...
rm -f $PIDFILE
}
force_stop() {
if [ ! -r $PIDFILE ]; then
echo 'HAProxy is not running!'
return
fi
echo "Hard-stopping HAProxy..."
kill $(cat $PIDFILE)
# Even with the right permissions the PID file will not be removed...
rm -f $PIDFILE
}
status() {
if [ ! -r $PIDFILE ]; then
echo "HAProxy is not running."
return
fi
PID=$(cat $PIDFILE)
if [ -z "$PID" ]; then
echo 'PID file is empty! HAProxy does not appear to be running, but there is a stale PID file.'
elif kill -0 $PID; then
echo "HAProxy is running."
else
echo "HAProxy is not running, but there is a stale PID file."
fi
}
checkconfig() {
$HAPROXY -c -q -V -f $CONFIG
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'force_stop')
force_stop
;;
'restart')
stop
start
;;
'force_restart')
force_stop
start
;;
'status')
status
;;
'checkconfig')
checkconfig
;;
*)
echo "Usage: $0 {start|stop|force_stop|restart|force_restart|status|checkconfig}"
exit 1
;;
esac

19
haproxy/slack-desc Normal file
View File

@@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
haproxy: haproxy (The Reliable, High Performance TCP/HTTP Load Balancer)
haproxy:
haproxy: HAProxy is a free, very fast and reliable reverse-proxy offering high
haproxy: availability, load balancing, and proxying for TCP and HTTP-based
haproxy: applications. It is particularly suited for very high traffic
haproxy: web sites and powers a significant portion of the world's most
haproxy: visited ones.
haproxy:
haproxy:
haproxy: Check out more information on https://www.haproxy.org/
haproxy:

20
haproxy/syslog.example Normal file
View File

@@ -0,0 +1,20 @@
# Note: If you enable local0 logging. You'll probably want to add
# something like local0.none to your /etc/syslogd.conf
#
# Otherwise the logs will be sent to your /var/log/messages file
# as well as the logfile specified below.
#
# An example would be to change the default line
#
# authpriv.none;cron.none;mail.none;news.none -/var/log/messages
# to
# authpriv.none;cron.none;mail.none;news.none;local0.none -/var/log/messages
#
# Move this file to /etc/syslog.d/ with .conf extension
# so syslog will load it automatically.
#
# Also remember to restart sysklogd
# sh /etc/rc.d/rc.syslog restart
#
local0.* -/var/log/haproxy