#!/bin/bash # # ossec.SlackBuild 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 2 of the License, or any later version. # # ossec.SlackBuild 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, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA # # default settings PACKAGE="ossec" PACKAGE_EXT="gz" VERSION=${VERSION:=3.6.0} BUILD=${BUILD:=2} if [ -f ~/.slackbuildrc ]; then . ~/.slackbuildrc elif [ -f ../../runtime/slackbuildrc ]; then . ../../runtime/slackbuildrc fi # Check for ossec accounts here if ! grep ^ossec: /etc/group 2>&1 > /dev/null; then groupadd -g 302 ossec fi if ! grep ^ossec: /etc/passwd 2>&1 > /dev/null; then useradd -d /var/ossec -s /bin/false -u 302 -g 302 -c "Ossec" ossec passwd -l ossec &>/dev/null fi if ! grep ^ossecm: /etc/passwd 2>&1 > /dev/null; then useradd -d /var/ossec -s /bin/false -u 303 -g 302 -c "Ossec" ossecm passwd -l ossecm &>/dev/null fi if ! grep ^ossecr: /etc/passwd 2>&1 > /dev/null; then useradd -d /var/ossec -s /bin/false -u 304 -g 302 -c "Ossec" ossecr passwd -l ossecr &>/dev/null fi check_required SRC="v$VERSION.tar.$PACKAGE_EXT" URL="https://github.com/ossec/ossec-hids/archive/${VERSION}.tar.gz" get_source $SRC $URL unpack_source $SRC ossec-hids-$VERSION ( cd src # Patch for the GCC version 10 -fno-common change. See # https://github.com/ossec/ossec-hids/pull/1875 cat $CWD/gcc-fno-common-3.6.0.patch | patch -p2 cat $CWD/makefile-3.6.0.patch | patch -p1 ) _instdir=/var/ossec export USER_NO_STOP=yes export USER_LANGUAGE=en export USER_INSTALL_TYPE=server export USER_DIR=$_instdir export USER_BINARYINSTALL=x export USE_GEOIP=0 export PCRE2_SYSTEM=yes export ZLIB_SYSTEM=yes . "$CWD/ossec.config" # load configuration # fix placement of ossec-init.conf mkdir -p $PKG/etc sed -i "s|^OSSEC_INIT.*|OSSEC_INIT=\"$PKG/etc/ossec-init.conf\"|" src/init/shared.sh cd src make clean make TARGET=$USER_INSTALL_TYPE USE_GEOIP=$USE_GEOIP cd .. #. "$CWD/ossec.config" USER_DIR="${PKG}${_instdir}" ./install.sh # fix DIRECTORY path in ossec-init.conf sed -i '/DIRECTORY=/c\DIRECTORY="/var/ossec"' "$PKG/etc/ossec-init.conf" ( cd $PKG/var/ossec/etc sed -i "s|\/tmp\/package-ossec||" ossec.conf mv ossec.conf ossec.conf.new mv internal_options.conf internal_options.conf.new touch local_decoder.xml.new chgrp ossec local_decoder.xml.new ) ( cd $PKG/var/ossec/rules mv local_rules.xml local_rules.xml.new ) # install rc initscript install -D -m755 $CWD/ossec.rc $PKG/etc/rc.d/init.d/ossec install -D -m755 $CWD/ossec.setup $PKG/var/lib/pkgtools/setup/setup.ossec install -D -m644 $CWD/ossec.logrotate $PKG/etc/logrotate.d/ossec mkdir -p $DOCS cp -a BUGS CONFIG CONTRIBUTORS INSTALL LICENSE *.md doc/* $DOCS rm -rf $DOCS/br $DOCS/pl fixup_package $PKG # Clean up the extra stuff: set +u if [ "$1" = "--cleanup" ]; then rm -rf $TMP/$PACKAGE-$VERSION rm -rf $PKG fi