Обновить install.sh
This commit is contained in:
93
install.sh
93
install.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
REPO="https://git.ownsrv.ru/yanistyle/podkop/releases/latest"
|
REPO_API="https://git.ownsrv.ru/api/v1/repos/yanistyle/podkop/releases"
|
||||||
DOWNLOAD_DIR="/tmp/podkop"
|
DOWNLOAD_DIR="/tmp/podkop"
|
||||||
COUNT=3
|
COUNT=3
|
||||||
|
|
||||||
@@ -18,52 +18,51 @@ main() {
|
|||||||
/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
|
||||||
|
|
||||||
opkg update || { echo "opkg update failed"; exit 1; }
|
opkg update || { echo "opkg update failed"; exit 1; }
|
||||||
|
|
||||||
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 "Installed podkop..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v curl &> /dev/null; then
|
|
||||||
check_response=$(curl -s "https://git.ownsrv.ru/yanistyle/podkop/releases/latest/")
|
|
||||||
|
|
||||||
if echo "$check_response" | grep -q 'API rate limit '; then
|
# --- Получаем последний релиз из Gitea ---
|
||||||
msg "You've reached rate limit from GitHub. Repeat in five minutes."
|
LATEST_TAG=$(curl -s "$REPO_API" | jq -r '.[0].tag_name')
|
||||||
exit 1
|
if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" = "null" ]; then
|
||||||
fi
|
msg "Не удалось получить последний релиз"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
msg "Последний релиз: $LATEST_TAG"
|
||||||
|
|
||||||
|
# --- Получаем список всех assets ---
|
||||||
|
ASSETS=$(curl -s "$REPO_API" | jq -r '.[0].assets[].name')
|
||||||
|
|
||||||
download_success=0
|
download_success=0
|
||||||
while read -r url; do
|
for filename in $ASSETS; do
|
||||||
filename=$(basename "$url")
|
|
||||||
filepath="$DOWNLOAD_DIR/$filename"
|
filepath="$DOWNLOAD_DIR/$filename"
|
||||||
|
|
||||||
attempt=0
|
attempt=0
|
||||||
while [ $attempt -lt $COUNT ]; do
|
while [ $attempt -lt $COUNT ]; do
|
||||||
msg "Download $filename (count $((attempt+1)))..."
|
msg "Download $filename (count $((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 "$filename successfully downloaded"
|
msg "$filename successfully downloaded"
|
||||||
download_success=1
|
download_success=1
|
||||||
break
|
break
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
msg "Download error $filename. Retry..."
|
msg "Download error $filename. 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 $filename after $COUNT attempts"
|
||||||
fi
|
fi
|
||||||
done < <(wget -qO- "$REPO" | grep -o 'https://[^"[:space:]]*\.ipk')
|
done
|
||||||
|
|
||||||
if [ $download_success -eq 0 ]; then
|
if [ $download_success -eq 0 ]; then
|
||||||
msg "No packages were downloaded successfully"
|
msg "No packages were downloaded successfully"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
||||||
@@ -76,25 +75,25 @@ main() {
|
|||||||
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
|
||||||
msg "Upgraded ru translation..."
|
msg "Upgraded ru translation..."
|
||||||
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 (Need a Russian translation?)"
|
||||||
while true; do
|
while true; do
|
||||||
read -r -p '' RUS
|
read -r -p '' RUS
|
||||||
case $RUS in
|
case $RUS in
|
||||||
y)
|
y)
|
||||||
opkg remove luci-i18n-podkop*
|
opkg remove luci-i18n-podkop*
|
||||||
opkg install "$DOWNLOAD_DIR/$ru"
|
opkg install "$DOWNLOAD_DIR/$ru"
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
n)
|
n)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Введите y или n"
|
echo "Введите y или n"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@@ -103,24 +102,19 @@ main() {
|
|||||||
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
|
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --- Проверка системы ---
|
||||||
check_system() {
|
check_system() {
|
||||||
# Get router model
|
|
||||||
MODEL=$(cat /tmp/sysinfo/model)
|
MODEL=$(cat /tmp/sysinfo/model)
|
||||||
msg "Router model: $MODEL"
|
msg "Router model: $MODEL"
|
||||||
|
|
||||||
# Check OpenWrt version
|
|
||||||
openwrt_version=$(cat /etc/openwrt_release | grep DISTRIB_RELEASE | cut -d"'" -f2 | cut -d'.' -f1)
|
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"
|
||||||
msg "Для OpenWrt 23.05 используйте podkop версии 0.4.11 или устанавливайте зависимости и podkop вручную"
|
|
||||||
msg "Подробности: https://podkop.net/docs/install/#%d1%83%d1%81%d1%82%d0%b0%d0%bd%d0%be%d0%b2%d0%ba%d0%b0-%d0%bd%d0%b0-2305"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check available space
|
|
||||||
AVAILABLE_SPACE=$(df /overlay | awk 'NR==2 {print $4}')
|
AVAILABLE_SPACE=$(df /overlay | awk 'NR==2 {print $4}')
|
||||||
REQUIRED_SPACE=15360 # 15MB in KB
|
REQUIRED_SPACE=15360
|
||||||
|
|
||||||
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
|
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
|
||||||
msg "Error: Insufficient space in flash"
|
msg "Error: Insufficient space in flash"
|
||||||
msg "Available: $((AVAILABLE_SPACE/1024))MB"
|
msg "Available: $((AVAILABLE_SPACE/1024))MB"
|
||||||
@@ -135,11 +129,9 @@ check_system() {
|
|||||||
|
|
||||||
if opkg list-installed | grep -q https-dns-proxy; then
|
if opkg list-installed | grep -q https-dns-proxy; then
|
||||||
msg "Сonflicting package detected: https-dns-proxy. Remove?"
|
msg "Сonflicting package detected: https-dns-proxy. Remove?"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
read -r -p '' DNSPROXY
|
read -r -p '' DNSPROXY
|
||||||
case $DNSPROXY in
|
case $DNSPROXY in
|
||||||
|
|
||||||
yes|y|Y|yes)
|
yes|y|Y|yes)
|
||||||
opkg remove --force-depends luci-app-https-dns-proxy https-dns-proxy luci-i18n-https-dns-proxy*
|
opkg remove --force-depends luci-app-https-dns-proxy https-dns-proxy luci-i18n-https-dns-proxy*
|
||||||
break
|
break
|
||||||
@@ -148,8 +140,8 @@ check_system() {
|
|||||||
msg "Exit"
|
msg "Exit"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,10 +149,8 @@ sing_box() {
|
|||||||
if ! opkg list-installed | grep -q "^sing-box"; then
|
if ! opkg list-installed | grep -q "^sing-box"; then
|
||||||
return
|
return
|
||||||
fi
|
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 "sing-box version $sing_box_version is older than required $required_version"
|
msg "sing-box version $sing_box_version is older than required $required_version"
|
||||||
msg "Removing old version..."
|
msg "Removing old version..."
|
||||||
@@ -169,3 +159,4 @@ sing_box() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user