Skip to content

Commit f629168

Browse files
committed
fixes
1 parent a4335f8 commit f629168

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

cmd/push-validator/cmd_chain.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Examples:
167167

168168
verifyBinary := func(path string) (string, error) {
169169
verCmd := exec.Command(path, "version")
170+
verCmd.Stdin = nil
170171
out, err := verCmd.Output()
171172
if err != nil {
172173
return "", err

install.sh

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ download_with_progress() {
223223
# Get size for percentage reporting
224224
total_size=$(curl -sLI "$url" 2>/dev/null | grep -i '^content-length:' | tail -1 | awk '{print $2}' | tr -d '\r\n')
225225
total_size=${total_size:-0}
226-
curl -sL -o "$output_file" "$url" &
226+
curl -sL -o "$output_file" "$url" < /dev/null &
227227
else
228228
total_size=$(wget --spider --server-response "$url" 2>&1 | grep -i 'content-length:' | tail -1 | awk '{print $2}' | tr -d '\r\n')
229229
total_size=${total_size:-0}
230-
wget -q -O "$output_file" "$url" &
230+
wget -q -O "$output_file" "$url" < /dev/null &
231231
fi
232232
local dl_pid=$!
233233
local last_threshold=-1
@@ -262,10 +262,10 @@ download_with_progress() {
262262
start_epoch=$(date +%s)
263263

264264
if [[ $use_curl -eq 1 ]]; then
265-
curl -sL -o "$output_file" "$url" &
265+
curl -sL -o "$output_file" "$url" < /dev/null &
266266
dl_pid=$!
267267
else
268-
wget -q -O "$output_file" "$url" &
268+
wget -q -O "$output_file" "$url" < /dev/null &
269269
dl_pid=$!
270270
fi
271271

@@ -299,9 +299,9 @@ node_running() {
299299
local TO; TO=$(timeout_cmd)
300300
local status_json
301301
if [[ -n "$TO" ]]; then
302-
status_json=$($TO 2 "$MANAGER_BIN" status --output json 2>/dev/null || echo "{}")
302+
status_json=$($TO 2 "$MANAGER_BIN" status --output json < /dev/null 2>/dev/null || echo "{}")
303303
else
304-
status_json=$("$MANAGER_BIN" status --output json 2>/dev/null || echo "{}")
304+
status_json=$("$MANAGER_BIN" status --output json < /dev/null 2>/dev/null || echo "{}")
305305
fi
306306

307307
if command -v jq >/dev/null 2>&1; then
@@ -327,7 +327,7 @@ stop_all_processes() {
327327

328328
# 1. Try graceful stop via manager first
329329
if [[ -x "$MANAGER_BIN" ]]; then
330-
$use_sudo "$MANAGER_BIN" stop >/dev/null 2>&1 || true
330+
$use_sudo "$MANAGER_BIN" stop < /dev/null >/dev/null 2>&1 || true
331331
sleep 2
332332
fi
333333

@@ -386,7 +386,7 @@ any_node_running() {
386386
# Helper: Check if current node consensus key already exists in validator set
387387
node_is_validator() {
388388
local result
389-
if ! result=$("$MANAGER_BIN" register-validator --check-only --output json 2>/dev/null); then
389+
if ! result=$("$MANAGER_BIN" register-validator --check-only --output json < /dev/null 2>/dev/null); then
390390
return 1
391391
fi
392392
if command -v jq >/dev/null 2>&1; then
@@ -573,9 +573,9 @@ install_go() {
573573
update_shell_profile "$install_dir/go"
574574

575575
# Verify installation
576-
if "$install_dir/go/bin/go" version >/dev/null 2>&1; then
576+
if "$install_dir/go/bin/go" version < /dev/null >/dev/null 2>&1; then
577577
local installed_version
578-
installed_version=$("$install_dir/go/bin/go" version | awk '{print $3}')
578+
installed_version=$("$install_dir/go/bin/go" version < /dev/null | awk '{print $3}')
579579
ok "Go installed successfully: $installed_version"
580580
echo
581581
echo -e "${GREEN}Go has been installed to: $install_dir/go${NC}"
@@ -723,7 +723,7 @@ download_pchaind() {
723723
# Verify installation
724724
if [[ -x "$COSMOVISOR_GENESIS_BIN/pchaind" ]]; then
725725
local installed_version
726-
installed_version=$("$COSMOVISOR_GENESIS_BIN/pchaind" version 2>&1 | head -1 || echo "")
726+
installed_version=$("$COSMOVISOR_GENESIS_BIN/pchaind" version < /dev/null 2>&1 | head -1 || echo "")
727727
if [[ -n "$installed_version" ]]; then
728728
ok "Installed pchaind ($installed_version)"
729729
else
@@ -860,7 +860,7 @@ download_push_validator() {
860860
# Verify installation
861861
if [[ -x "$MANAGER_BIN" ]]; then
862862
local installed_version
863-
installed_version=$("$MANAGER_BIN" version 2>&1 | awk '{print $2}' || echo "")
863+
installed_version=$("$MANAGER_BIN" version < /dev/null 2>&1 | awk '{print $2}' || echo "")
864864
if [[ -n "$installed_version" ]]; then
865865
ok "Installed push-validator ($installed_version)"
866866
else
@@ -1109,7 +1109,7 @@ elif pgrep -f "pchaind.*start" >/dev/null 2>&1; then
11091109
HAS_RUNNING_NODE="yes"
11101110
elif [[ -x "$MANAGER_BIN" ]] && command -v "$MANAGER_BIN" >/dev/null 2>&1; then
11111111
# Manager exists, check if node is actually running via status
1112-
STATUS_JSON=$("$MANAGER_BIN" status --output json 2>/dev/null || echo "{}")
1112+
STATUS_JSON=$("$MANAGER_BIN" status --output json < /dev/null 2>/dev/null || echo "{}")
11131113
if echo "$STATUS_JSON" | grep -q '"running"[[:space:]]*:[[:space:]]*true'; then
11141114
HAS_RUNNING_NODE="yes"
11151115
fi
@@ -1167,7 +1167,7 @@ if ! command -v go >/dev/null 2>&1; then
11671167
warn "Go is not installed"
11681168
else
11691169
# Validate Go version (requires 1.23+ for cosmovisor)
1170-
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
1170+
GO_VERSION=$(go version < /dev/null | awk '{print $3}' | sed 's/go//')
11711171
GO_MAJOR=$(echo "$GO_VERSION" | cut -d. -f1)
11721172
GO_MINOR=$(echo "$GO_VERSION" | cut -d. -f2)
11731173

@@ -1205,7 +1205,7 @@ if [[ $GO_NEEDS_INSTALL -eq 1 ]] || [[ $GO_NEEDS_UPGRADE -eq 1 ]]; then
12051205

12061206
# Verify installation worked
12071207
if command -v go >/dev/null 2>&1; then
1208-
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
1208+
GO_VERSION=$(go version < /dev/null | awk '{print $3}' | sed 's/go//')
12091209
verbose "Go successfully installed: $GO_VERSION"
12101210
else
12111211
err "Go installation completed but 'go' command not found in PATH"
@@ -1236,7 +1236,7 @@ if [[ $GO_NEEDS_INSTALL -eq 1 ]] || [[ $GO_NEEDS_UPGRADE -eq 1 ]]; then
12361236

12371237
# Verify installation worked
12381238
if command -v go >/dev/null 2>&1; then
1239-
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
1239+
GO_VERSION=$(go version < /dev/null | awk '{print $3}' | sed 's/go//')
12401240
verbose "Go successfully installed: $GO_VERSION"
12411241
else
12421242
err "Go installation completed but 'go' command not found in PATH"
@@ -1290,7 +1290,7 @@ fi
12901290
# Store environment info (will print after manager is built)
12911291
OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
12921292
OS_ARCH=$(uname -m)
1293-
GO_VER=$(go version | awk '{print $3}' | sed 's/go//')
1293+
GO_VER=$(go version < /dev/null | awk '{print $3}' | sed 's/go//')
12941294
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
12951295

12961296
# Calculate total phases needed (detection already done above before mkdir)
@@ -1353,7 +1353,7 @@ if [[ "$USE_LOCAL" = "yes" || -n "$LOCAL_REPO" ]]; then
13531353
if [[ -x "$MANAGER_BIN" ]]; then
13541354
CURRENT_COMMIT=$(cd "$REPO_DIR" && git rev-parse --short HEAD 2>/dev/null || echo "unknown")
13551355
# Extract commit from version output (format: "push-validator vX.Y.Z (1f599bd) built ...")
1356-
INSTALLED_COMMIT=$("$MANAGER_BIN" version 2>/dev/null | sed -n 's/.*(\([0-9a-f]\{7,\}\)).*/\1/p')
1356+
INSTALLED_COMMIT=$("$MANAGER_BIN" version < /dev/null 2>/dev/null | sed -n 's/.*(\([0-9a-f]\{7,\}\)).*/\1/p')
13571357
# Only skip build if both are valid hex commits and match
13581358
if [[ "$CURRENT_COMMIT" =~ ^[0-9a-f]+$ ]] && [[ "$INSTALLED_COMMIT" =~ ^[0-9a-f]+$ ]] && [[ "$CURRENT_COMMIT" == "$INSTALLED_COMMIT" ]]; then
13591359
step "Manager already up-to-date ($CURRENT_COMMIT) - skipped"
@@ -1408,7 +1408,7 @@ ok "Manager installed: $MANAGER_BIN"
14081408
MANAGER_VER_BANNER="dev unknown"
14091409
if [[ -x "$MANAGER_BIN" ]]; then
14101410
# Parse full version output: "push-validator v1.0.0 (abc1234) built 2025-01-08"
1411-
MANAGER_FULL=$("$MANAGER_BIN" version 2>/dev/null || echo "unknown")
1411+
MANAGER_FULL=$("$MANAGER_BIN" version < /dev/null 2>/dev/null || echo "unknown")
14121412
if [[ "$MANAGER_FULL" != "unknown" ]]; then
14131413
MANAGER_VER_BANNER=$(echo "$MANAGER_FULL" | awk '{print $2, $3}' | sed 's/[()]//g')
14141414
fi
@@ -1438,7 +1438,7 @@ if [[ "$PCHAIN_REF" =~ ^v[0-9] ]]; then
14381438
VERSION_FLAG="--version $PCHAIN_REF"
14391439
fi
14401440

1441-
if ! "$MANAGER_BIN" chain install $VERSION_FLAG --home "$HOME_DIR"; then
1441+
if ! "$MANAGER_BIN" chain install $VERSION_FLAG --home "$HOME_DIR" < /dev/null; then
14421442
err "Failed to download pchaind binary"
14431443
echo
14441444
echo "Please check your internet connection and try again."
@@ -1454,7 +1454,7 @@ verbose "Using built-in WebSocket monitor (no external dependency)"
14541454
# Install Cosmovisor for automatic upgrades (pinned to v1.7.1)
14551455
step "Installing Cosmovisor for automatic upgrades"
14561456
if ! command -v cosmovisor >/dev/null 2>&1; then
1457-
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.7.1
1457+
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.7.1 < /dev/null
14581458
ok "Cosmovisor v1.7.1 installed"
14591459
else
14601460
ok "Cosmovisor already installed"
@@ -1469,7 +1469,7 @@ if [[ "$AUTO_START" = "yes" ]]; then
14691469
step "Downloading blockchain snapshot (~6-7GB)"
14701470
"$MANAGER_BIN" snapshot download \
14711471
--home "$HOME_DIR" \
1472-
--snapshot-url "$SNAPSHOT_URL" || { err "snapshot download failed"; exit 1; }
1472+
--snapshot-url "$SNAPSHOT_URL" < /dev/null || { err "snapshot download failed"; exit 1; }
14731473
ok "Snapshot cached"
14741474

14751475
next_phase "Initializing Node"
@@ -1483,7 +1483,7 @@ if [[ "$AUTO_START" = "yes" ]]; then
14831483
--genesis-domain "$GENESIS_DOMAIN" \
14841484
--snapshot-url "$SNAPSHOT_URL" \
14851485
--skip-snapshot \
1486-
--bin "${PCHAIND:-pchaind}" 2>&1 | indent_output || { err "init failed"; exit 1; }
1486+
--bin "${PCHAIND:-pchaind}" < /dev/null 2>&1 | indent_output || { err "init failed"; exit 1; }
14871487
ok "Node initialized"
14881488

14891489
# Optimize config for faster sync
@@ -1524,7 +1524,7 @@ if [[ "$AUTO_START" = "yes" ]]; then
15241524
"$MANAGER_BIN" snapshot extract \
15251525
--home "$HOME_DIR" \
15261526
--target "$DATA_DIR" \
1527-
--force || { err "snapshot extract failed"; exit 1; }
1527+
--force < /dev/null || { err "snapshot extract failed"; exit 1; }
15281528

15291529
# Mark snapshot as downloaded
15301530
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$SNAPSHOT_MARKER"
@@ -1542,12 +1542,12 @@ if [[ "$AUTO_START" = "yes" ]]; then
15421542
step "Restarting node (attempt $((RETRY_COUNT + 1))/$((MAX_RETRIES + 1)))"
15431543
fi
15441544

1545-
"$MANAGER_BIN" start --no-prompt --home "$HOME_DIR" --bin "${PCHAIND:-pchaind}" 2>&1 | indent_output || { err "start failed"; exit 1; }
1545+
"$MANAGER_BIN" start --no-prompt --home "$HOME_DIR" --bin "${PCHAIND:-pchaind}" < /dev/null 2>&1 | indent_output || { err "start failed"; exit 1; }
15461546

15471547
step "Waiting for sync"
15481548
# Stream compact sync until fully synced (monitor prints snapshot/block progress)
15491549
set +e
1550-
"$MANAGER_BIN" sync --compact --window 30 --rpc "http://127.0.0.1:26657" --remote "https://$GENESIS_DOMAIN:443" --skip-final-message
1550+
"$MANAGER_BIN" sync --compact --window 30 --rpc "http://127.0.0.1:26657" --remote "https://$GENESIS_DOMAIN:443" --skip-final-message < /dev/null
15511551
SYNC_RC=$?
15521552
set -e
15531553

@@ -1582,15 +1582,15 @@ if [[ "$AUTO_START" = "yes" ]]; then
15821582
echo " • Discord: https://discord.com/invite/pushchain"
15831583
echo " • Support: https://push.org/support/"
15841584
echo
1585-
"$MANAGER_BIN" stop >/dev/null 2>&1 || true
1585+
"$MANAGER_BIN" stop < /dev/null >/dev/null 2>&1 || true
15861586
exit 1
15871587
fi
15881588

15891589
warn "Sync stuck or failed. Performing full data reset (attempt $RETRY_COUNT/$MAX_RETRIES)..."
15901590
echo
15911591

15921592
step "Stopping node"
1593-
"$MANAGER_BIN" stop >/dev/null 2>&1 || true
1593+
"$MANAGER_BIN" stop < /dev/null >/dev/null 2>&1 || true
15941594
sleep 2
15951595
pkill -x pchaind 2>/dev/null || true
15961596
pkill -x push-validator 2>/dev/null || true
@@ -1600,7 +1600,7 @@ if [[ "$AUTO_START" = "yes" ]]; then
16001600
fi
16011601

16021602
warn "Sync monitoring ended with code $SYNC_RC (not a stuck condition, skipping retry)"
1603-
"$MANAGER_BIN" stop >/dev/null 2>&1 || true
1603+
"$MANAGER_BIN" stop < /dev/null >/dev/null 2>&1 || true
16041604
break
16051605
done
16061606

@@ -1676,11 +1676,11 @@ INSTALL_END_TIME=$(date +%s)
16761676
TOTAL_TIME=$((INSTALL_END_TIME - ${INSTALL_START_TIME:-$INSTALL_END_TIME}))
16771677

16781678
# Get node information for unified summary
1679-
MANAGER_VER=$("$MANAGER_BIN" version 2>/dev/null | awk '{print $2}' || echo "unknown")
1679+
MANAGER_VER=$("$MANAGER_BIN" version < /dev/null 2>/dev/null | awk '{print $2}' || echo "unknown")
16801680
PCHAIND_PATH="${PCHAIND:-pchaind}"
16811681
# Extract pchaind version if binary exists
16821682
if command -v "$PCHAIND_PATH" >/dev/null 2>&1; then
1683-
CHAIN_VER=$("$PCHAIND_PATH" version 2>/dev/null | head -1 || echo "")
1683+
CHAIN_VER=$("$PCHAIND_PATH" version < /dev/null 2>/dev/null | head -1 || echo "")
16841684
if [[ -n "$CHAIN_VER" ]]; then
16851685
PCHAIND_VER="$PCHAIND_PATH ($CHAIN_VER)"
16861686
else
@@ -1694,9 +1694,9 @@ RPC_URL="http://127.0.0.1:26657"
16941694
# Try to get Node status info
16951695
TO_CMD=$(timeout_cmd)
16961696
if [[ -n "$TO_CMD" ]]; then
1697-
STATUS_JSON=$($TO_CMD 5 "$MANAGER_BIN" status --output json 2>/dev/null || echo "{}")
1697+
STATUS_JSON=$($TO_CMD 5 "$MANAGER_BIN" status --output json < /dev/null 2>/dev/null || echo "{}")
16981698
else
1699-
STATUS_JSON=$("$MANAGER_BIN" status --output json 2>/dev/null || echo "{}")
1699+
STATUS_JSON=$("$MANAGER_BIN" status --output json < /dev/null 2>/dev/null || echo "{}")
17001700
fi
17011701
if command -v jq >/dev/null 2>&1; then
17021702
NETWORK=$(echo "$STATUS_JSON" | jq -r '.network // .node.network // empty' 2>/dev/null)

internal/ui/terminal_init.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,17 @@ func InitTerminal() {
4848
// FlushStdinWithTimeout reads and discards stdin for the specified duration.
4949
// This catches asynchronous terminal responses (cursor position reports,
5050
// OSC responses, focus events) that arrive after queries are sent.
51+
// Only flushes if stdin is a terminal — never reads from pipes or /dev/null
52+
// to avoid consuming piped script content (e.g., curl | bash).
5153
func FlushStdinWithTimeout(timeout time.Duration) {
5254
fd := int(os.Stdin.Fd())
5355

56+
// Never read from stdin if it's not a terminal — this would consume
57+
// piped input (e.g., the install script when run via "curl | bash")
58+
if !term.IsTerminal(fd) {
59+
return
60+
}
61+
5462
// Set non-blocking mode to read without waiting
5563
if err := syscall.SetNonblock(fd, true); err != nil {
5664
return

0 commit comments

Comments
 (0)