2024-01-22 10:36:06 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
# ALR - Any Linux Repository
|
|
|
|
|
# Copyright (C) 2024 Евгений Храмов
|
2024-01-22 10:36:06 +00:00
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
info() {
|
|
|
|
|
echo $'\x1b[32m[INFO]\x1b[0m' $@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
warn() {
|
|
|
|
|
echo $'\x1b[31m[WARN]\x1b[0m' $@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error() {
|
|
|
|
|
echo $'\x1b[31;1m[ERR]\x1b[0m' $@
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
installPkg() {
|
|
|
|
|
rootCmd=""
|
|
|
|
|
if command -v doas &>/dev/null; then
|
|
|
|
|
rootCmd="doas"
|
|
|
|
|
elif command -v sudo &>/dev/null; then
|
|
|
|
|
rootCmd="sudo"
|
|
|
|
|
else
|
2024-05-05 10:32:08 +00:00
|
|
|
|
warn "Команда повышения привилегий (например, sudo, do as) не обнаружена"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
|
pacman) $rootCmd pacman --noconfirm -U ${@:2} ;;
|
|
|
|
|
apk) $rootCmd apk add --allow-untrusted ${@:2} ;;
|
|
|
|
|
zypper) $rootCmd zypper --no-gpg-checks install ${@:2} ;;
|
|
|
|
|
*) $rootCmd $1 install -y ${@:2} ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ! command -v curl &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
error "Для этого скрипта требуется команда curl. Пожалуйста, установите его и запустите снова."
|
2024-01-22 10:36:06 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
pkgFormat=""
|
|
|
|
|
pkgMgr=""
|
|
|
|
|
if command -v pacman &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Обнаружен pacman"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
pkgFormat="pkg.tar.zst"
|
|
|
|
|
pkgMgr="pacman"
|
|
|
|
|
elif command -v apt &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Обнаружен apt"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
pkgFormat="deb"
|
|
|
|
|
pkgMgr="apt"
|
|
|
|
|
elif command -v dnf &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Обнаружен dnf"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
pkgFormat="rpm"
|
|
|
|
|
pkgMgr="dnf"
|
|
|
|
|
elif command -v yum &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Обнаружен yum"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
pkgFormat="rpm"
|
|
|
|
|
pkgMgr="yum"
|
|
|
|
|
elif command -v zypper &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Обнаружен zypper"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
pkgFormat="rpm"
|
|
|
|
|
pkgMgr="zypper"
|
|
|
|
|
elif command -v apk &>/dev/null; then
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Обнаружен apk"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
pkgFormat="apk"
|
|
|
|
|
pkgMgr="apk"
|
|
|
|
|
else
|
2024-05-05 10:32:08 +00:00
|
|
|
|
error "Не обнаружен поддерживаемый пакетный менеджер!"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
latestVersion=$(curl -sI 'https://gitflic.ru/project/xpamych/alr/release/latest' | grep -io 'location: .*' | rev | cut -d '/' -f1 | rev | tr -d '[:space:]')
|
|
|
|
|
info "Найдена последняя версия ALR:" $latestVersion
|
2024-01-22 10:36:06 +00:00
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
fname="$(mktemp -u -p /tmp "alr.XXXXXXXXXX").${pkgFormat}"
|
|
|
|
|
url="https://registry.gitflic.ru/project/xpamych/alr/package/-/generic/alr-linux-x86-64/{version}/{file}"
|
|
|
|
|
https://gitflic.ru/project/xpamych/alr/releases/download/${latestVersion}/linux-user-repository-${latestVersion#v}-linux-$(uname -m).${pkgFormat}"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Скачивается пакет ALR"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
curl -L $url -o $fname
|
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Устанавливается ALR"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
installPkg $pkgMgr $fname
|
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Очистка"
|
2024-01-22 10:36:06 +00:00
|
|
|
|
rm $fname
|
|
|
|
|
|
2024-05-05 10:32:08 +00:00
|
|
|
|
info "Готово!"
|