Install-Skript by CODEX
This commit is contained in:
1 parent
65a84206a5
commit
b404cfbdf3
4 files changed
+158
-30
No files matched your search
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
if [[ $(uname -s) != Linux ]] || (( EUID != 0 )); then
|
||||
echo 'Bitte auf einem Linux-Server mit sudo bash install.sh ausführen.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
if ! command -v apt-get >/dev/null || ! command -v systemctl >/dev/null; then
|
||||
echo 'Der Installer benötigt Debian oder Ubuntu mit systemd.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
required=(curl ipset iptables python3 flock cron logger)
|
||||
for command in "${required[@]}"; do
|
||||
if ! command -v "$command" >/dev/null; then
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates curl ipset iptables python3 util-linux cron
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
systemctl enable --now cron.service
|
||||
|
||||
install -o root -g root -m 0755 "$source_dir/do_persistant_bans.sh" /usr/local/sbin/bca-blocked-ips
|
||||
|
||||
cron_file=$(mktemp /etc/cron.d/.bca-blocked-ips.XXXXXXXX)
|
||||
trap 'rm -f -- "$cron_file"' EXIT
|
||||
cat >"$cron_file" <<'CRON'
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
@reboot root /usr/local/sbin/bca-blocked-ips 2>&1 | logger -t bca-blocked-ips
|
||||
*/15 * * * * root /usr/local/sbin/bca-blocked-ips 2>&1 | logger -t bca-blocked-ips
|
||||
CRON
|
||||
chown root:root "$cron_file"
|
||||
chmod 0644 "$cron_file"
|
||||
mv -f -- "$cron_file" /etc/cron.d/bca-blocked-ips
|
||||
|
||||
if /usr/local/sbin/bca-blocked-ips; then
|
||||
echo 'Die Sperrlisten sind aktiv. Cron synchronisiert alle 15 Minuten und beim Start.'
|
||||
else
|
||||
echo 'Der Cronjob ist eingerichtet. Der erste Abgleich war unvollständig und wird automatisch wiederholt.' >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user