Обновить install.sh

This commit is contained in:
2025-09-22 13:27:39 +03:00
parent 9dfb6b410f
commit 07527fa8a7

View File

@@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
REPO="https://git.ownsrv.ru/yanistyle/podkop/releases/latest" # --- Настройки ---
GITEA_API="https://git.ownsrv.ru/api/v1/repos/yanistyle/podkop/releases/latest"
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() { msg() { printf "\033[32;1m%s\033[0m\n" "$1"; }
printf "\033[32;1m%s\033[0m\n" "$1"
}
main() { main() {
check_system check_system
@@ -22,42 +22,50 @@ 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 "Installed podkop..." msg "Installing podkop..."
fi fi
download_success=0 download_packages
install_packages
}
# Берём страницу latest release и вытаскиваем все ссылки на .ipk download_packages() {
wget -qO- "$REPO" | grep -o 'https://[^"]*\.ipk' | while read -r url; do msg "Fetching latest release info from Gitea..."
filename=$(basename "$url") RELEASE_JSON=$(wget -qO- --header="Authorization: token $TOKEN" "$GITEA_API")
filepath="$DOWNLOAD_DIR/$filename"
# Находим все .ipk ссылки
URLS=$(echo "$RELEASE_JSON" | grep -o 'https://[^"]*\.ipk')
if [ -z "$URLS" ]; then
msg "No packages found in latest release"
exit 1
fi
for url in $URLS; do
file=$(basename "$url")
filepath="$DOWNLOAD_DIR/$file"
attempt=0 attempt=0
while [ $attempt -lt $COUNT ]; do while [ $attempt -lt $COUNT ]; do
msg "Download $filename (attempt $((attempt+1)))..." msg "Downloading $file (attempt $((attempt+1)))..."
if wget -q -O "$filepath" "$url"; then if wget -q -O "$filepath" "$url"; then
if [ -s "$filepath" ]; then if [ -s "$filepath" ]; then
msg "$filename successfully downloaded" msg "$file successfully downloaded"
download_success=1
break break
fi 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 $filename after $COUNT attempts" msg "Failed to download $file after $COUNT attempts"
fi fi
done done
}
if [ $download_success -eq 0 ]; then install_packages() {
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
@@ -67,7 +75,6 @@ main() {
fi fi
done done
# Русский перевод
ru=$(ls "$DOWNLOAD_DIR" | grep "luci-i18n-podkop-ru" | head -n 1) ru=$(ls "$DOWNLOAD_DIR" | grep "luci-i18n-podkop-ru" | head -n 1)
if [ -n "$ru" ]; then if [ -n "$ru" ]; then
if opkg list-installed | grep -q luci-i18n-podkop-ru; then if opkg list-installed | grep -q luci-i18n-podkop-ru; then
@@ -75,52 +82,71 @@ main() {
opkg remove luci-i18n-podkop* opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru" opkg install "$DOWNLOAD_DIR/$ru"
else else
msg "Installing Russian translation..." msg "Русский язык интерфейса ставим? y/n (Need a Russian translation?)"
opkg install "$DOWNLOAD_DIR/$ru" while true; do
read -r RUS
case $RUS in
y)
opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru"
break
;;
n)
break
;;
*)
echo "Введите y или n"
;;
esac
done
fi fi
fi fi
# Очистка временной папки # Чистим
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \; find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
} }
check_system() { check_system() {
# Проверка модели роутера MODEL=$(cat /tmp/sysinfo/model 2>/dev/null || echo "Unknown")
MODEL=$(cat /tmp/sysinfo/model)
msg "Router model: $MODEL" msg "Router model: $MODEL"
# Проверка версии OpenWrt openwrt_version=$(cat /etc/openwrt_release 2>/dev/null | grep DISTRIB_RELEASE | cut -d"'" -f2 | cut -d'.' -f1 || echo "Unknown")
openwrt_version=$(cat /etc/openwrt_release | grep DISTRIB_RELEASE | cut -d"'" -f2 | cut -d'.' -f1)
if [ "$openwrt_version" = "23" ]; then if [ "$openwrt_version" = "23" ]; then
msg "OpenWrt 23.05 не поддерживается начиная с podkop 0.5.0" msg "OpenWrt 23.05 не поддерживается начиная с podkop 0.5.0"
exit 1 exit 1
fi fi
# Проверка места AVAILABLE_SPACE=$(df /overlay 2>/dev/null | awk 'NR==2 {print $4}' || echo 0)
AVAILABLE_SPACE=$(df /overlay | awk 'NR==2 {print $4}')
REQUIRED_SPACE=15360 REQUIRED_SPACE=15360
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
msg "Insufficient space in flash" msg "Insufficient space. Available: $((AVAILABLE_SPACE/1024))MB, Required: $((REQUIRED_SPACE/1024))MB"
exit 1 exit 1
fi fi
# Проверка DNS
if ! nslookup google.com >/dev/null 2>&1; then if ! nslookup google.com >/dev/null 2>&1; then
msg "DNS not working" msg "DNS not working"
exit 1 exit 1
fi 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() { sing_box() {
if ! opkg list-installed | grep -q "^sing-box"; then if ! opkg list-installed | grep -q "^sing-box"; then return; fi
return
fi
sing_box_version=$(sing-box version | head -n 1 | awk '{print $3}') sing_box_version=$(sing-box version | head -n 1 | awk '{print $3}')
required_version="1.12.4" required_version="1.12.4"
if [ "$(echo -e "$sing_box_version\n$required_version" | sort -V | head -n 1)" != "$required_version" ]; then if [ "$(echo -e "$sing_box_version\n$required_version" | sort -V | head -n 1)" != "$required_version" ]; then
msg "Removing old sing-box version $sing_box_version..." msg "sing-box version $sing_box_version is older than required $required_version"
msg "Removing old version..."
opkg remove sing-box opkg remove sing-box
fi fi
} }