Files
podkop/install.sh
2025-09-22 13:17:58 +03:00

129 lines
3.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
REPO="https://git.ownsrv.ru/yanistyle/podkop/releases/latest"
DOWNLOAD_DIR="/tmp/podkop"
COUNT=3
rm -rf "$DOWNLOAD_DIR"
mkdir -p "$DOWNLOAD_DIR"
msg() {
printf "\033[32;1m%s\033[0m\n" "$1"
}
main() {
check_system
sing_box
/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
opkg update || { echo "opkg update failed"; exit 1; }
if [ -f "/etc/init.d/podkop" ]; then
msg "Podkop is already installed. Upgraded..."
else
msg "Installed podkop..."
fi
download_success=0
# Берём страницу latest release и вытаскиваем все ссылки на .ipk
wget -qO- "$REPO" | grep -o 'https://[^"]*\.ipk' | while read -r url; do
filename=$(basename "$url")
filepath="$DOWNLOAD_DIR/$filename"
attempt=0
while [ $attempt -lt $COUNT ]; do
msg "Download $filename (attempt $((attempt+1)))..."
if wget -q -O "$filepath" "$url"; then
if [ -s "$filepath" ]; then
msg "$filename successfully downloaded"
download_success=1
break
fi
fi
msg "Download error $filename. Retry..."
rm -f "$filepath"
attempt=$((attempt+1))
done
if [ $attempt -eq $COUNT ]; then
msg "Failed to download $filename after $COUNT attempts"
fi
done
if [ $download_success -eq 0 ]; then
msg "No packages were downloaded successfully"
exit 1
fi
# Установка пакетов
for pkg in podkop luci-app-podkop; do
file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1)
if [ -n "$file" ]; then
msg "Installing $file"
opkg install "$DOWNLOAD_DIR/$file"
sleep 3
fi
done
# Русский перевод
ru=$(ls "$DOWNLOAD_DIR" | grep "luci-i18n-podkop-ru" | head -n 1)
if [ -n "$ru" ]; then
if opkg list-installed | grep -q luci-i18n-podkop-ru; then
msg "Upgraded ru translation..."
opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru"
else
msg "Installing Russian translation..."
opkg install "$DOWNLOAD_DIR/$ru"
fi
fi
# Очистка временной папки
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
}
check_system() {
# Проверка модели роутера
MODEL=$(cat /tmp/sysinfo/model)
msg "Router model: $MODEL"
# Проверка версии OpenWrt
openwrt_version=$(cat /etc/openwrt_release | 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 "Insufficient space in flash"
exit 1
fi
# Проверка DNS
if ! nslookup google.com >/dev/null 2>&1; then
msg "DNS not working"
exit 1
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 "Removing old sing-box version $sing_box_version..."
opkg remove sing-box
fi
}
main