mirror of
https://github.com/Snowy-Fluffy/zapret.installer.git
synced 2025-12-06 09:03:04 +03:00
Wget has been replaced with curl, unnecessary dependencies have been removed, and ID_LIKE distributions have been fixed
This commit is contained in:
47
installer.sh
47
installer.sh
@@ -4,48 +4,43 @@ set -e
|
||||
|
||||
install_dependencies() {
|
||||
kernel="$(uname -s)"
|
||||
|
||||
if [ "$kernel" = "Linux" ]; then
|
||||
. /etc/os-release
|
||||
[ -f /etc/os-release ] && . /etc/os-release || { echo "Не удалось определить ОС"; exit 1; }
|
||||
|
||||
update_cmd=""
|
||||
install_cmd=""
|
||||
if [ -n "$ID" ]; then
|
||||
case "$ID" in
|
||||
arch) update_cmd="$SUDO pacman -Syu --noconfirm"; install_cmd="$SUDO pacman -S --noconfirm git" ;;
|
||||
debian|ubuntu|mint) update_cmd="$SUDO DEBIAN_FRONTEND=noninteractive apt update -y"; install_cmd="$SUDO DEBIAN_FRONTEND=noninteractive apt install -y git" ;;
|
||||
fedora) update_cmd="$SUDO dnf check-update -y"; install_cmd="$SUDO dnf install -y git" ;;
|
||||
void) update_cmd="$SUDO xbps-install -S"; install_cmd="$SUDO xbps-install -y git" ;;
|
||||
gentoo) update_cmd="$SUDO emerge --sync --quiet"; install_cmd="$SUDO emerge --ask=n dev-vcs/git" ;;
|
||||
opensuse) update_cmd="$SUDO zypper refresh -y"; install_cmd="$SUDO zypper install -y git" ;;
|
||||
openwrt) update_cmd="$SUDO opkg update"; install_cmd="$SUDO opkg install -y git bash git-http ncurses-term" ;;
|
||||
SUDO="${SUDO:-}"
|
||||
|
||||
find_package_manager() {
|
||||
case "$1" in
|
||||
arch) echo "$SUDO pacman -Syu --noconfirm && $SUDO pacman -S --noconfirm git" ;;
|
||||
debian|ubuntu|mint) echo "$SUDO apt update -y && $SUDO apt install -y git" ;;
|
||||
fedora) echo "$SUDO dnf check-update -y && $SUDO dnf install -y git" ;;
|
||||
void) echo "$SUDO xbps-install -S && $SUDO xbps-install -y git" ;;
|
||||
gentoo) echo "$SUDO emerge --sync --quiet && $SUDO emerge --ask=n dev-vcs/git" ;;
|
||||
opensuse) echo "$SUDO zypper refresh -y && $SUDO zypper install -y git" ;;
|
||||
openwrt) echo "$SUDO opkg update && $SUDO opkg install git git-http bash" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
install_cmd="$(find_package_manager "$ID")"
|
||||
if [ -z "$install_cmd" ] && [ -n "$ID_LIKE" ]; then
|
||||
for like in $ID_LIKE; do
|
||||
case "$like" in
|
||||
debian) update_cmd="$SUDO DEBIAN_FRONTEND=noninteractive apt update -y"; install_cmd="$SUDO DEBIAN_FRONTEND=noninteractive apt install -y git"; break ;;
|
||||
arch) update_cmd="$SUDO pacman -Syu --noconfirm"; install_cmd="$SUDO pacman -S --noconfirm git"; break ;;
|
||||
fedora) update_cmd="$SUDO dnf check-update -y"; install_cmd="$SUDO dnf install -y git"; break ;;
|
||||
void) update_cmd="$SUDO xbps-install -S"; install_cmd="$SUDO xbps-install -y git"; break ;;
|
||||
gentoo) update_cmd="$SUDO emerge --sync --quiet"; install_cmd="$SUDO emerge --ask=n dev-vcs/git"; break ;;
|
||||
opensuse) update_cmd="$SUDO zypper refresh -y"; install_cmd="$SUDO zypper install -y git"; break ;;
|
||||
openwrt) update_cmd="$SUDO opkg update"; install_cmd="$SUDO opkg install git git-http bash" ; break ;;
|
||||
esac
|
||||
install_cmd="$(find_package_manager "$like")" && [ -n "$install_cmd" ] && break
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$install_cmd" ]; then
|
||||
eval "$update_cmd"
|
||||
eval "$install_cmd"
|
||||
else
|
||||
echo "Неизвестная ОС: ${ID} ${ID_LIKE}"; exit 1
|
||||
echo "Неизвестная ОС: ${ID:-Неизвестно}"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$kernel" = "Darwin" ]; then
|
||||
echo "macOS не поддерживается на данный момент."
|
||||
echo "macOS не поддерживается на данный момент."
|
||||
exit 1
|
||||
else
|
||||
echo "Неизвестная ОС: ${kernel}"
|
||||
echo "Неизвестная ОС: $kernel"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -282,25 +282,15 @@ install_dependencies() {
|
||||
. /etc/os-release
|
||||
|
||||
declare -A command_by_ID=(
|
||||
["arch"]="pacman -S --noconfirm make gcc wget libcap ipset \
|
||||
libnetfilter_queue"
|
||||
["debian"]="apt-get install -y make gcc zlib1g-dev ipset iptables \
|
||||
libcap-dev wget"
|
||||
["fedora"]="dnf install -y make gcc zlib-devel ipset iptables \
|
||||
libcap-devel wget"
|
||||
["ubuntu"]="apt-get install -y make gcc zlib1g-dev wget ipset iptables \
|
||||
libcap-dev"
|
||||
["mint"]="apt-get install -y make gcc wget zlib1g-dev ipset iptables \
|
||||
libcap-dev libnetfilter-queue-dev"
|
||||
["void"]="xpbs-install -y make gcc zlib libcap wget ipset iptables \
|
||||
libnetfilter_queue"
|
||||
["gentoo"]="emerge sys-libs/zlib net-firewall/iptables net-misc/wget net-firewall/ipset sys-libs/libcap \
|
||||
net-libs/libnetfilter_queue"
|
||||
["opensuse"]="zypper install -y make gcc wget zlib-devel ipset iptables \
|
||||
libcap-devel libnetfilter_queue-devel"
|
||||
["openwrt"]="opkg install iptables ipset \
|
||||
libcap wget"
|
||||
|
||||
["arch"]="pacman -S --noconfirm iptables ipset"
|
||||
["debian"]="apt-get install -y iptables ipset"
|
||||
["fedora"]="dnf install -y iptables ipset"
|
||||
["ubuntu"]="apt-get install -y iptables ipset"
|
||||
["mint"]="apt-get install -y iptables ipset"
|
||||
["void"]="xbps-install -y iptables ipset"
|
||||
["gentoo"]="emerge net-firewall/iptables net-firewall/ipset"
|
||||
["opensuse"]="zypper install -y iptables ipset"
|
||||
["openwrt"]="opkg install iptables ipset"
|
||||
)
|
||||
|
||||
if [[ -v command_by_ID[$ID] ]]; then
|
||||
@@ -359,7 +349,7 @@ main_menu() {
|
||||
case "$CHOICE" in
|
||||
1) install_zapret; main_menu;;
|
||||
2) update_script;;
|
||||
3) $TPUT_E; exit 0;;
|
||||
3) tput rmcup; exit 0;;
|
||||
*) echo "Неверный ввод!"; sleep 2;;
|
||||
esac
|
||||
fi
|
||||
@@ -402,8 +392,8 @@ install_zapret() {
|
||||
|
||||
if [[ ! -d /opt/zapret.installer/zapret.binaries ]]; then
|
||||
echo "Клонирую релиз запрета..."
|
||||
mkdir -p /opt/zapret.installer/zapret.binaries
|
||||
if ! wget -P /opt/zapret.installer/zapret.binaries/zapret https://github.com/bol-van/zapret/releases/download/v70.4/zapret-v70.4.tar.gz; then
|
||||
mkdir -p /opt/zapret.installer/zapret.binaries/zapret
|
||||
if ! curl -L -o /opt/zapret.installer/zapret.binaries/zapret/zapret-v70.4.tar.gz https://github.com/bol-van/zapret/releases/download/v70.4/zapret-v70.4.tar.gz; then
|
||||
rm -rf /opt/zapret.installer/
|
||||
error_exit "не удалось получить релиз запрета."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user