Files
zapret.installer-Snowy-Fluffy/installer.sh

72 lines
2.1 KiB
Bash
Raw Normal View History

#!/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
declare -A command_by_ID=(
["arch"]="pacman -S --noconfirm git"
["debian"]="DEBIAN_FRONTEND=noninteractive apt install -y git"
["fedora"]="dnf install -y git"
["ubuntu"]="DEBIAN_FRONTEND=noninteractive apt install -y git"
["mint"]="DEBIAN_FRONTEND=noninteractive apt install -y git"
["void"]="xpbs-install -y git "
["gentoo"]="emerge --ask=n dev-vcs/git"
["opensuse"]="zypper install -y git "
)
if [[ -v command_by_ID[$ID] ]]; then
eval "${command_by_ID[$ID]}"
elif [[ -v command_by_ID[$ID_LIKE] ]]; then
eval "${command_by_ID[$ID_LIKE]}"
fi
elif [ "$kernel" = "Darwin" ]; then
echo "macOS не поддерживается на данный момент."
exit 1
else
echo "Неизвестная ОС: ${kernel}"
exit 1
fi
}
2025-03-25 15:45:31 +03:00
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
else
if command -v sudo &> /dev/null; then
SUDO="sudo"
elif command -v doas &> /dev/null; then
SUDO="doas"
else
2025-03-26 15:24:30 +03:00
echo "Скрипт не может быть выполнен не от имени суперпользователя."
exit 1
fi
fi
2025-03-20 15:58:49 +03:00
2025-03-26 15:24:30 +03:00
if command -v git > /dev/null 2>&1; then
echo ""
else
$SUDO install_dependencies
fi
if [ ! -d "/opt/zapret.installer" ]; then
cd /opt || exit
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git
2025-03-20 15:58:49 +03:00
else
cd "/opt/zapret.installer" || exit
if ! $SUDO git pull; then
2025-03-20 15:58:49 +03:00
echo "Ошибка при обновлении. Удаляю репозиторий и клонирую заново..."
cd /opt || exit
$SUDO rm -rf "/opt/zapret.installer"
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git
cd "/opt/zapret.installer" || exit
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
$SUDO chmod +x /opt/zapret.installer/zapret-control.sh
bash /opt/zapret.installer/zapret-control.sh
2025-03-20 04:05:10 +03:00