Compare commits

...

11 Commits
v0.5.6 ... main

3 changed files with 112 additions and 106 deletions

View File

@@ -20,7 +20,7 @@ https://podkop.net/
Вкратце, достаточно одного скрипта для установки и обновления:
```
sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/podkop/refs/heads/main/install.sh)
sh <(wget -O - https://git.ownsrv.ru/yanistyle/podkop/raw/branch/main/install.sh))
```
# ToDo

View File

@@ -1,6 +1,7 @@
#!/bin/sh
REPO="https://api.github.com/repos/itdoginfo/podkop/releases/latest"
# --- Настройки ---
REPO_API="https://git.ownsrv.ru/api/v1/repos/yanistyle/podkop/releases"
DOWNLOAD_DIR="/tmp/podkop"
COUNT=3
@@ -11,59 +12,129 @@ 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() {
check_system
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
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
if command -v curl &> /dev/null; then
check_response=$(curl -s "https://api.github.com/repos/itdoginfo/podkop/releases/latest")
if echo "$check_response" | grep -q 'API rate limit '; then
msg "You've reached rate limit from GitHub. Repeat in five minutes."
exit 1
fi
# --- Получаем последний релиз из Gitea ---
msg "Fetching latest release info from Gitea..."
LATEST_TAG=$(curl -s "$REPO_API" | jq -r '.[0].tag_name')
if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" = "null" ]; then
msg "Не удалось получить последний релиз"
exit 1
fi
msg "Последний релиз: $LATEST_TAG"
# --- Получаем список всех assets ---
ASSETS=$(curl -s "$REPO_API" | jq -r '.[0].assets[].name')
download_success=0
while read -r url; do
filename=$(basename "$url")
for filename in $ASSETS; do
filepath="$DOWNLOAD_DIR/$filename"
attempt=0
while [ $attempt -lt $COUNT ]; do
msg "Download $filename (count $((attempt+1)))..."
if wget -q -O "$filepath" "$url"; then
if [ -s "$filepath" ]; then
msg "$filename successfully downloaded"
download_success=1
break
fi
msg "Download $filename (attempt $((attempt+1)))..."
wget -q -O "$filepath" "https://git.ownsrv.ru/yanistyle/podkop/releases/download/$LATEST_TAG/$filename"
if [ -s "$filepath" ]; then
msg "$filename successfully downloaded"
download_success=1
break
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 < <(wget -qO- "$REPO" | grep -o 'https://[^"[:space:]]*\.ipk')
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
@@ -76,25 +147,25 @@ main() {
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"
msg "Upgraded ru translation..."
opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru"
else
msg "Русский язык интерфейса ставим? y/n (Need a Russian translation?)"
msg "Русский язык интерфейса ставим? y/n"
while true; do
read -r -p '' RUS
case $RUS in
y)
opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru"
break
;;
n)
break
;;
*)
echo "Введите y или n"
;;
y)
opkg remove luci-i18n-podkop*
opkg install "$DOWNLOAD_DIR/$ru"
break
;;
n)
break
;;
*)
echo "Введите y или n"
;;
esac
done
fi
@@ -103,69 +174,4 @@ main() {
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
}
check_system() {
# Get router model
MODEL=$(cat /tmp/sysinfo/model)
msg "Router model: $MODEL"
# Check OpenWrt version
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"
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
fi
# Check available space
AVAILABLE_SPACE=$(df /overlay | awk 'NR==2 {print $4}')
REQUIRED_SPACE=15360 # 15MB in KB
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
msg "Error: Insufficient space in flash"
msg "Available: $((AVAILABLE_SPACE/1024))MB"
msg "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|yes)
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

View File

@@ -48,8 +48,8 @@ SB_MAIN_OUTBOUND_TAG="main-out"
SB_REJECT_RULE_TAG="reject-rule-tag"
## Lists
GITHUB_RAW_URL="https://raw.githubusercontent.com/itdoginfo/allow-domains/main"
SRS_MAIN_URL="https://github.com/itdoginfo/allow-domains/releases/latest/download"
GITHUB_RAW_URL="https://git.ownsrv.ru/yanistyle/allow-domains/src/branch/main"
SRS_MAIN_URL="https://git.ownsrv.ru/yanistyle/allow-domains/releases/latest"
DOMAINS_RU_INSIDE="${GITHUB_RAW_URL}/Russia/inside-dnsmasq-nfset.lst"
DOMAINS_RU_OUTSIDE="${GITHUB_RAW_URL}/Russia/outside-dnsmasq-nfset.lst"
DOMAINS_UA="${GITHUB_RAW_URL}/Ukraine/inside-dnsmasq-nfset.lst"