This commit is contained in:
Snowy-Fluffy
2025-03-26 15:29:34 +03:00
parent e7ceafe014
commit 862274c941
2 changed files with 97 additions and 30 deletions

View File

@@ -7,22 +7,24 @@ install_dependencies() {
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
case "$ID" in
arch) $SUDO pacman -S --noconfirm git ;;
debian|ubuntu|mint) $SUDO DEBIAN_FRONTEND=noninteractive apt install -y git ;;
fedora) $SUDO dnf install -y git ;;
void) $SUDO xbps-install -y git ;;
gentoo) $SUDO emerge --ask=n dev-vcs/git ;;
opensuse) $SUDO zypper install -y git ;;
*)
if [ -n "$ID_LIKE" ]; then
case "$ID_LIKE" in
debian) $SUDO DEBIAN_FRONTEND=noninteractive apt install -y git ;;
*) echo "Неизвестная ОС: ${ID} ${ID_LIKE}"; exit 1 ;;
esac
else
echo "Неизвестная ОС: ${ID}"; exit 1
fi
;;
esac
elif [ "$kernel" = "Darwin" ]; then
echo "macOS не поддерживается на данный момент."
exit 1
@@ -32,13 +34,12 @@ install_dependencies() {
fi
}
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
else
if command -v sudo &> /dev/null; then
if command -v sudo > /dev/null 2>&1; then
SUDO="sudo"
elif command -v doas &> /dev/null; then
elif command -v doas > /dev/null 2>&1; then
SUDO="doas"
else
echo "Скрипт не может быть выполнен не от имени суперпользователя."
@@ -46,23 +47,18 @@ else
fi
fi
if command -v git > /dev/null 2>&1; then
echo ""
else
$SUDO install_dependencies
if ! command -v git > /dev/null 2>&1; then
install_dependencies
fi
if [ ! -d "/opt/zapret.installer" ]; then
cd /opt || exit
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git /opt/zapret.installer
else
cd "/opt/zapret.installer" || exit
cd /opt/zapret.installer || exit
if ! $SUDO git pull; then
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
$SUDO rm -rf /opt/zapret.installer
$SUDO git clone https://github.com/Snowy-Fluffy/zapret.installer.git /opt/zapret.installer
fi
fi