#!/bin/sh # Slackware Package Build Script for fail2ban # Home Page http://www.fail2ban.org/wiki/index.php/Main_Page # Git Hub: https://github.com/fail2ban/fail2ban/ # Copyright (c) 2008-2011, Nishant Limbachia, Hoffman Estates, IL, USA # # 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 script must retain the above copyright notice, # this list of conditions and the following disclaimer. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "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 COPYRIGHT OWNER OR # CONTRIBUTORS 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. # default settings PACKAGE="fail2ban" PACKAGE_EXT="gz" VERSION=${VERSION:=1.1.0} BUILD=${BUILD:=1} if [ -f ~/.slackbuildrc ]; then . ~/.slackbuildrc elif [ -f ../../runtime/slackbuildrc ]; then . ../../runtime/slackbuildrc fi # If fail2ban is installed on the build system, it will be destroyed during this build. # So refuse to run this build if so. SHORT="$(package_name $PACKAGE)" found=0 for installed_package in /var/log/packages/$SHORT* ; do if [ "$(package_name $installed_package)" = "$SHORT" ]; then # found one echo "$(basename $installed_package) is installed on this system!" found=1 break fi done if [ $found == 1 ]; then echo "Build on a different machine or backup and uninstall it first." exit 1 fi check_required SRC="${VERSION}.tar.$PACKAGE_EXT" URL="https://github.com/fail2ban/fail2ban/archive/refs/tags/$SRC" get_source $SRC $URL unpack_source $SRC fail2ban-${VERSION} # Replace /var/run with /run, but not in the top source directory find . -mindepth 2 -type f -exec sed -i -e 's|/var\(/run/fail2ban\)|\1|g' {} + || die echo "** Install fail2ban **" python3 -m pip install --no-warn-script-location . --root=$PKG echo "** Install finished **" # installing man pages mkdir -p $PKG/usr/man/man1 $PKG/usr/man/man5 install -m 0644 man/fail2ban-client.1 man/fail2ban-regex.1 man/fail2ban-server.1 man/fail2ban.1 $PKG/usr/man/man1 install -m 0644 man/jail.conf.5 $PKG/usr/man/man5 # move config files to .new ( cd $PKG/etc/fail2ban for file in $(ls *.conf); do mv $file "$file.new" done ) # install startup script install -D -m 0644 $CWD/rc.fail2ban $PKG/etc/rc.d/rc.fail2ban.new # install logrotate script install -D -m 0644 $CWD/fail2ban.logrotate $PKG/etc/logrotate.d/fail2ban.new install -D -m 0644 $CWD/paths-slackware.conf $PKG/etc/fail2ban/paths-slackware.conf.new # Duplicated docs rm -rf $PKG/usr/share $PKG/run mkdir -p $DOCS cp -a CONTRIBUTING.md COPYING ChangeLog DEVELOP FILTERS README* THANKS TODO $DOCS fixup_package $PKG # Clean up the extra stuff: set +u if [ "$1" = "--cleanup" ]; then rm -rf $TMP/$PACKAGE-$VERSION rm -rf $PKG fi