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

71
installer.sh.old Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/sh
set -e
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
}
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
echo "Скрипт не может быть выполнен не от имени суперпользователя."
exit 1
fi
fi
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
else
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
fi
fi
$SUDO chmod +x /opt/zapret.installer/zapret-control.sh
bash /opt/zapret.installer/zapret-control.sh