2025-03-25 15:32:32 +03:00
|
|
|
|
#!/bin/sh
|
2025-03-20 16:21:00 +03:00
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
2025-03-26 15:24:30 +03:00
|
|
|
|
install_dependencies() {
|
|
|
|
|
|
kernel="$(uname -s)"
|
|
|
|
|
|
if [ "$kernel" = "Linux" ]; then
|
|
|
|
|
|
. /etc/os-release
|
|
|
|
|
|
|
2025-03-26 15:39:54 +03:00
|
|
|
|
update_cmd=""
|
|
|
|
|
|
install_cmd=""
|
|
|
|
|
|
if [ -n "$ID" ]; then
|
|
|
|
|
|
case "$ID" in
|
2025-03-29 13:51:41 +03:00
|
|
|
|
arch) update_cmd="$SUDO pacman -Syu --noconfirm"; install_cmd="$SUDO pacman -S --noconfirm git" ;;
|
2025-03-26 15:39:54 +03:00
|
|
|
|
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" ;;
|
2025-03-29 16:42:15 +03:00
|
|
|
|
openwrt) update_cmd="$SUDO opkg update"; install_cmd="$SUDO opkg install -y git bash git-http ncurses-term" ;;
|
2025-03-26 15:39:54 +03:00
|
|
|
|
esac
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
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 ;;
|
2025-03-29 13:51:41 +03:00
|
|
|
|
arch) update_cmd="$SUDO pacman -Syu --noconfirm"; install_cmd="$SUDO pacman -S --noconfirm git"; break ;;
|
2025-03-26 15:39:54 +03:00
|
|
|
|
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 ;;
|
2025-03-29 16:42:15 +03:00
|
|
|
|
openwrt) update_cmd="$SUDO opkg update"; install_cmd="$SUDO opkg install git git-http bash" ; break ;;
|
2025-03-26 15:39:54 +03:00
|
|
|
|
esac
|
|
|
|
|
|
done
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$install_cmd" ]; then
|
|
|
|
|
|
eval "$update_cmd"
|
|
|
|
|
|
eval "$install_cmd"
|
|
|
|
|
|
else
|
|
|
|
|
|
echo "Неизвестная ОС: ${ID} ${ID_LIKE}"; exit 1
|
|
|
|
|
|
fi
|
2025-03-26 15:24:30 +03:00
|
|
|
|
elif [ "$kernel" = "Darwin" ]; then
|
|
|
|
|
|
echo "macOS не поддерживается на данный момент."
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
else
|
|
|
|
|
|
echo "Неизвестная ОС: ${kernel}"
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 15:32:32 +03:00
|
|
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
|
|
|
|
SUDO=""
|
|
|
|
|
|
else
|
2025-03-26 15:29:34 +03:00
|
|
|
|
if command -v sudo > /dev/null 2>&1; then
|
2025-03-25 15:32:32 +03:00
|
|
|
|
SUDO="sudo"
|
2025-03-26 15:29:34 +03:00
|
|
|
|
elif command -v doas > /dev/null 2>&1; then
|
2025-03-25 15:32:32 +03:00
|
|
|
|
SUDO="doas"
|
|
|
|
|
|
else
|
2025-03-26 15:24:30 +03:00
|
|
|
|
echo "Скрипт не может быть выполнен не от имени суперпользователя."
|
2025-03-25 15:32:32 +03:00
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
fi
|
2025-03-20 15:58:49 +03:00
|
|
|
|
|
2025-03-26 15:29:34 +03:00
|
|
|
|
if ! command -v git > /dev/null 2>&1; then
|
|
|
|
|
|
install_dependencies
|
2025-03-26 15:24:30 +03:00
|
|
|
|
fi
|
|
|
|
|
|
|
2025-03-25 15:32:32 +03:00
|
|
|
|
if [ ! -d "/opt/zapret.installer" ]; then
|
2025-03-26 15:29:34 +03:00
|
|
|
|
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git /opt/zapret.installer
|
2025-03-20 15:58:49 +03:00
|
|
|
|
else
|
2025-03-26 15:29:34 +03:00
|
|
|
|
cd /opt/zapret.installer || exit
|
2025-03-25 15:32:32 +03:00
|
|
|
|
if ! $SUDO git pull; then
|
2025-03-20 15:58:49 +03:00
|
|
|
|
echo "Ошибка при обновлении. Удаляю репозиторий и клонирую заново..."
|
2025-03-26 15:29:34 +03:00
|
|
|
|
$SUDO rm -rf /opt/zapret.installer
|
|
|
|
|
|
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git /opt/zapret.installer
|
2025-03-20 15:58:49 +03:00
|
|
|
|
fi
|
2025-03-20 04:05:10 +03:00
|
|
|
|
fi
|
2025-03-20 18:31:49 +03:00
|
|
|
|
|
2025-03-25 15:32:32 +03:00
|
|
|
|
$SUDO chmod +x /opt/zapret.installer/zapret-control.sh
|
2025-03-26 15:32:57 +03:00
|
|
|
|
exec bash /opt/zapret.installer/zapret-control.sh
|
2025-03-20 04:05:10 +03:00
|
|
|
|
|