fix: handle pipefail exits in detect_defaults, docker ps, and curl|jq pipelines
This commit is contained in:
parent
e1260ba5d3
commit
c7cd5550bc
1 changed files with 6 additions and 6 deletions
12
install.sh
Normal file → Executable file
12
install.sh
Normal file → Executable file
|
|
@ -119,16 +119,16 @@ install_deps() {
|
|||
#==============================================================================
|
||||
|
||||
detect_defaults() {
|
||||
# Auto-detect primary network interface
|
||||
IFACE_DEFAULT=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $5; exit}')
|
||||
# Auto-detect primary network interface (graceful fallback if ip route fails)
|
||||
IFACE_DEFAULT=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $5; exit}' || true)
|
||||
[ -z "$IFACE_DEFAULT" ] && IFACE_DEFAULT="eth0"
|
||||
|
||||
# Auto-detect gateway
|
||||
GATEWAY_DEFAULT=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $3; exit}')
|
||||
GATEWAY_DEFAULT=$(ip route get 1.1.1.1 2>/dev/null | awk '{print $3; exit}' || true)
|
||||
[ -z "$GATEWAY_DEFAULT" ] && GATEWAY_DEFAULT="10.2.0.10"
|
||||
|
||||
# Auto-detect DNS from resolv.conf
|
||||
DNS_DEFAULT=$(grep '^nameserver' /etc/resolv.conf 2>/dev/null | awk '{print $2}' | tr '\n' ',' | sed 's/,$//')
|
||||
DNS_DEFAULT=$( (grep '^nameserver' /etc/resolv.conf 2>/dev/null || true) | awk '{print $2}' | tr '\n' ',' | sed 's/,$//')
|
||||
[ -z "$DNS_DEFAULT" ] && DNS_DEFAULT="1.1.1.1,8.8.8.8"
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ detect_zoraxy() {
|
|||
# --- Check Docker ---
|
||||
if command -v docker &>/dev/null && docker info &>/dev/null 2>&1; then
|
||||
local zoraxy_container
|
||||
zoraxy_container=$(docker ps --format '{{.Names}} {{.Image}}' 2>/dev/null | grep -i zoraxy | head -1 | awk '{print $1}')
|
||||
zoraxy_container=$(docker ps --format '{{.Names}} {{.Image}}' 2>/dev/null | grep -i zoraxy | head -1 | awk '{print $1}' || true)
|
||||
if [ -n "$zoraxy_container" ]; then
|
||||
ZORAXY_MODE="docker"
|
||||
info "Found Zoraxy in Docker container: ${BOLD}$zoraxy_container${NC}"
|
||||
|
|
@ -421,7 +421,7 @@ install_zoraxy_fresh() {
|
|||
# Download latest release
|
||||
local latest_url
|
||||
latest_url=$(curl -s https://api.github.com/repos/tobychui/zoraxy/releases/latest \
|
||||
| jq -r ".assets[] | select(.name | contains(\"$binary\")) | .browser_download_url" 2>/dev/null)
|
||||
| jq -r ".assets[] | select(.name | contains(\"$binary\")) | .browser_download_url" 2>/dev/null || true)
|
||||
|
||||
if [ -z "$latest_url" ] || [ "$latest_url" = "null" ]; then
|
||||
err "Failed to fetch Zoraxy download URL. Check your internet connection."
|
||||
|
|
|
|||
Loading…
Reference in a new issue