Compare commits

..

No commits in common. "15751976e0438411587c7c25aef44e60d44418d9" and "243a64cbec5a7e4cdbace38789e65e5efe73ffdb" have entirely different histories.

12 changed files with 40 additions and 88 deletions

View File

@ -2,17 +2,11 @@
EXEDIR="$(dirname "$0")" EXEDIR="$(dirname "$0")"
EXEDIR="$(cd "$EXEDIR"; pwd)" EXEDIR="$(cd "$EXEDIR"; pwd)"
ZAPRET_BASE=${ZAPRET_BASE:-"$EXEDIR"} ZAPRET_CONFIG="$EXEDIR/config"
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} ZAPRET_BASE="$EXEDIR"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"}
ZAPRET_CONFIG_DEFAULT="$ZAPRET_BASE/config.default"
[ -f "$ZAPRET_CONFIG" ] || { [ -f "$ZAPRET_CONFIG" ] || {
[ -f "$ZAPRET_CONFIG_DEFAULT" ] && { [ -f "${ZAPRET_CONFIG}.default" ] && cp "${ZAPRET_CONFIG}.default" "$ZAPRET_CONFIG"
ZAPRET_CONFIG_DIR="$(dirname "$ZAPRET_CONFIG")"
[ -d "$ZAPRET_CONFIG_DIR" ] || mkdir -p "$ZAPRET_CONFIG_DIR"
cp "$ZAPRET_CONFIG_DEFAULT" "$ZAPRET_CONFIG"
}
} }
[ -f "$ZAPRET_CONFIG" ] && . "$ZAPRET_CONFIG" [ -f "$ZAPRET_CONFIG" ] && . "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"

View File

@ -154,7 +154,7 @@ linux_get_subsys()
local INIT="$(sed 's/\x0/\n/g' /proc/1/cmdline | head -n 1)" local INIT="$(sed 's/\x0/\n/g' /proc/1/cmdline | head -n 1)"
[ -L "$INIT" ] && INIT=$(readlink "$INIT") [ -L "$INIT" ] && INIT=$(readlink "$INIT")
INIT="$(basename "$INIT")" INIT=$(basename "$INIT")
if [ -f "/etc/openwrt_release" ] && [ "$INIT" = "procd" ] ; then if [ -f "/etc/openwrt_release" ] && [ "$INIT" = "procd" ] ; then
SUBSYS=openwrt SUBSYS=openwrt
elif [ -x "/bin/ndm" ] ; then elif [ -x "/bin/ndm" ] ; then

View File

@ -89,7 +89,7 @@ check_system()
# do not use 'exe' because it requires root # do not use 'exe' because it requires root
local INIT="$(sed 's/\x0/\n/g' /proc/1/cmdline | head -n 1)" local INIT="$(sed 's/\x0/\n/g' /proc/1/cmdline | head -n 1)"
[ -L "$INIT" ] && INIT=$(readlink "$INIT") [ -L "$INIT" ] && INIT=$(readlink "$INIT")
INIT="$(basename "$INIT")" INIT=$(basename "$INIT")
# some distros include systemctl without systemd # some distros include systemctl without systemd
if [ -d "$SYSTEMD_DIR" ] && [ -x "$SYSTEMCTL" ] && [ "$INIT" = "systemd" ]; then if [ -d "$SYSTEMD_DIR" ] && [ -x "$SYSTEMCTL" ] && [ "$INIT" = "systemd" ]; then
SYSTEM=systemd SYSTEM=systemd

View File

@ -117,7 +117,7 @@ resolve_lower_devices()
{ {
local l lower lowers local l lower lowers
while read lower; do while read lower; do
lower="$(basename "$lower")" lower=$(basename "$lower")
l="${lower#lower_*}" l="${lower#lower_*}"
[ "$l" != "$lower" ] && append_separator_list lowers ' ' '' "$l" [ "$l" != "$lower" ] && append_separator_list lowers ' ' '' "$l"
done done

View File

@ -1,9 +1,7 @@
# init script functions library for macos # init script functions library for macos
ZAPRET_BASE=${ZAPRET_BASE:-/opt/zapret} [ -n "$ZAPRET_BASE" ] || ZAPRET_BASE=/opt/zapret
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} . "$ZAPRET_BASE/config"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"}
. "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/pf.sh" . "$ZAPRET_BASE/common/pf.sh"
. "$ZAPRET_BASE/common/list.sh" . "$ZAPRET_BASE/common/list.sh"

View File

@ -31,9 +31,7 @@ check_need_to_reload_tpws6()
else else
ZAPRET_BASE=/opt/zapret ZAPRET_BASE=/opt/zapret
fi fi
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} . "$ZAPRET_BASE/config"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"}
. "$ZAPRET_CONFIG"
check_need_to_reload_tpws6 check_need_to_reload_tpws6
[ -n "$RELOAD_TPWS6" ] && { [ -n "$RELOAD_TPWS6" ] && {

View File

@ -1,9 +1,7 @@
. /lib/functions/network.sh . /lib/functions/network.sh
ZAPRET_BASE=${ZAPRET_BASE:-/opt/zapret} [ -n "$ZAPRET_BASE" ] || ZAPRET_BASE=/opt/zapret
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} . "$ZAPRET_BASE/config"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"}
. "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/fwtype.sh" . "$ZAPRET_BASE/common/fwtype.sh"
. "$ZAPRET_BASE/common/queue.sh" . "$ZAPRET_BASE/common/queue.sh"

View File

@ -1,9 +1,7 @@
# init script functions library for desktop linux systems # init script functions library for desktop linux systems
ZAPRET_BASE=${ZAPRET_BASE:-/opt/zapret} [ -n "$ZAPRET_BASE" ] || ZAPRET_BASE=/opt/zapret
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} . "$ZAPRET_BASE/config"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"}
. "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/fwtype.sh" . "$ZAPRET_BASE/common/fwtype.sh"
. "$ZAPRET_BASE/common/queue.sh" . "$ZAPRET_BASE/common/queue.sh"

View File

@ -5,7 +5,7 @@ EXEDIR="$(cd "$EXEDIR"; pwd)"
BINS=binaries BINS=binaries
BINDIR="$EXEDIR/$BINS" BINDIR="$EXEDIR/$BINS"
ZAPRET_BASE=${ZAPRET_BASE:-"$EXEDIR"} ZAPRET_BASE="$EXEDIR"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
check_dir() check_dir()
@ -41,11 +41,11 @@ check_dir()
# link or copy executables. uncomment either ln or cp, comment other # link or copy executables. uncomment either ln or cp, comment other
ccp() ccp()
{ {
local F="$(basename "$1")" local F=$(basename $1)
[ -d "$ZAPRET_BASE/$2" ] || mkdir "$ZAPRET_BASE/$2" [ -d "$EXEDIR/$2" ] || mkdir "$EXEDIR/$2"
[ -f "$ZAPRET_BASE/$2/$F" ] && rm -f "$ZAPRET_BASE/$2/$F" [ -f "$EXEDIR/$2/$F" ] && rm -f "$EXEDIR/$2/$F"
ln -fs "../$BINS/$1" "$ZAPRET_BASE/$2" && echo linking : "../$BINS/$1" =\> "$ZAPRET_BASE/$2" ln -fs "../$BINS/$1" "$EXEDIR/$2" && echo linking : "../$BINS/$1" =\> "$EXEDIR/$2"
#cp -f "../$BINS/$1" "$ZAPRET_BASE/$2" && echo copying : "../$BINS/$1" =\> "$ZAPRET_BASE/$2" #cp -f "$BINDIR/$1" "$EXEDIR/$2" && echo copying : "$BINDIR/$1" =\> "$EXEDIR/$2"
} }
UNAME=$(uname) UNAME=$(uname)

View File

@ -4,17 +4,11 @@
EXEDIR="$(dirname "$0")" EXEDIR="$(dirname "$0")"
EXEDIR="$(cd "$EXEDIR"; pwd)" EXEDIR="$(cd "$EXEDIR"; pwd)"
ZAPRET_BASE=${ZAPRET_BASE:-"$EXEDIR"} IPSET_DIR="$EXEDIR/ipset"
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} ZAPRET_CONFIG="$EXEDIR/config"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"} ZAPRET_BASE="$EXEDIR"
ZAPRET_CONFIG_DEFAULT="$ZAPRET_BASE/config.default"
IPSET_DIR="$ZAPRET_BASE/ipset"
[ -f "$ZAPRET_CONFIG" ] || { [ -f "$ZAPRET_CONFIG" ] || cp "${ZAPRET_CONFIG}.default" "$ZAPRET_CONFIG"
ZAPRET_CONFIG_DIR="$(dirname "$ZAPRET_CONFIG")"
[ -d "$ZAPRET_CONFIG_DIR" ] || mkdir -p "$ZAPRET_CONFIG_DIR"
cp "$ZAPRET_CONFIG_DEFAULT" "$ZAPRET_CONFIG"
}
. "$ZAPRET_CONFIG" . "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/elevate.sh" . "$ZAPRET_BASE/common/elevate.sh"
@ -25,7 +19,7 @@ IPSET_DIR="$ZAPRET_BASE/ipset"
. "$ZAPRET_BASE/common/virt.sh" . "$ZAPRET_BASE/common/virt.sh"
# install target # install target
ZAPRET_TARGET=${ZAPRET_TARGET:-/opt/zapret} ZAPRET_TARGET=/opt/zapret
GET_LIST="$IPSET_DIR/get_config.sh" GET_LIST="$IPSET_DIR/get_config.sh"
@ -384,16 +378,12 @@ select_mode_iface()
default_files() default_files()
{ {
# $1 - ro location [ -f "$1/ipset/$file/zapret-hosts-user-exclude.txt" ] || cp "$1/ipset/$file/zapret-hosts-user-exclude.txt.default" "$1/ipset/$file/zapret-hosts-user-exclude.txt"
# $2 - rw location (can be equal to $1) [ -f "$1/ipset/$file/zapret-hosts-user.txt" ] || echo nonexistent.domain >> "$1/ipset/$file/zapret-hosts-user.txt"
[ -d "$2/ipset" ] || mkdir -p "$2/ipset" [ -f "$1/ipset/$file/zapret-hosts-user-ipban.txt" ] || touch "$1/ipset/$file/zapret-hosts-user-ipban.txt"
[ -f "$2/ipset/zapret-hosts-user-exclude.txt" ] || cp "$1/ipset/zapret-hosts-user-exclude.txt.default" "$2/ipset/zapret-hosts-user-exclude.txt"
[ -f "$2/ipset/zapret-hosts-user.txt" ] || echo nonexistent.domain >> "$2/ipset/zapret-hosts-user.txt"
[ -f "$2/ipset/zapret-hosts-user-ipban.txt" ] || touch "$2/ipset/zapret-hosts-user-ipban.txt"
for dir in openwrt sysv macos; do for dir in openwrt sysv macos; do
[ -d "$1/init.d/$dir" ] && { [ -d "$1/init.d/$dir" ] && {
[ -d "$2/init.d/$dir" ] || mkdir -p "$2/init.d/$dir" [ -f "$1/init.d/$dir/custom" ] || cp "$1/init.d/$dir/custom.default" "$1/init.d/$dir/custom"
[ -f "$2/init.d/$dir/custom" ] || cp "$1/init.d/$dir/custom.default" "$2/init.d/$dir/custom"
} }
done done
} }
@ -430,15 +420,7 @@ fix_perms()
[ -d "$1" ] || return [ -d "$1" ] || return
find "$1" -type d -exec chmod 755 {} \; find "$1" -type d -exec chmod 755 {} \;
find "$1" -type f -exec chmod 644 {} \; find "$1" -type f -exec chmod 644 {} \;
local chow chown -R root:root "$1"
case "$UNAME" in
Linux)
chow=root:root
;;
*)
chow=root:wheel
esac
chown -R $chow "$1"
find "$1/binaries" '(' -name tpws -o -name dvtws -o -name nfqws -o -name ip2net -o -name mdig ')' -exec chmod 755 {} \; find "$1/binaries" '(' -name tpws -o -name dvtws -o -name nfqws -o -name ip2net -o -name mdig ')' -exec chmod 755 {} \;
for f in \ for f in \
install_bin.sh \ install_bin.sh \
@ -511,7 +493,7 @@ check_location()
# use inodes in case something is linked # use inodes in case something is linked
if [ -d "$ZAPRET_TARGET" ] && [ $(get_dir_inode "$EXEDIR") = $(get_dir_inode "$ZAPRET_TARGET") ]; then if [ -d "$ZAPRET_TARGET" ] && [ $(get_dir_inode "$EXEDIR") = $(get_dir_inode "$ZAPRET_TARGET") ]; then
default_files "$ZAPRET_TARGET" "$ZAPRET_RW" default_files "$ZAPRET_TARGET"
else else
echo echo
echo easy install is supported only from default location : $ZAPRET_TARGET echo easy install is supported only from default location : $ZAPRET_TARGET
@ -524,10 +506,8 @@ check_location()
echo directory needs to be replaced. config and custom scripts can be kept or replaced with clean version echo directory needs to be replaced. config and custom scripts can be kept or replaced with clean version
if ask_yes_no N "do you want to delete all files there and copy this version"; then if ask_yes_no N "do you want to delete all files there and copy this version"; then
echo echo
if [ $(get_dir_inode "$ZAPRET_BASE") = $(get_dir_inode "$ZAPRET_RW") ]; then ask_yes_no Y "keep config, custom scripts and user lists" && keep=Y
ask_yes_no Y "keep config, custom scripts and user lists" && keep=Y [ "$keep" = "Y" ] && backup_restore_settings 1
[ "$keep" = "Y" ] && backup_restore_settings 1
fi
rm -r "$ZAPRET_TARGET" rm -r "$ZAPRET_TARGET"
else else
echo refused to overwrite $ZAPRET_TARGET. exiting echo refused to overwrite $ZAPRET_TARGET. exiting
@ -540,7 +520,7 @@ check_location()
fix_perms "$ZAPRET_TARGET" fix_perms "$ZAPRET_TARGET"
[ "$keep" = "Y" ] && backup_restore_settings 0 [ "$keep" = "Y" ] && backup_restore_settings 0
echo relaunching itself from $ZAPRET_TARGET echo relaunching itself from $ZAPRET_TARGET
exec "$ZAPRET_TARGET/$(basename "$0")" exec $ZAPRET_TARGET/$(basename $0)
else else
echo copying aborted. exiting echo copying aborted. exiting
exitp 3 exitp 3

View File

@ -4,17 +4,10 @@
EXEDIR="$(dirname "$0")" EXEDIR="$(dirname "$0")"
EXEDIR="$(cd "$EXEDIR"; pwd)" EXEDIR="$(cd "$EXEDIR"; pwd)"
ZAPRET_BASE=${ZAPRET_BASE:-"$EXEDIR"} ZAPRET_CONFIG="$EXEDIR/config"
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} ZAPRET_BASE="$EXEDIR"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"}
ZAPRET_CONFIG_DEFAULT="$ZAPRET_BASE/config.default"
[ -f "$ZAPRET_CONFIG" ] || {
ZAPRET_CONFIG_DIR="$(dirname "$ZAPRET_CONFIG")"
[ -d "$ZAPRET_CONFIG_DIR" ] || mkdir -p "$ZAPRET_CONFIG_DIR"
cp "$ZAPRET_CONFIG_DEFAULT" "$ZAPRET_CONFIG"
}
[ -f "$ZAPRET_CONFIG" ] || cp "${ZAPRET_CONFIG}.default" "$ZAPRET_CONFIG"
. "$ZAPRET_CONFIG" . "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/elevate.sh" . "$ZAPRET_BASE/common/elevate.sh"

View File

@ -4,18 +4,11 @@
EXEDIR="$(dirname "$0")" EXEDIR="$(dirname "$0")"
EXEDIR="$(cd "$EXEDIR"; pwd)" EXEDIR="$(cd "$EXEDIR"; pwd)"
ZAPRET_BASE=${ZAPRET_BASE:-"$EXEDIR"} IPSET_DIR="$EXEDIR/ipset"
ZAPRET_RW=${ZAPRET_RW:-"$ZAPRET_BASE"} ZAPRET_CONFIG="$EXEDIR/config"
ZAPRET_CONFIG=${ZAPRET_CONFIG:-"$ZAPRET_RW/config"} ZAPRET_BASE="$EXEDIR"
ZAPRET_CONFIG_DEFAULT="$ZAPRET_BASE/config.default"
IPSET_DIR="$ZAPRET_BASE/ipset"
[ -f "$ZAPRET_CONFIG" ] || {
ZAPRET_CONFIG_DIR="$(dirname "$ZAPRET_CONFIG")"
[ -d "$ZAPRET_CONFIG_DIR" ] || mkdir -p "$ZAPRET_CONFIG_DIR"
cp "$ZAPRET_CONFIG_DEFAULT" "$ZAPRET_CONFIG"
}
[ -f "$ZAPRET_CONFIG" ] || cp "${ZAPRET_CONFIG}.default" "$ZAPRET_CONFIG"
. "$ZAPRET_CONFIG" . "$ZAPRET_CONFIG"
. "$ZAPRET_BASE/common/base.sh" . "$ZAPRET_BASE/common/base.sh"
. "$ZAPRET_BASE/common/elevate.sh" . "$ZAPRET_BASE/common/elevate.sh"