diff --git a/install.sh b/install.sh index a95c4e8..8a114e0 100755 --- a/install.sh +++ b/install.sh @@ -329,21 +329,21 @@ choose_modules() { script_dir() { case "$0" in */*) cd "$(dirname "$0")" 2>/dev/null && pwd ;; - *) pwd ;; + *) return 1 ;; esac } download_file() { src="$1" dst="$2" - local_dir="$(script_dir)" + local_dir="$(script_dir 2>/dev/null || true)" - if [ -f "$local_dir/$src" ]; then + if [ -n "$local_dir" ] && [ -f "$local_dir/$src" ]; then run cp "$local_dir/$src" "$dst" return 0 fi - if [ -f "$PWD/$src" ]; then + if [ "${LEMANA_VPN_USE_LOCAL_FILES:-0}" = "1" ] && [ -f "$PWD/$src" ]; then run cp "$PWD/$src" "$dst" return 0 fi diff --git a/tests/smoke.sh b/tests/smoke.sh index cceffce..5c5fbb8 100755 --- a/tests/smoke.sh +++ b/tests/smoke.sh @@ -29,4 +29,19 @@ status_text="$(bash "$ROOT/bin/vpn-lemanapro.sh" --status)" printf '%s\n' "$status_text" | grep -q 'app=' printf '%s\n' "$status_text" | grep -q 'autostart=' +fake_pwd="$TMP_DIR/fake-pwd" +mkdir -p "$fake_pwd/bin" +printf 'stale local cli\n' > "$fake_pwd/bin/vpn-lemanapro.sh" + +piped_output="$( + cd "$fake_pwd" && + LEMANA_VPN_RAW_BASE_URL="file://$ROOT" sh -s -- --dry-run --non-interactive --minimal --without-app < "$ROOT/install.sh" +)" + +printf '%s\n' "$piped_output" | grep -q "curl -fsSL file://$ROOT/bin/vpn-lemanapro.sh" +if printf '%s\n' "$piped_output" | grep -q "$fake_pwd/bin/vpn-lemanapro.sh"; then + echo "piped install used stale PWD/bin/vpn-lemanapro.sh" >&2 + exit 1 +fi + printf 'smoke ok\n'