Обновить install.sh
This commit is contained in:
177
install.sh
177
install.sh
@@ -1,19 +1,90 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# --- Настройки ---
|
# --- Настройки ---
|
||||||
GITEA_API="https://git.ownsrv.ru/api/v1/repos/yanistyle/podkop/releases/latest"
|
REPO_API="https://git.ownsrv.ru/api/v1/repos/yanistyle/podkop/releases"
|
||||||
DOWNLOAD_DIR="/tmp/podkop"
|
DOWNLOAD_DIR="/tmp/podkop"
|
||||||
TOKEN="YOUR_TOKEN_HERE" # <--- сюда твой Gitea токен
|
|
||||||
COUNT=3
|
COUNT=3
|
||||||
|
|
||||||
rm -rf "$DOWNLOAD_DIR"
|
rm -rf "$DOWNLOAD_DIR"
|
||||||
mkdir -p "$DOWNLOAD_DIR"
|
mkdir -p "$DOWNLOAD_DIR"
|
||||||
|
|
||||||
msg() { printf "\033[32;1m%s\033[0m\n" "$1"; }
|
msg() {
|
||||||
|
printf "\033[32;1m%s\033[0m\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Проверка и установка зависимостей ---
|
||||||
|
install_dependencies() {
|
||||||
|
deps="curl jq wget"
|
||||||
|
for dep in $deps; do
|
||||||
|
if ! command -v $dep >/dev/null 2>&1; then
|
||||||
|
msg "$dep не найден. Пытаемся установить..."
|
||||||
|
opkg update
|
||||||
|
opkg install $dep || { msg "Не удалось установить $dep"; exit 1; }
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Проверка системы ---
|
||||||
|
check_system() {
|
||||||
|
MODEL=$(cat /tmp/sysinfo/model 2>/dev/null || echo "Unknown")
|
||||||
|
msg "Router model: $MODEL"
|
||||||
|
|
||||||
|
openwrt_version=$(cat /etc/openwrt_release 2>/dev/null | grep DISTRIB_RELEASE | cut -d"'" -f2 | cut -d'.' -f1)
|
||||||
|
if [ "$openwrt_version" = "23" ]; then
|
||||||
|
msg "OpenWrt 23.05 не поддерживается начиная с podkop 0.5.0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
AVAILABLE_SPACE=$(df /overlay | awk 'NR==2 {print $4}')
|
||||||
|
REQUIRED_SPACE=15360
|
||||||
|
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
|
||||||
|
msg "Error: Insufficient space in flash"
|
||||||
|
msg "Available: $((AVAILABLE_SPACE/1024))MB, Required: $((REQUIRED_SPACE/1024))MB"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! nslookup google.com >/dev/null 2>&1; then
|
||||||
|
msg "DNS not working"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if opkg list-installed | grep -q https-dns-proxy; then
|
||||||
|
msg "Сonflicting package detected: https-dns-proxy. Remove?"
|
||||||
|
while true; do
|
||||||
|
read -r -p '' DNSPROXY
|
||||||
|
case $DNSPROXY in
|
||||||
|
yes|y|Y)
|
||||||
|
opkg remove --force-depends luci-app-https-dns-proxy https-dns-proxy luci-i18n-https-dns-proxy*
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
msg "Exit"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Проверка и обновление sing-box ---
|
||||||
|
sing_box() {
|
||||||
|
if ! opkg list-installed | grep -q "^sing-box"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sing_box_version=$(sing-box version | head -n 1 | awk '{print $3}')
|
||||||
|
required_version="1.12.4"
|
||||||
|
if [ "$(echo -e "$sing_box_version\n$required_version" | sort -V | head -n 1)" != "$required_version" ]; then
|
||||||
|
msg "sing-box version $sing_box_version is older than required $required_version"
|
||||||
|
msg "Removing old version..."
|
||||||
|
opkg remove sing-box
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Основная логика ---
|
||||||
main() {
|
main() {
|
||||||
check_system
|
check_system
|
||||||
sing_box
|
sing_box
|
||||||
|
install_dependencies
|
||||||
|
|
||||||
/usr/sbin/ntpd -q -p 194.190.168.1 -p 216.239.35.0 -p 216.239.35.4 -p 162.159.200.1 -p 162.159.200.123
|
/usr/sbin/ntpd -q -p 194.190.168.1 -p 216.239.35.0 -p 216.239.35.4 -p 162.159.200.1 -p 162.159.200.123
|
||||||
|
|
||||||
@@ -22,50 +93,48 @@ main() {
|
|||||||
if [ -f "/etc/init.d/podkop" ]; then
|
if [ -f "/etc/init.d/podkop" ]; then
|
||||||
msg "Podkop is already installed. Upgraded..."
|
msg "Podkop is already installed. Upgraded..."
|
||||||
else
|
else
|
||||||
msg "Installing podkop..."
|
msg "Installed podkop..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_packages
|
# --- Получаем последний релиз из Gitea ---
|
||||||
install_packages
|
|
||||||
}
|
|
||||||
|
|
||||||
download_packages() {
|
|
||||||
msg "Fetching latest release info from Gitea..."
|
msg "Fetching latest release info from Gitea..."
|
||||||
RELEASE_JSON=$(wget -qO- --header="Authorization: token $TOKEN" "$GITEA_API")
|
LATEST_TAG=$(curl -s "$REPO_API" | jq -r '.[0].tag_name')
|
||||||
|
if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" = "null" ]; then
|
||||||
# Находим все .ipk ссылки
|
msg "Не удалось получить последний релиз"
|
||||||
URLS=$(echo "$RELEASE_JSON" | grep -o 'https://[^"]*\.ipk')
|
|
||||||
|
|
||||||
if [ -z "$URLS" ]; then
|
|
||||||
msg "No packages found in latest release"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
msg "Последний релиз: $LATEST_TAG"
|
||||||
|
|
||||||
for url in $URLS; do
|
# --- Получаем список всех assets ---
|
||||||
file=$(basename "$url")
|
ASSETS=$(curl -s "$REPO_API" | jq -r '.[0].assets[].name')
|
||||||
filepath="$DOWNLOAD_DIR/$file"
|
|
||||||
|
download_success=0
|
||||||
|
for filename in $ASSETS; do
|
||||||
|
filepath="$DOWNLOAD_DIR/$filename"
|
||||||
attempt=0
|
attempt=0
|
||||||
|
|
||||||
while [ $attempt -lt $COUNT ]; do
|
while [ $attempt -lt $COUNT ]; do
|
||||||
msg "Downloading $file (attempt $((attempt+1)))..."
|
msg "Download $filename (attempt $((attempt+1)))..."
|
||||||
if wget -q -O "$filepath" "$url"; then
|
wget -q -O "$filepath" "https://git.ownsrv.ru/yanistyle/podkop/releases/download/$LATEST_TAG/$filename"
|
||||||
if [ -s "$filepath" ]; then
|
if [ -s "$filepath" ]; then
|
||||||
msg "$file successfully downloaded"
|
msg "$filename successfully downloaded"
|
||||||
|
download_success=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
msg "Download error $filename. Retry..."
|
||||||
msg "Download error $file. Retry..."
|
|
||||||
rm -f "$filepath"
|
rm -f "$filepath"
|
||||||
attempt=$((attempt+1))
|
attempt=$((attempt+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $attempt -eq $COUNT ]; then
|
if [ $attempt -eq $COUNT ]; then
|
||||||
msg "Failed to download $file after $COUNT attempts"
|
msg "Failed to download $filename after $COUNT attempts"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
|
||||||
|
|
||||||
install_packages() {
|
if [ $download_success -eq 0 ]; then
|
||||||
|
msg "No packages were downloaded successfully"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- Установка пакетов ---
|
||||||
for pkg in podkop luci-app-podkop; do
|
for pkg in podkop luci-app-podkop; do
|
||||||
file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1)
|
file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1)
|
||||||
if [ -n "$file" ]; then
|
if [ -n "$file" ]; then
|
||||||
@@ -82,9 +151,9 @@ install_packages() {
|
|||||||
opkg remove luci-i18n-podkop*
|
opkg remove luci-i18n-podkop*
|
||||||
opkg install "$DOWNLOAD_DIR/$ru"
|
opkg install "$DOWNLOAD_DIR/$ru"
|
||||||
else
|
else
|
||||||
msg "Русский язык интерфейса ставим? y/n (Need a Russian translation?)"
|
msg "Русский язык интерфейса ставим? y/n"
|
||||||
while true; do
|
while true; do
|
||||||
read -r RUS
|
read -r -p '' RUS
|
||||||
case $RUS in
|
case $RUS in
|
||||||
y)
|
y)
|
||||||
opkg remove luci-i18n-podkop*
|
opkg remove luci-i18n-podkop*
|
||||||
@@ -102,53 +171,7 @@ install_packages() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Чистим
|
|
||||||
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
|
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
|
||||||
}
|
}
|
||||||
|
|
||||||
check_system() {
|
|
||||||
MODEL=$(cat /tmp/sysinfo/model 2>/dev/null || echo "Unknown")
|
|
||||||
msg "Router model: $MODEL"
|
|
||||||
|
|
||||||
openwrt_version=$(cat /etc/openwrt_release 2>/dev/null | grep DISTRIB_RELEASE | cut -d"'" -f2 | cut -d'.' -f1 || echo "Unknown")
|
|
||||||
if [ "$openwrt_version" = "23" ]; then
|
|
||||||
msg "OpenWrt 23.05 не поддерживается начиная с podkop 0.5.0"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
AVAILABLE_SPACE=$(df /overlay 2>/dev/null | awk 'NR==2 {print $4}' || echo 0)
|
|
||||||
REQUIRED_SPACE=15360
|
|
||||||
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
|
|
||||||
msg "Insufficient space. Available: $((AVAILABLE_SPACE/1024))MB, Required: $((REQUIRED_SPACE/1024))MB"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! nslookup google.com >/dev/null 2>&1; then
|
|
||||||
msg "DNS not working"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if opkg list-installed | grep -q https-dns-proxy; then
|
|
||||||
msg "Сonflicting package detected: https-dns-proxy. Remove?"
|
|
||||||
while true; do
|
|
||||||
read -r DNSPROXY
|
|
||||||
case $DNSPROXY in
|
|
||||||
yes|y|Y) opkg remove --force-depends luci-app-https-dns-proxy https-dns-proxy luci-i18n-https-dns-proxy*; break ;;
|
|
||||||
*) msg "Exit"; exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
sing_box() {
|
|
||||||
if ! opkg list-installed | grep -q "^sing-box"; then return; fi
|
|
||||||
sing_box_version=$(sing-box version | head -n 1 | awk '{print $3}')
|
|
||||||
required_version="1.12.4"
|
|
||||||
if [ "$(echo -e "$sing_box_version\n$required_version" | sort -V | head -n 1)" != "$required_version" ]; then
|
|
||||||
msg "sing-box version $sing_box_version is older than required $required_version"
|
|
||||||
msg "Removing old version..."
|
|
||||||
opkg remove sing-box
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user