Compare commits

...

3 Commits

2 changed files with 55 additions and 24 deletions

View File

@ -617,11 +617,17 @@ write_config_var()
replace_var_def $1 "$M" "$ZAPRET_CONFIG" replace_var_def $1 "$M" "$ZAPRET_CONFIG"
} }
no_prereq_exit()
{
echo could not install prerequisites
exitp 6
}
check_prerequisites_linux() check_prerequisites_linux()
{ {
echo \* checking prerequisites echo \* checking prerequisites
local s cmd PKGS UTILS req="curl curl" local s cmd PKGS UTILS req="curl curl"
local APTGET DNF YUM PACMAN ZYPPER EOPKG APK
case "$FWTYPE" in case "$FWTYPE" in
iptables) iptables)
req="$req iptables iptables ip6tables iptables ipset ipset" req="$req iptables iptables ip6tables iptables ipset ipset"
@ -650,6 +656,7 @@ check_prerequisites_linux()
echo packages required : $PKGS echo packages required : $PKGS
APTGET=$(whichq apt-get) APTGET=$(whichq apt-get)
DNF=$(whichq dnf)
YUM=$(whichq yum) YUM=$(whichq yum)
PACMAN=$(whichq pacman) PACMAN=$(whichq pacman)
ZYPPER=$(whichq zypper) ZYPPER=$(whichq zypper)
@ -657,39 +664,23 @@ check_prerequisites_linux()
APK=$(whichq apk) APK=$(whichq apk)
if [ -x "$APTGET" ] ; then if [ -x "$APTGET" ] ; then
"$APTGET" update "$APTGET" update
"$APTGET" install -y --no-install-recommends $PKGS dnsutils || { "$APTGET" install -y --no-install-recommends $PKGS dnsutils || no_prereq_exit
echo could not install prerequisites elif [ -x "$DNF" ] ; then
exitp 6 "$DNF" -y install $PKGS || no_prereq_exit
}
elif [ -x "$YUM" ] ; then elif [ -x "$YUM" ] ; then
"$YUM" -y install $PKGS || { "$YUM" -y install $PKGS || no_prereq_exit
echo could not install prerequisites
exitp 6
}
elif [ -x "$PACMAN" ] ; then elif [ -x "$PACMAN" ] ; then
"$PACMAN" -Syy "$PACMAN" -Syy
"$PACMAN" --noconfirm -S $PKGS || { "$PACMAN" --noconfirm -S $PKGS || no_prereq_exit
echo could not install prerequisites
exitp 6
}
elif [ -x "$ZYPPER" ] ; then elif [ -x "$ZYPPER" ] ; then
"$ZYPPER" --non-interactive install $PKGS || { "$ZYPPER" --non-interactive install $PKGS || no_prereq_exit
echo could not install prerequisites
exitp 6
}
elif [ -x "$EOPKG" ] ; then elif [ -x "$EOPKG" ] ; then
"$EOPKG" -y install $PKGS || { "$EOPKG" -y install $PKGS || no_prereq_exit
echo could not install prerequisites
exitp 6
}
elif [ -x "$APK" ] ; then elif [ -x "$APK" ] ; then
"$APK" update "$APK" update
# for alpine # for alpine
[ "$FWTYPE" = iptables ] && [ -n "$($APK list ip6tables)" ] && PKGS="$PKGS ip6tables" [ "$FWTYPE" = iptables ] && [ -n "$($APK list ip6tables)" ] && PKGS="$PKGS ip6tables"
"$APK" add $PKGS || { "$APK" add $PKGS || no_prereq_exit
echo could not install prerequisites
exitp 6
}
else else
echo supported package manager not found echo supported package manager not found
echo you must manually install : $UTILS echo you must manually install : $UTILS

View File

@ -0,0 +1,40 @@
#!/bin/sh
IPSET_DIR="$(dirname "$0")"
IPSET_DIR="$(cd "$IPSET_DIR"; pwd)"
. "$IPSET_DIR/def.sh"
TMPLIST="$TMPDIR/list.txt"
URL="https://antifilter.download/list/domains.lst"
dl()
{
# $1 - url
# $2 - file
# $3 - minsize
# $4 - maxsize
curl -L -H "Accept-Encoding: gzip" -k --fail --max-time 60 --connect-timeout 10 --retry 4 --max-filesize 251658240 -o "$TMPLIST" "$1" ||
{
echo list download failed : $1
exit 2
}
dlsize=$(LANG=C wc -c "$TMPLIST" | xargs | cut -f 1 -d ' ')
if test $dlsize -lt $3; then
echo list is too small : $dlsize bytes. can be bad.
exit 2
fi
zzcat "$TMPLIST" | tr -d '\015' | zz "$2"
rm -f "$TMPLIST"
}
# useful in case ipban set is used in custom scripts
FAIL=
getipban || FAIL=1
"$IPSET_DIR/create_ipset.sh"
[ -n "$FAIL" ] && exit
dl "$URL" "$ZHOSTLIST" 32768 4194304
exit 0