This repository has been archived on 2024-07-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Gitea 64bf10ea8a committing changes in /etc after apt run
Package changes:
-adduser 3.118 all
+adduser 3.134 all
-amavisd-new 1:2.11.1-5 all
+amavisd-new 1:2.13.0-3 all
-apt-show-versions 0.22.12 all
-apt-transport-https 2.2.4 all
+apt-show-versions 0.22.13+nmu1 all
+apt-transport-https 2.6.1 all
-base-files 11.1+deb11u7 amd64
+base-files 12.4+deb12u1 amd64
-bash-completion 1:2.11-2 all
-bc 1.07.1-2+b2 amd64
+bash-completion 1:2.11-6 all
+bc 1.07.1-3+b1 amd64
-ca-certificates 20210119 all
+ca-certificates 20230311 all
-cloud-guest-utils 0.31-2 all
+cloud-guest-utils 0.33-1 all
-console-setup 1.205 all
-console-setup-linux 1.205 all
+console-setup 1.221 all
+console-setup-linux 1.221 all
-debconf 1.5.77 all
-debconf-i18n 1.5.77 all
-debian-archive-keyring 2021.1.1+deb11u1 all
-debian-faq 10.1 all
+debconf 1.5.82 all
+debconf-i18n 1.5.82 all
+debian-archive-keyring 2023.3 all
+debian-faq 11.1 all
-debsums 3.0.2 all
-dictionaries-common 1.28.4 all
+debsums 3.0.2.1 all
+dictionaries-common 1.29.5 all
-discover-data 2.2013.01.11+nmu1 all
-distro-info-data 0.51+deb11u3 all
-dkms 2.8.4-3 all
+discover-data 2.2013.01.13 all
+distro-info-data 0.58 all
+dkms 3.0.10-8+deb12u1 all
-dns-root-data 2021011101 all
-dnsutils 1:9.16.42-1~deb11u1 all
-doc-debian 6.5 all
+dns-root-data 2023010101 all
+dnsutils 1:9.18.16-1~deb12u1 all
+doc-debian 11.3+nmu1 all
-emacsen-common 3.0.4 all
-etckeeper 1.18.16-1 all
-fail2ban 0.11.2-2 all
+emacsen-common 3.0.5 all
+etckeeper 1.18.20-1 all
+fail2ban 1.0.2-2 all
-fontconfig-config 2.13.1-4.2 all
-fonts-dejavu-core 2.37-2 all
+fontconfig-config 2.14.1-4 amd64
+fonts-dejavu-core 2.37-6 all
-gdbm-l10n 1.19-2 all
+gdbm-l10n 1.23-3 all
-geoip-database 20191224-3 all
+geoip-database 20230203-1 all
-imagemagick 8:6.9.11.60+dfsg-1.3+deb11u1 amd64
-imagemagick-6-common 8:6.9.11.60+dfsg-1.3+deb11u1 all
+imagemagick 8:6.9.11.60+dfsg-1.6 amd64
+imagemagick-6-common 8:6.9.11.60+dfsg-1.6 all
-init 1.60 amd64
+init 1.65.2 amd64
-initramfs-tools 0.140 all
-initramfs-tools-core 0.140 all
-installation-report 2.78 all
+initramfs-tools 0.142 all
+initramfs-tools-core 0.142 all
+installation-report 2.89 all
-isc-dhcp-common 4.4.1-2.3+deb11u2 amd64
-iso-codes 4.6.0-1 all
+isc-dhcp-common 4.4.3-P1-2 amd64
+iso-codes 4.15.0-1 all
-keyboard-configuration 1.205 all
-klibc-utils 2.0.8-6.1 amd64
+keyboard-configuration 1.221 all
+klibc-utils 2.0.12-1 amd64
-krb5-locales 1.18.3-6+deb11u3 all
+krb5-locales 1.20.1-2 all
-libalgorithm-merge-perl 0.08-3 all
+libalgorithm-merge-perl 0.08-5 all
-libattr1 1:2.4.48-6 amd64
-libaudit-common 1:3.0-2 all
+libattr1 1:2.5.1-4 amd64
+libaudit-common 1:3.0.9-1 all
-libauthen-sasl-perl 2.1600-1.1 all
+libauthen-sasl-perl 2.1600-3 all
-libblas3 3.9.0-3 amd64
+libblas3 3.11.0-2 amd64
-libbrotli1 1.0.9-2+b2 amd64
+libbrotli1 1.0.9-2+b6 amd64
-libc-l10n 2.31-13+deb11u6 all
+libc-l10n 2.36-9+deb12u1 all
-libcgi-pm-perl 4.51-1 all
+libcgi-pm-perl 4.55-1 all
-libcom-err2 1.46.2-2 amd64
+libcom-err2 1.47.0-2 amd64
-libconfig-inifiles-perl 3.000003-1 all
-libconvert-binhex-perl 1.125-1 all
+libconfig-inifiles-perl 3.000003-2 all
+libconvert-binhex-perl 1.125-3 all
-libcrack2 2.9.6-3.4 amd64
+libcrack2 2.9.6-5+b1 amd64
-libctf-nobfd0 2.35.2-2 amd64
+libctf-nobfd0 2.40-2 amd64
-libdate-manip-perl 6.83-1 all
-libdatrie1 0.2.13-1 amd64
+libdate-manip-perl 6.91-1 all
+libdatrie1 0.2.13-2+b1 amd64
-libdebconfclient0 0.260 amd64
-libdeflate0 1.7-1 amd64
+libdebconfclient0 0.270 amd64
+libdeflate0 1.14-1 amd64
-libdigest-hmac-perl 1.03+dfsg-2.1 all
+libdigest-hmac-perl 1.04+dfsg-2 all
-libencode-locale-perl 1.05-1.1 all
-liberror-perl 0.17029-1 all
-libestr0 0.1.10-2.1+b1 amd64
+libencode-locale-perl 1.05-3 all
+liberror-perl 0.17029-2 all
+libestr0 0.1.11-1 amd64
-libexpat1 2.2.10-2+deb11u5 amd64
+libexpat1 2.5.0-1 amd64
-libfastjson4 0.99.9-1 amd64
+libfastjson4 1.2304.0-1 amd64
-libfribidi0 1.0.8-2+deb11u1 amd64
+libfribidi0 1.0.8-2.1 amd64
-libglib2.0-data 2.66.8-1 all
-libgmp10 2:6.2.1+dfsg-1+deb11u1 amd64
+libglib2.0-data 2.74.6-2 all
+libgmp10 2:6.2.1+dfsg1-1.1 amd64
-libhogweed6 3.7.3-1 amd64
+libhogweed6 3.8.1-2 amd64
-libhtml-tagset-perl 3.20-4 all
-libhtml-template-perl 2.97-1.1 all
-libhttp-date-perl 6.05-1 all
+libhtml-tagset-perl 3.20-6 all
+libhtml-template-perl 2.97-2 all
+libhttp-date-perl 6.05-2 all
-libidn2-0 2.3.0-5 amd64
+libidn2-0 2.3.3-1+b1 amd64
-libio-html-perl 1.004-2 all
-libio-multiplex-perl 1.16-1.1 all
-libio-socket-inet6-perl 2.72-2.1 all
-libio-socket-ssl-perl 2.069-1 all
+libio-html-perl 1.004-3 all
+libio-multiplex-perl 1.16-3 all
+libio-socket-inet6-perl 2.73-1 all
+libio-socket-ssl-perl 2.081-2 all
-libisl23 0.23-1 amd64
+libisl23 0.25-1 amd64
-libjbig0 2.1-3.1+b2 amd64
-libjbig2dec0 0.19-2 amd64
+libjbig0 2.1-6.1 amd64
+libjbig2dec0 0.19-3 amd64
-libjpeg62-turbo 1:2.0.6-4 amd64
+libjpeg62-turbo 1:2.1.5-2 amd64
-libjs-jquery 3.5.1+dfsg+~3.5.5-7 all
+libjs-jquery 3.6.1+dfsg+~3.5.14-1 all
-libjson-perl 4.03000-1 all
+libjson-perl 4.10000-1 all
-libjxr-tools 1.1-6+b1 amd64
-libjxr0 1.1-6+b1 amd64
+libjxr-tools 1.2~git20170615.f752187-5 amd64
+libjxr0 1.2~git20170615.f752187-5 amd64
-libkeyutils1 1.6.1-2 amd64
-libklibc 2.0.8-6.1 amd64
+libkeyutils1 1.6.3-2 amd64
+libklibc 2.0.12-1 amd64
-liblcms2-2 2.12~rc1-2 amd64
+liblcms2-2 2.14-2 amd64
-libldap-common 2.4.57+dfsg-3+deb11u1 all
+libldap-common 2.5.13+dfsg-5 all
-liblognorm5 2.0.5-1.1 amd64
+liblognorm5 2.0.6-4 amd64
-liblua5.1-0 5.1.5-8.1+b3 amd64
+liblua5.1-0 5.1.5-9 amd64
-liblwp-mediatypes-perl 6.04-1 all
-liblz4-1 1.9.3-2 amd64
+liblwp-mediatypes-perl 6.04-2 all
+liblz4-1 1.9.4-1 amd64
-libmagickwand-6.q16-6 8:6.9.11.60+dfsg-1.3+deb11u1 amd64
-libmail-authenticationresults-perl 2.20210112-1 all
-libmail-dkim-perl 1.20200907-1 all
-libmailtools-perl 2.21-1 all
+libmagickwand-6.q16-6 8:6.9.11.60+dfsg-1.6 amd64
+libmail-authenticationresults-perl 2.20230112-1 all
+libmail-dkim-perl 1.20230212-1 all
+libmailtools-perl 2.21-2 all
-libmime-tools-perl 5.509-1 all
+libmime-tools-perl 5.510-1 all
-libmpc3 1.2.0-1 amd64
+libmpc3 1.3.1-1 amd64
-libmpfr6 4.1.0-3 amd64
-libmspack0 0.10.1-2 amd64
+libmpfr6 4.2.0-1 amd64
+libmspack0 0.11-1 amd64
-libnet-cidr-lite-perl 0.22-1 all
-libnet-cidr-perl 0.20-1 all
-libnet-dns-perl 1.29-1 all
+libnet-cidr-lite-perl 0.22-2 all
+libnet-cidr-perl 0.21-2 all
+libnet-dns-perl 1.36-1 all
-libnet-ip-perl 1.26-2 all
+libnet-ip-perl 1.26-3 all
-libnet-rblclient-perl 0.5-3 all
-libnet-server-perl 2.009-2 all
-libnet-smtp-ssl-perl 1.04-1 all
-libnet-snmp-perl 6.0.1-6 all
+libnet-rblclient-perl 0.5-4 all
+libnet-server-perl 2.013-2 all
+libnet-smtp-ssl-perl 1.04-2 all
+libnet-snmp-perl 6.0.1-7 all
-libnetfilter-conntrack3 1.0.8-3 amd64
+libnetfilter-conntrack3 1.0.9-3 amd64
-libnettle8 3.7.3-1 amd64
+libnettle8 3.8.1-2 amd64
-libnfnetlink0 1.0.1-3+b1 amd64
+libnfnetlink0 1.0.2-2 amd64
-libnghttp2-14 1.43.0-1 amd64
+libnghttp2-14 1.52.0-1 amd64
-libonig5 6.9.6-1.1 amd64
+libonig5 6.9.8-1 amd64
-libpam-pwquality 1.4.4-1 amd64
-libpam-runtime 1.4.0-9+deb11u1 all
+libpam-pwquality 1.4.5-1+b1 amd64
+libpam-runtime 1.5.2-6 all
-libparse-syslog-perl 1.10-3.1 all
+libparse-syslog-perl 1.10-4 all
-libperl4-corelibs-perl 0.004-2 all
+libperl4-corelibs-perl 0.004-3 all
-libpixman-1-0 0.40.0-1.1~deb11u1 amd64
+libpixman-1-0 0.42.2-1 amd64
-libpng16-16 1.6.37-3 amd64
+libpng16-16 1.6.39-2 amd64
-libprotobuf-c1 1.3.3-1+b2 amd64
+libprotobuf-c1 1.4.1-1+b1 amd64
-libpwquality-common 1.4.4-1 all
+libpwquality-common 1.4.5-1 all
-libsasl2-modules-db 2.1.27+dfsg-2.1+deb11u1 amd64
-libseccomp2 2.5.1-1+deb11u1 amd64
+libsasl2-modules-db 2.1.28+dfsg-10 amd64
+libseccomp2 2.5.4-1+b3 amd64
-libsensors-config 1:3.6.0-7 all
+libsensors-config 1:3.6.0-7.1 all
-libsigsegv2 2.13-1 amd64
+libsigsegv2 2.14-1 amd64
-libstemmer0d 2.1.0-1 amd64
+libstemmer0d 2.2.0-2 amd64
-libtasn1-6 4.16.0-2+deb11u1 amd64
+libtasn1-6 4.19.0-2 amd64
-libtext-wrapi18n-perl 0.06-9 all
-libtfm1 0.13-4 amd64
-libthai-data 0.1.28-3 all
-libthai0 0.1.28-3 amd64
+libtext-wrapi18n-perl 0.06-10 all
+libtfm1 0.13.1-1 amd64
+libthai-data 0.1.29-1 all
+libthai0 0.1.29-1 amd64
-libtirpc-common 1.3.1-1+deb11u1 all
+libtirpc-common 1.3.3+ds-1 all
-libusb-1.0-0 2:1.0.24-3 amd64
+libusb-1.0-0 2:1.0.26-1 amd64
-libuuid1 2.36.1-8+deb11u1 amd64
+libuuid1 2.38.1-5+b1 amd64
-libx11-data 2:1.7.2-1+deb11u1 all
+libx11-data 2:1.8.4-2+deb12u1 all
-libxcb-render0 1.14-3 amd64
-libxcb-shm0 1.14-3 amd64
-libxcb1 1.14-3 amd64
+libxcb-render0 1.15-1 amd64
+libxcb-shm0 1.15-1 amd64
+libxcb1 1.15-1 amd64
-libxext6 2:1.3.3-1.1 amd64
+libxext6 2:1.3.4-1+b1 amd64
-libxmuu1 2:1.1.2-2+b3 amd64
+libxmuu1 2:1.1.3-3 amd64
-libxrender1 1:0.9.10-1 amd64
+libxrender1 1:0.9.10-1.1 amd64
-libxxhash0 0.8.0-2 amd64
-libyaml-0-2 0.2.2-1 amd64
+libxxhash0 0.8.1-1 amd64
+libyaml-0-2 0.2.5-1 amd64
-linux-base 4.6 all
+linux-base 4.9 all
-linux-libc-dev 5.10.179-5 amd64
+linux-libc-dev 6.1.38-4 amd64
-logwatch 7.5.5-1 all
+logwatch 7.7-1 all
-lsb-release 11.1.0 all
+lsb-release 12.0-1 all
-lua-bitop 1.0.2-5 amd64
-lua-cjson 2.1.0+dfsg-2.1 amd64
-lua-lpeg 1.0.2-1 amd64
-mailcap 3.69 all
+lua-bitop 1.0.2-7 amd64
+lua-cjson 2.1.0+dfsg-2.2 amd64
+lua-lpeg 1.0.2-2 amd64
+mailcap 3.70+nmu1 all
-manpages 5.10-1 all
-manpages-dev 5.10-1 all
+manpages 6.03-2 all
+manpages-dev 6.03-2 all
-mariadb-common 1:10.9.8+maria~deb11 all
+mariadb-common 1:10.11.3-1 all
-mawk 1.3.4.20200120-2 amd64
-media-types 4.0.0 all
+mawk 1.3.4.20200120-3.1 amd64
+media-types 10.0.0 all
-netbase 6.3 all
-netcat-traditional 1.10-46 amd64
+netbase 6.4 all
+netcat-traditional 1.10-47 amd64
-os-prober 1.79 amd64
+os-prober 1.81 amd64
-pci.ids 0.0~2021.02.08-1 all
+pci.ids 0.0~2023.04.11-1 all
-php-common 2:93+0~20230409.46+debian11~1.gbpdb4dcc all
-php8.1 8.1.22-1+0~20230815.49+debian11~1.gbp8da143 all
+php-common 2:93+0~20230409.46+debian12~1.gbpdb4dcc all
+php8.1 8.1.22-1+0~20230815.49+debian12~1.gbp8da143 all
-php8.1-igbinary 3.2.14-1+0~20230618.45+debian11~1.gbpcc1dca amd64
+php8.1-igbinary 3.2.14-1+0~20230618.45+debian12~1.gbpcc1dca amd64
-php8.1-memcache 8.2-2+0~20230716.32+debian11~1.gbpbf55c7 amd64
+php8.1-memcache 8.2-2+0~20230716.32+debian12~1.gbpbf55c7 amd64
-php8.1-msgpack 1:2.2.0~rc2-3+0~20230620.38+debian11~1.gbp2bc756 amd64
+php8.1-msgpack 1:2.2.0~rc2-3+0~20230620.38+debian12~1.gbp2bc756 amd64
-poppler-data 0.4.10-1 all
+poppler-data 0.4.12-1 all
-postgrey 1.36-5.2 all
-powermgmt-base 1.36 all
+postgrey 1.37-2 all
+powermgmt-base 1.37 all
-publicsuffix 20220811.1734-0+deb11u1 all
+publicsuffix 20230209.2326-1 all
-python-apt-common 2.2.1 all
+python-apt-common 2.6.0 all
-python3-attr 20.3.0-1 all
-python3-blinker 1.4+dfsg1-0.3 all
-python3-certifi 2020.6.20-1 all
+python3-attr 22.2.0-1 all
+python3-blinker 1.5-1 all
+python3-certifi 2022.9.24-1 all
-python3-chardet 4.0.0-1 all
-python3-configobj 5.0.6-4 all
+python3-chardet 5.1.0+dfsg-2 all
+python3-configobj 5.0.8-1 all
-python3-debconf 1.5.77 all
+python3-debconf 1.5.82 all
-python3-debianbts 3.1.0 all
-python3-distro-info 1.0 all
+python3-debianbts 4.0.1 all
+python3-distro-info 1.5 all
-python3-idna 2.10-1 all
-python3-importlib-metadata 1.6.0-2 all
+python3-idna 3.3-1 all
+python3-importlib-metadata 4.12.0-1 all
-python3-json-pointer 2.0-2 all
-python3-jsonpatch 1.25-3 all
+python3-json-pointer 2.3-2 all
+python3-jsonpatch 1.32-2 all
-python3-jwt 1.7.1-2 all
+python3-jwt 2.6.0-1 all
-python3-more-itertools 4.2.0-3 all
-python3-oauthlib 3.1.0-2 all
-python3-pkg-resources 52.0.0-4 all
+python3-more-itertools 8.10.0-2 all
+python3-oauthlib 3.2.2-1 all
+python3-pkg-resources 66.1.1-1 all
-python3-pyinotify 0.9.6-1.3 all
+python3-pyinotify 0.9.6-2 all
-python3-pysimplesoap 1.16.2-3 all
-python3-reportbug 7.10.3+deb11u1 all
+python3-pysimplesoap 1.16.2-5 all
+python3-reportbug 12.0.0 all
-python3-setuptools 52.0.0-4 all
-python3-six 1.16.0-2 all
+python3-setuptools 66.1.1-1 all
+python3-six 1.16.0-4 all
-python3-urllib3 1.26.5-1~exp1 all
+python3-urllib3 1.26.12-1 all
-python3-zipp 1.0.0-3 all
+python3-zipp 1.0.0-6 all
-rake 13.0.3-1 all
-readline-common 8.1-1 all
+rake 13.0.6-3 all
+readline-common 8.2-1.3 all
-reportbug 7.10.3+deb11u1 all
+reportbug 12.0.0 all
-rkhunter 1.4.6-9 all
+rkhunter 1.4.6-11 all
-ruby-minitest 5.13.0-1 all
-ruby-net-telnet 0.1.1-2 all
-ruby-power-assert 1.1.7-2 all
-ruby-rubygems 3.2.5-2 all
-ruby-test-unit 3.3.9-1 all
-ruby-xmlrpc 0.3.0-2 all
+ruby-minitest 5.17.0-1 all
+ruby-net-telnet 0.2.0-1 all
+ruby-power-assert 2.0.3-1 all
+ruby-rubygems 3.3.15-2 all
+ruby-test-unit 3.5.7-1 all
+ruby-xmlrpc 0.3.2-2 all
-runit-helper 2.10.3 all
+runit-helper 2.15.2 all
-sensible-utils 0.0.14 all
+sensible-utils 0.0.17+nmu1 all
-ssl-cert 1.1.0+nmu1 all
+ssl-cert 1.1.2 all
-systemd-sysv 247.3-7+deb11u4 amd64
+systemd-sysv 252.12-1~deb12u1 amd64
-task-english 3.68+deb11u1 all
-task-ssh-server 3.68+deb11u1 all
-tasksel 3.68+deb11u1 all
-tasksel-data 3.68+deb11u1 all
+task-english 3.73 all
+task-ssh-server 3.73 all
+tasksel 3.73 all
+tasksel-data 3.73 all
-tzdata 2021a-1+deb11u10 all
-ucf 3.0043 all
+tzdata 2023c-5 all
+ucf 3.0043+nmu1 all
-unattended-upgrades 2.8 all
+unattended-upgrades 2.9.1+nmu3 all
-unhide.rb 22-5 all
+unhide.rb 22-6 all
-usbutils 1:013-3 amd64
+usbutils 1:014-1 amd64
-wamerican 2019.10.06-1 all
+wamerican 2020.12.07-2 all
-xkb-data 2.29-2 all
+xkb-data 2.35.1-1 all
-zlib1g 1:1.2.11.dfsg-2+deb11u2 amd64
+zlib1g 1:1.2.13.dfsg-1 amd64
2023-08-16 10:06:48 +02:00

274 lines
6.8 KiB
Bash
Executable File

#!/bin/sh
### BEGIN INIT INFO
# Provides: fail2ban
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $time $network $syslog $named iptables firehol shorewall ipmasq arno-iptables-firewall iptables-persistent ferm ufw
# Should-Stop: $network $syslog $named iptables firehol shorewall ipmasq arno-iptables-firewall iptables-persistent ferm ufw
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop fail2ban
# Description: Start/stop fail2ban, a daemon scanning the log files and
# banning potential attackers.
### END INIT INFO
# Author: Aaron Isotton <aaron@isotton.com>
# Modified: by Yaroslav Halchenko <debian@onerussian.com>
# reindented + minor corrections + to work on sarge without modifications
# Modified: by Glenn Aaldering <glenn@openvideo.nl>
# added exit codes for status command
# Modified: by Juan Karlo de Guzman <jkarlodg@gmail.com>
# corrected the DAEMON's path and the SOCKFILE
# rename this file: (sudo) mv /etc/init.d/fail2ban.init /etc/init.d/fail2ban
# same with the logrotate file: (sudo) mv /etc/logrotate.d/fail2ban.logrotate /etc/logrotate.d/fail2ban
#
PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin"
DESC="Authentication failure monitor"
NAME="fail2ban"
# fail2ban-client is not a daemon itself but starts a daemon and
# loads its with configuration
DAEMON="/usr/bin/$NAME-client"
SCRIPTNAME="/etc/init.d/$NAME"
# Ad-hoc way to parse out socket file name
SOCKFILE="$(grep -h '^[^#]*socket *=' "/etc/$NAME/$NAME.conf" "/etc/$NAME/$NAME.local" 2>/dev/null \
| tail -n 1 | sed -e 's/.*socket *= *//g' -e 's/ *$//g')"
[ -z "$SOCKFILE" ] && SOCKFILE="/run/fail2ban.sock"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Run as root by default.
FAIL2BAN_USER="root"
# Read configuration variable file if it is present
[ -r "/etc/default/$NAME" ] && . "/etc/default/$NAME"
DAEMON_ARGS="$FAIL2BAN_OPTS"
# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS
# Predefine what can be missing from lsb source later on -- necessary to run
# on sarge. Just present it in a bit more compact way from what was shipped
log_daemon_msg()
{
[ -z "$1" ] && return 1
echo -n "$1:"
[ -z "$2" ] || echo -n " $2"
}
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
# Actually has to (>=2.0-7) present in sarge. log_daemon_msg is predefined
# so we must be ok
. /lib/lsb/init-functions
#
# Shortcut function for abnormal init script interruption
#
report_bug()
{
echo "$*"
echo "Please submit a bug report to Debian BTS (reportbug fail2ban)"
exit 1
}
#
# Helper function to check if socket is present, which is often left after
# abnormal exit of fail2ban and needs to be removed
#
check_socket()
{
# Return
# 0 if socket is present and readable
# 1 if socket file is not present
# 2 if socket file is present but not readable
# 3 if socket file is present but is not a socket
[ -e "$SOCKFILE" ] || return 1
[ -r "$SOCKFILE" ] || return 2
[ -S "$SOCKFILE" ] || return 3
return 0
}
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_status && return 1
if [ -e "$SOCKFILE" ]; then
log_failure_msg "Socket file $SOCKFILE is present"
[ "$1" = force-start ] \
&& log_success_msg "Starting anyway as requested" \
|| return 2
DAEMON_ARGS="$DAEMON_ARGS -x"
fi
# Assure that /run/fail2ban exists
[ -d /run/fail2ban ] || mkdir -p /run/fail2ban
if [ "$FAIL2BAN_USER" != root ]; then
# Make the socket directory, IP lists and fail2ban log
# files writable by fail2ban
chown "$FAIL2BAN_USER" /run/fail2ban
# Create the logfile if it doesn't exist
touch /var/log/fail2ban.log
chown "$FAIL2BAN_USER" /var/log/fail2ban.log
find /proc/net/xt_recent -name "fail2ban-*" -exec chown "$FAIL2BAN_USER" "{}" ";"
fi
# $DAEMON_ARGS need to be expanded possibly with multiple or no options
# shellcheck disable=SC2086
start-stop-daemon --start --quiet --chuid "$FAIL2BAN_USER" --exec "$DAEMON" -- \
$DAEMON_ARGS start >/dev/null \
|| return 2
return 0
}
#
# Function that checks the status of fail2ban and returns
# corresponding code
#
do_status()
{
$DAEMON ping >/dev/null 2>&1
return "$?"
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
$DAEMON status >/dev/null 2>&1 || return 1
$DAEMON stop >/dev/null || return 2
# now we need actually to wait a bit since it might take time
# for server to react on client's stop request. Especially
# important for restart command on slow boxes
count=1
while do_status && [ "$count" -lt 60 ]; do
sleep 1
count="$((count + 1))"
done
[ "$count" -lt 60 ] || return 3 # failed to stop
return 0
}
#
# Function to reload configuration
#
do_reload()
{
"$DAEMON" reload >/dev/null && return 0 || return 1
return 0
}
# yoh:
# shortcut function to don't duplicate case statements and to don't use
# bashisms (arrays). Fixes #368218
#
log_end_msg_wrapper()
{
if [ "$1" != 0 ] && [ "$1" != "$2" ]; then
value="1"
else
value="0"
fi
if [ "$3" != no ]; then
log_end_msg "$value"
fi
if [ "$value" != 0 ]; then
exit "$1"
fi
}
command="$1"
case "$command" in
start|force-start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start "$command"
log_end_msg_wrapper "$?" 255 "$VERBOSE"
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
log_end_msg_wrapper "$?" 255 "$VERBOSE"
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
log_end_msg_wrapper "$?" 0 always
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg "$?"
;;
status)
log_daemon_msg "Status of $DESC"
do_status
case "$?" in
0)
log_success_msg " $NAME is running"
;;
255)
check_socket
case "$?" in
1)
log_failure_msg " $NAME is not running" && exit 3
;;
0)
log_failure_msg " $NAME is not running but $SOCKFILE exists" && exit 3
;;
2)
log_failure_msg " $SOCKFILE not readable, status of $NAME is unknown" && exit 3
;;
3)
log_failure_msg " $SOCKFILE exists but not a socket, status of $NAME is unknown" && exit 3
;;
*)
report_bug "Unknown return code from $NAME:check_socket." && exit 4
;;
esac
;;
*)
report_bug "Unknown $NAME status code" && exit 4
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|force-start|stop|restart|force-reload|status}" 1>&2
exit 3
;;
esac
: