fix: make sshpass optional for architectures where it is missing

This commit is contained in:
Petro1990 2026-03-13 14:30:38 +03:00
parent 02a0536b11
commit 777133c13d
2 changed files with 24 additions and 8 deletions

View File

@ -57,7 +57,12 @@ install_pkg() {
install_pkg "openssh-client" install_pkg "openssh-client"
install_pkg "autossh" install_pkg "autossh"
install_pkg "curl" install_pkg "curl"
install_pkg "sshpass"
# sshpass is optional (needed only for password auth, may be missing on some architectures)
if ! opkg list-installed 2>/dev/null | grep -q "^sshpass "; then
msg "Пытаюсь установить sshpass (необязательно)..."
opkg install "sshpass" >/dev/null 2>&1 || warn "Пакет sshpass не найден. Авторизация по паролю будет недоступна (только по SSH-ключу)."
fi
# ─── Download rproxy script ───────────────────────────────────────── # ─── Download rproxy script ─────────────────────────────────────────
msg "Скачиваю rproxy..." msg "Скачиваю rproxy..."

25
rproxy
View File

@ -69,6 +69,11 @@ load_service() {
ssh_cmd() { ssh_cmd() {
if [ "$VPS_AUTH" = "password" ]; then if [ "$VPS_AUTH" = "password" ]; then
if ! command -v sshpass >/dev/null 2>&1; then
err "Утилита sshpass не найдена. Авторизация по паролю невозможна."
err "Пожалуйста, перенастройте rProxy на использование SSH-ключа (rproxy setup)."
return 1
fi
sshpass -p "$VPS_PASS" ssh -o StrictHostKeyChecking=no -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "$@" sshpass -p "$VPS_PASS" ssh -o StrictHostKeyChecking=no -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "$@"
else else
ssh -o StrictHostKeyChecking=no -i "$SSH_KEY" -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "$@" ssh -o StrictHostKeyChecking=no -i "$SSH_KEY" -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "$@"
@ -77,6 +82,10 @@ ssh_cmd() {
scp_cmd() { scp_cmd() {
if [ "$VPS_AUTH" = "password" ]; then if [ "$VPS_AUTH" = "password" ]; then
if ! command -v sshpass >/dev/null 2>&1; then
err "Утилита sshpass не найдена. Копирование по паролю невозможно."
return 1
fi
sshpass -p "$VPS_PASS" scp -o StrictHostKeyChecking=no -P "$VPS_PORT" "$@" sshpass -p "$VPS_PASS" scp -o StrictHostKeyChecking=no -P "$VPS_PORT" "$@"
else else
scp -o StrictHostKeyChecking=no -i "$SSH_KEY" -P "$VPS_PORT" "$@" scp -o StrictHostKeyChecking=no -i "$SSH_KEY" -P "$VPS_PORT" "$@"
@ -659,19 +668,21 @@ do_setup() {
if [ "$auth_choice" = "2" ]; then if [ "$auth_choice" = "2" ]; then
vps_auth="password" vps_auth="password"
if ! command -v sshpass >/dev/null 2>&1; then
printf "\n ${RED}✖ Ошибка: Утилита sshpass не найдена в системе.${NC}\n"
printf " Для вашего роутера этот пакет недоступен в репозитории.\n"
printf " Пожалуйста, используйте авторизацию по SSH-ключу.\n"
pause
return
fi
printf " SSH пароль: " printf " SSH пароль: "
stty -echo 2>/dev/null stty -echo 2>/dev/null
read -r vps_pass read -r vps_pass
stty echo 2>/dev/null stty echo 2>/dev/null
printf "\n" printf "\n"
if ! command -v sshpass >/dev/null 2>&1; then
msg "Устанавливаю sshpass..."
opkg install sshpass 2>/dev/null || {
err "Не удалось установить sshpass. Установите вручную: opkg install sshpass"
pause
return
}
fi fi
else else
if [ ! -f "$SSH_KEY" ]; then if [ ! -f "$SSH_KEY" ]; then