Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
b3417a3
feature: push node manager
mohammeds1992 Aug 12, 2025
8fa24b7
fix: nginx tests
mohammeds1992 Aug 12, 2025
f67d8a4
fix: ubuntu error fix for netcat
mohammeds1992 Aug 12, 2025
11544d5
Update README.md
mohammeds1992 Aug 12, 2025
dc9f910
fix: virtual python env
mohammeds1992 Aug 12, 2025
f688c71
Update setup-dependencies.sh
mohammeds1992 Aug 13, 2025
0843919
fixes
mohammeds1992 Aug 13, 2025
80ce768
fixes
mohammeds1992 Aug 13, 2025
3aeb70a
Update install.sh
mohammeds1992 Aug 13, 2025
abf70ac
fixes
mohammeds1992 Aug 13, 2025
98fc8e0
Update setup-dependencies.sh
mohammeds1992 Aug 13, 2025
fab1368
log fixes
mohammeds1992 Aug 13, 2025
1df14da
Update install.sh
mohammeds1992 Aug 13, 2025
8222d4c
Update setup-dependencies.sh
mohammeds1992 Aug 13, 2025
1e6ecde
fixes
mohammeds1992 Aug 13, 2025
d1ba0c5
fixes
mohammeds1992 Aug 13, 2025
8f56fdd
Update install.sh
mohammeds1992 Aug 13, 2025
54c710e
Update install.sh
mohammeds1992 Aug 13, 2025
4038ef2
Update install.sh
mohammeds1992 Aug 13, 2025
7e739e6
Update install.sh
mohammeds1992 Aug 13, 2025
27e6df2
fixes
mohammeds1992 Aug 13, 2025
0d924b5
Update push-node-manager
mohammeds1992 Aug 13, 2025
ed5be7b
Update push-node-manager
mohammeds1992 Aug 13, 2025
5b0d664
Update push-node-manager
mohammeds1992 Aug 13, 2025
b52697f
Update push-node-manager
mohammeds1992 Aug 13, 2025
b0b9af2
Update push-node-manager
mohammeds1992 Aug 13, 2025
a323fcc
Update push-node-manager
mohammeds1992 Aug 14, 2025
22a736f
fix: updated push-validator-manger from push-node-manager
mohammeds1992 Sep 3, 2025
d342611
fix: reduce logs clutter
mohammeds1992 Sep 3, 2025
99dd4c7
fix: more logs cleanup
mohammeds1992 Sep 3, 2025
3f1302a
fix: flicker issue
mohammeds1992 Sep 3, 2025
389a412
fix: flicker issue
mohammeds1992 Sep 3, 2025
24007b2
fix: reset data
mohammeds1992 Sep 4, 2025
82bb4a4
Update install.sh
mohammeds1992 Sep 4, 2025
2c5e6a5
fixes
mohammeds1992 Sep 4, 2025
e4d1678
fix: logging fixes
mohammeds1992 Sep 4, 2025
cf0b89a
feature: ws logic to block sync
mohammeds1992 Sep 4, 2025
cefe15d
fix: wscat auto install
mohammeds1992 Sep 4, 2025
3d1e989
fix: remove brew logs
mohammeds1992 Sep 4, 2025
1fe9f6b
fix: progress bar logic
mohammeds1992 Sep 4, 2025
8a8ee3a
fix: status check
mohammeds1992 Sep 4, 2025
4a90dce
fix: progress bar fixes
mohammeds1992 Sep 4, 2025
37dfd87
fix: more fixes
mohammeds1992 Sep 4, 2025
65524e8
fix: progress bar issues
mohammeds1992 Sep 4, 2025
334a19c
fix: pchaind fix
mohammeds1992 Sep 4, 2025
c681e8d
fix: start pchaind in background fix
mohammeds1992 Sep 4, 2025
2898863
fix: added daemon launcher
mohammeds1992 Sep 4, 2025
d4ad313
fix: log fixes
mohammeds1992 Sep 4, 2025
41f475c
fix: add state sync functionality
mohammeds1992 Sep 15, 2025
5441f6c
fix: read me fixes
mohammeds1992 Sep 15, 2025
8254497
fix: variable fix
mohammeds1992 Sep 15, 2025
9579533
fix: few code fixes
mohammeds1992 Sep 15, 2025
b826062
fix: minor sed fixes
mohammeds1992 Sep 15, 2025
77fa964
fixes
mohammeds1992 Sep 15, 2025
b921e63
fix: installer fixes
mohammeds1992 Sep 15, 2025
6a57835
fix: prevent installer hanging during node start with state sync
mohammeds1992 Sep 15, 2025
5a5b214
Update install.sh
mohammeds1992 Sep 15, 2025
5133630
Update push-validator-manager
mohammeds1992 Sep 15, 2025
cfef217
Update install.sh
mohammeds1992 Sep 15, 2025
96780b0
fix: more fixes
mohammeds1992 Sep 15, 2025
a64b914
Update install.sh
mohammeds1992 Sep 15, 2025
cb8ae7d
Update push-validator-manager
mohammeds1992 Sep 15, 2025
bda4411
Update push-validator-manager
mohammeds1992 Sep 15, 2025
2c2e1aa
fix: state sync progress bar
mohammeds1992 Sep 15, 2025
380a195
Update install.sh
mohammeds1992 Sep 15, 2025
4d99e4d
Update install.sh
mohammeds1992 Sep 15, 2025
62df99d
fixes
mohammeds1992 Sep 15, 2025
495abdf
Update install.sh
mohammeds1992 Sep 15, 2025
70a869f
fixes
mohammeds1992 Sep 15, 2025
21353c9
Update install.sh
mohammeds1992 Sep 15, 2025
37d7d87
fixes
mohammeds1992 Sep 15, 2025
1e18434
Update install.sh
mohammeds1992 Sep 15, 2025
bdb9538
Update install.sh
mohammeds1992 Sep 15, 2025
dfb8fb7
fixes
mohammeds1992 Sep 15, 2025
f29bc2b
feat: add extensive debug logging to diagnose installer startup issue
mohammeds1992 Sep 15, 2025
be15ed7
fix: redirect pchaind init output to stderr to maintain pipe connection
mohammeds1992 Sep 15, 2025
d69c30c
fix: add --overwrite flag to pchaind init to handle existing genesis.…
mohammeds1992 Sep 15, 2025
d668344
fix: state sync progress calculation and remove debug logs
mohammeds1992 Sep 15, 2025
a8dff55
fix: improve state sync progress calculation
mohammeds1992 Sep 15, 2025
4c4b878
fix: show actual state sync progress instead of phase-divided progress
mohammeds1992 Sep 15, 2025
e085ca0
Update push-validator-manager
mohammeds1992 Sep 15, 2025
cc70c38
Update push-validator-manager
mohammeds1992 Sep 15, 2025
183ecd0
Update push-validator-manager
mohammeds1992 Sep 15, 2025
48c315f
Update push-validator-manager
mohammeds1992 Sep 15, 2025
8dcebb2
Update push-validator-manager
mohammeds1992 Sep 15, 2025
77bd911
Update push-validator-manager
mohammeds1992 Sep 15, 2025
556365e
Update push-validator-manager
mohammeds1992 Sep 15, 2025
dc09baa
Update push-validator-manager
mohammeds1992 Sep 15, 2025
3408946
Update push-validator-manager
mohammeds1992 Sep 15, 2025
e797eba
Update push-validator-manager
mohammeds1992 Sep 15, 2025
28c23af
Update push-validator-manager
mohammeds1992 Sep 15, 2025
36f9493
Update push-validator-manager
mohammeds1992 Sep 15, 2025
a21e234
Update push-validator-manager
mohammeds1992 Sep 15, 2025
ef0775e
Update push-validator-manager
mohammeds1992 Sep 15, 2025
1a736f3
fixes
mohammeds1992 Sep 15, 2025
320d417
Update install.sh
mohammeds1992 Sep 15, 2025
0525567
Update push-validator-manager
mohammeds1992 Sep 15, 2025
db2431c
Update push-validator-manager
mohammeds1992 Sep 15, 2025
ee49ac3
fixes
mohammeds1992 Sep 15, 2025
c8235dd
Update push-validator-manager
mohammeds1992 Sep 15, 2025
6a39770
fix: remove fallback monitoring and restore detect_state_sync_phase f…
mohammeds1992 Sep 15, 2025
65a6c9f
fix: prevent SYNC_COMPLETE from being reset after state sync
mohammeds1992 Sep 15, 2025
8dffe5f
fix: make monitor-state-sync exit after sync completes
mohammeds1992 Sep 15, 2025
47ede71
fix: use catching_up API field to detect sync completion
mohammeds1992 Sep 15, 2025
30ace68
fix: initialize SYNC_COMPLETE variable to prevent unbound error
mohammeds1992 Sep 15, 2025
ecc2573
fix: prevent premature exit when checking catching_up before state sy…
mohammeds1992 Sep 15, 2025
c56f20b
fix: ensure monitor exits all loops when sync completes
mohammeds1992 Sep 15, 2025
f304ecf
fix: remove 'Fetching network height' message display
mohammeds1992 Sep 15, 2025
c47dd66
Update push-validator-manager
mohammeds1992 Sep 15, 2025
963e829
Update push-validator-manager
mohammeds1992 Sep 15, 2025
62134b2
Update push-validator-manager
mohammeds1992 Sep 15, 2025
6fd8692
fix: remove subshells from monitor_sync_auto to fix exit issue
mohammeds1992 Sep 15, 2025
658a44e
fix: make monitor_sync exit when node is synced in state sync mode
mohammeds1992 Sep 15, 2025
b7ff85f
Update install.sh
mohammeds1992 Sep 15, 2025
04d6bee
fix: cleanup background process when WebSocket monitor falls back
mohammeds1992 Sep 15, 2025
8bb6b11
fix: initialize LOCAL_HEIGHT with actual node height to show correct …
mohammeds1992 Sep 15, 2025
df1c17c
Update push-validator-manager
mohammeds1992 Sep 15, 2025
55a4f58
Update push-validator-manager
mohammeds1992 Sep 15, 2025
7364471
Update push-validator-manager
mohammeds1992 Sep 15, 2025
b62dffd
Update push-validator-manager
mohammeds1992 Sep 15, 2025
ae9d43a
fixes
mohammeds1992 Sep 15, 2025
8634c5f
Update install.sh
mohammeds1992 Sep 15, 2025
ca959fa
Update install.sh
mohammeds1992 Sep 15, 2025
73b66e7
fixes
mohammeds1992 Sep 15, 2025
e6c73e4
Update install.sh
mohammeds1992 Sep 15, 2025
8013c14
fix: more cleanup
mohammeds1992 Sep 15, 2025
735d449
Update push-validator-manager
mohammeds1992 Sep 15, 2025
e51b366
Update install.sh
mohammeds1992 Sep 15, 2025
42985c7
fixes
mohammeds1992 Sep 15, 2025
d2d6e65
Update register-validator.sh
mohammeds1992 Sep 16, 2025
0c6f5ca
fixes
mohammeds1992 Sep 16, 2025
3f0e386
Update install.sh
mohammeds1992 Sep 16, 2025
2532f02
Update install.sh
mohammeds1992 Sep 16, 2025
3f21937
fixes
mohammeds1992 Sep 16, 2025
5157754
fix: clean UX
mohammeds1992 Sep 16, 2025
62543a3
fix: more fixes
mohammeds1992 Sep 16, 2025
500b5ad
Update install.sh
mohammeds1992 Sep 16, 2025
9b30526
Update install.sh
mohammeds1992 Sep 16, 2025
a549e47
Update install.sh
mohammeds1992 Sep 16, 2025
eee59f4
Update install.sh
mohammeds1992 Sep 16, 2025
d69c135
Update install.sh
mohammeds1992 Sep 16, 2025
286bc8e
Update register-validator.sh
mohammeds1992 Sep 16, 2025
152535e
feat: go implementation
mohammeds1992 Sep 17, 2025
d4a4fb9
fix: cleanup and cmd fixes
mohammeds1992 Sep 17, 2025
16c292b
fix: validator UX changes
mohammeds1992 Sep 17, 2025
92b48cd
fix: UI fixes
mohammeds1992 Sep 17, 2025
f5965bd
Merge branch 'feat/universal-validator' into feature/pnm
mohammeds1992 Sep 17, 2025
1f599bd
Merge branch 'main' into feature/pnm
mohammeds1992 Oct 8, 2025
9970ee1
fix: polish pnm
mohammeds1992 Oct 8, 2025
3212185
fix: log viewer fixes
mohammeds1992 Oct 9, 2025
a302811
fix: more fixes related to help
mohammeds1992 Oct 9, 2025
6c1b275
fix: more fixes
mohammeds1992 Oct 9, 2025
925db27
fix: add more fixes
mohammeds1992 Oct 9, 2025
fc2ad19
fix: install.sh fixes
mohammeds1992 Oct 9, 2025
ed9a7e7
fix: admin fixes
mohammeds1992 Oct 9, 2025
39d51a6
Update install.sh
mohammeds1992 Oct 9, 2025
f68725c
fix: bug fixes
mohammeds1992 Oct 9, 2025
ee7c51c
Update install.sh
mohammeds1992 Oct 9, 2025
9bf85f0
fix: add footer message when stopping logs in non-interactive mode
mohammeds1992 Oct 9, 2025
5a472a9
fix: enable interactive logs for remote installer by checking stderr TTY
mohammeds1992 Oct 9, 2025
997f336
fix: use /dev/tty for interactive detection in remote installer
mohammeds1992 Oct 9, 2025
1158709
fixes
mohammeds1992 Oct 9, 2025
f75cd61
Update cmd_register.go
mohammeds1992 Oct 9, 2025
336d64f
Update install.sh
mohammeds1992 Oct 9, 2025
37f6d04
fixes
mohammeds1992 Oct 9, 2025
1575bd2
fix: testing bug fixes
mohammeds1992 Oct 9, 2025
6699387
Update logtui_v2.go
mohammeds1992 Oct 9, 2025
44506f6
fixes
mohammeds1992 Oct 9, 2025
9c2e9b8
fix: added read me file
mohammeds1992 Oct 9, 2025
4c5df76
fix: advanced setup
mohammeds1992 Oct 9, 2025
f21177c
fix: log fixes
mohammeds1992 Oct 10, 2025
5bffab5
Merge branch 'main' into feature/pnm
mohammeds1992 Oct 10, 2025
e5f3b7f
fix: eta fixes
mohammeds1992 Oct 11, 2025
be848a7
error handling
mohammeds1992 Oct 11, 2025
1d2c79e
Update install.sh
mohammeds1992 Oct 11, 2025
bf31fb2
Update monitor.go
mohammeds1992 Oct 11, 2025
a5a5564
fix: dashboard implementation
mohammeds1992 Oct 13, 2025
82d5941
Merge branch 'main' into feature/pnm
mohammeds1992 Oct 17, 2025
987221e
fix: dashboard changes
mohammeds1992 Oct 18, 2025
ceb4613
fixes
mohammeds1992 Oct 18, 2025
1af9da6
fixes
mohammeds1992 Oct 18, 2025
ccb6ecb
Update install.sh
mohammeds1992 Oct 18, 2025
566263b
fix: logs viewer, pagination to validators
mohammeds1992 Oct 19, 2025
19ee2b8
fixes
mohammeds1992 Oct 21, 2025
01de801
fixes
mohammeds1992 Oct 22, 2025
f12060c
fixes
mohammeds1992 Oct 22, 2025
0faf709
Update dashboard.go
mohammeds1992 Oct 22, 2025
ab601f2
Update dashboard.go
mohammeds1992 Oct 22, 2025
0700489
fix: deleted older version of push-validator-manager
mohammeds1992 Oct 27, 2025
fbb99c7
fix: folder name simplification and command simplification
mohammeds1992 Oct 27, 2025
be2851d
fix: UX issues
mohammeds1992 Oct 27, 2025
b81bc47
fix: Resolve memory issue in push-validator status command
mohammeds1992 Oct 27, 2025
9d21519
fix: Resolve memory issue in push-validator status command
mohammeds1992 Oct 27, 2025
e58efd7
fix: Resolve memory issue in push-validator status command
mohammeds1992 Oct 27, 2025
8f1e48d
fixes
mohammeds1992 Oct 27, 2025
0ec0185
feat: Show initialization progress logs in push-validator start
mohammeds1992 Oct 27, 2025
6313842
feat: Show sync completion status in push-validator start output
mohammeds1992 Oct 27, 2025
2fb2166
fixes
mohammeds1992 Oct 28, 2025
1f73312
fixes
mohammeds1992 Oct 28, 2025
f929a24
Update app.go
mohammeds1992 Oct 28, 2025
1b5bc5d
fixes
mohammeds1992 Oct 28, 2025
8d590fd
Update README.md
mohammeds1992 Oct 28, 2025
8eb8764
fixes
mohammeds1992 Oct 28, 2025
fd2c927
Merge branch 'main' into feature/pnm
mohammeds1992 Oct 30, 2025
a2be313
fixes
mohammeds1992 Oct 30, 2025
8b134dd
Update install.sh
mohammeds1992 Oct 30, 2025
2c5db55
Update install.sh
mohammeds1992 Oct 30, 2025
682d62b
Update install.sh
mohammeds1992 Oct 30, 2025
8dede69
Update install.sh
mohammeds1992 Oct 30, 2025
306f131
fixes
mohammeds1992 Oct 30, 2025
82b6ec8
Update .gitignore
mohammeds1992 Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ testnet/*/binary
# Create cosmos app
web/

.env
.env
.DS_Store
35 changes: 35 additions & 0 deletions push-node-manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Environment files
.env
.env.local
.env.*.local

# Data directory
data/

# Backup directory
backups/

# Logs
*.log
logs/

# OS files
.DS_Store
Thumbs.db

# IDE files
.idea/
.vscode/
*.swp
*.swo

# Temporary files
*.tmp
*.temp
.cache/

# Keys (never commit these!)
*.key
*.pem
priv_validator_key.json
node_key.json
116 changes: 116 additions & 0 deletions push-node-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Push Node Manager

**Push Chain validator management**

## 🚀 Quick Start

### Step 1: Install & Start
```bash
curl -fsSL https://get.push.network/node/install.sh | bash
```
This installs and starts your validator automatically.

> **Note:** After installation, restart your terminal or run `source ~/.bashrc` (or `~/.zshrc`) to use the `push-node-manager` command from anywhere.

### Step 2: Check Sync Status
```bash
push-node-manager status
```
Wait for: `✅ Catching Up: false` (fully synced)

### Step 3: Become a Validator
```bash
push-node-manager register-validator
```

**Requirements:**
- Node must be synced (catching_up: false)
- Need 2+ PC tokens from [faucet](https://faucet.push.org)
- Account must be funded first

**That's it! You're now running a Push Chain validator! 🎉**

## 📖 Commands

### Essential Commands
```bash
push-node-manager start # Setup + start node
push-node-manager stop # Stop node
push-node-manager status # Show sync status & validator info
push-node-manager register-validator # Become a validator
push-node-manager logs # View live logs
```

### Additional Commands
```bash
push-node-manager restart # Restart node
push-node-manager sync # Real-time sync monitor
push-node-manager validators # List all validators
push-node-manager balance # Check wallet balance
push-node-manager reset # Reset blockchain data
push-node-manager help # Show all commands
```

### Public Setup Commands (Optional)
```bash
push-node-manager setup-nginx <domain> # Setup NGINX + SSL for public RPC
push-node-manager setup-logs # Configure log rotation
push-node-manager backup # Create node backup
```

## 📊 Network Info

- **Chain ID**: `push_42101-1`
- **Network**: Push Chain Testnet
- **Min Stake**: 2 PC
- **Faucet**: https://faucet.push.org
- **Explorer**: https://donut.push.network

## 🔧 File Locations

- **Binary**: `./build/pchaind`
- **Config**: `~/.pchain/config/`
- **Data**: `~/.pchain/data/`
- **Keys**: `~/.pchain/keyring-test/`
- **Logs**: `~/.pchain/logs/pchaind.log`


## 🌍 Public Setup (Optional)

### Making Your Node Publicly Accessible

By default, your validator runs locally. These optional commands help set up public HTTPS endpoints:

#### Setup NGINX with SSL
```bash
push-node-manager setup-nginx yourdomain.com
```
**Creates:**
- `https://yourdomain.com` - Cosmos RPC endpoint
- `https://evm.yourdomain.com` - EVM RPC endpoint
- Automatic SSL certificates via Let's Encrypt
- Rate limiting and security headers

**Requirements:**
- Domain pointing to your server IP
- Ports 80/443 open
- Ubuntu/Debian system

#### Setup Log Rotation
```bash
push-node-manager setup-logs
```
**Configures:**
- Daily log rotation
- 14-day retention
- Automatic compression
- System logrotate integration

#### Create Backups
```bash
push-node-manager backup
```
- Timestamped backup in `~/push-node-backups/`
- Includes all config, keys, and blockchain data
- Compressed archive with integrity verification

165 changes: 165 additions & 0 deletions push-node-manager/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/usr/bin/env bash

# Push Node Manager one-liner installer (source-build only, no CI required)
# Usage examples:
# curl -fsSL https://get.push.network/pnm/install.sh | bash
# MONIKER=my-node GENESIS_DOMAIN=rpc-testnet-donut-node1.push.org KEYRING_BACKEND=os \
# curl -fsSL https://get.push.network/pnm/install.sh | bash
# curl -fsSL https://get.push.network/pnm/install.sh | bash -s -- --no-start

set -euo pipefail
IFS=$'\n\t'

# Read env or defaults
MONIKER="${MONIKER:-push-validator}"
GENESIS_DOMAIN="${GENESIS_DOMAIN:-rpc-testnet-donut-node1.push.org}"
KEYRING_BACKEND="${KEYRING_BACKEND:-test}"
AUTO_START="yes"

while [[ $# -gt 0 ]]; do
case "$1" in
--no-start) AUTO_START="no"; shift ;;
--start) AUTO_START="yes"; shift ;;
--moniker) MONIKER="$2"; shift 2 ;;
--genesis) GENESIS_DOMAIN="$2"; shift 2 ;;
--keyring) KEYRING_BACKEND="$2"; shift 2 ;;
*) echo "Unknown flag: $1" >&2; exit 1 ;;
esac
done

require_cmd() { command -v "$1" >/dev/null 2>&1 || { echo "Missing dependency: $1" >&2; exit 1; }; }
for c in curl jq git tar; do require_cmd "$c"; done

# Use XDG Base Directory or fallback to hidden directory
if [[ -n "${XDG_DATA_HOME:-}" ]]; then
ROOT_DIR="$XDG_DATA_HOME/push-node-manager"
else
ROOT_DIR="$HOME/.local/share/push-node-manager"
fi
REPO_DIR="$ROOT_DIR/repo"
INSTALL_DIR="$ROOT_DIR/app"
MANAGER_LINK="$HOME/.local/bin/push-node-manager"

mkdir -p "$ROOT_DIR"
mkdir -p "$HOME/.local/bin"
cd "$ROOT_DIR"

echo "Installing Push Node Manager into $ROOT_DIR"

# Always clone fresh repository to ensure latest version
echo "Cloning repository..."
rm -rf "$REPO_DIR"
git clone --depth 1 --branch feature/pnm https://github.com/pushchain/push-chain-node "$REPO_DIR"

# Build native binary and ensure manager script
echo "Building native binary and setting up manager..."

# Copy manager to a stable install directory so we can delete the repo later
rm -rf "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
if [[ ! -d "$REPO_DIR/push-node-manager" ]]; then
echo "Error: missing source at $REPO_DIR/push-node-manager"
exit 1
fi
cp -a "$REPO_DIR/push-node-manager/." "$INSTALL_DIR/"

cd "$INSTALL_DIR"
bash scripts/setup-dependencies.sh

# Ensure the push-node-manager script is executable
chmod +x "$INSTALL_DIR/push-node-manager"

# Create symlink for binary in expected location
# The register-validator script expects ../build/pchaind relative to scripts/ directory
mkdir -p "$INSTALL_DIR/build"
cd "$INSTALL_DIR/build"
ln -sf ../scripts/build/pchaind pchaind
cd "$INSTALL_DIR"

# Remove any existing symlink/script and install a small launcher script
rm -f "$MANAGER_LINK"
cat > "$MANAGER_LINK" <<EOF
#!/usr/bin/env bash
exec "$INSTALL_DIR/push-node-manager" "\$@"
EOF
chmod +x "$MANAGER_LINK"

# Verify the script exists and is executable
if [[ ! -f "$INSTALL_DIR/push-node-manager" ]]; then
echo "Error: push-node-manager script not found in $INSTALL_DIR"
exit 1
fi

if [[ ! -x "$INSTALL_DIR/push-node-manager" ]]; then
echo "Error: push-node-manager script is not executable"
exit 1
fi

# Add to PATH if not already there
SHELL_CONFIG=""
if [[ -f "$HOME/.zshrc" ]]; then
SHELL_CONFIG="$HOME/.zshrc"
elif [[ -f "$HOME/.bashrc" ]]; then
SHELL_CONFIG="$HOME/.bashrc"
elif [[ -f "$HOME/.bash_profile" ]]; then
SHELL_CONFIG="$HOME/.bash_profile"
fi

if [[ -n "$SHELL_CONFIG" ]]; then
if ! grep -q "push-node-manager" "$SHELL_CONFIG" 2>/dev/null; then
echo "" >> "$SHELL_CONFIG"
echo "# Push Node Manager" >> "$SHELL_CONFIG"
echo "export PATH=\"$HOME/.local/bin:\$PATH\"" >> "$SHELL_CONFIG"
fi
fi

# ALWAYS export PATH for current session, regardless of shell config
export PATH="$HOME/.local/bin:$PATH"

# Persist configuration
ENV_FILE="$ROOT_DIR/.env"
tmp="$ENV_FILE.tmp"; : > "$tmp"
{ grep -v -e '^GENESIS_DOMAIN=' -e '^MONIKER=' -e '^KEYRING_BACKEND=' "$ENV_FILE" 2>/dev/null || true; } >> "$tmp"
mv "$tmp" "$ENV_FILE"
{
echo "GENESIS_DOMAIN=$GENESIS_DOMAIN"
echo "MONIKER=$MONIKER"
echo "KEYRING_BACKEND=$KEYRING_BACKEND"
} >> "$ENV_FILE"

echo "📁 Node data: $HOME/.pchain"
echo
echo "✅ Installation complete!"
echo

# Run auto-start before cleanup to ensure wrapper script is available
if [[ "$AUTO_START" = "yes" ]]; then
"$MANAGER_LINK" start || true
echo
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "\033[1;33m💡 Quick Commands:\033[0m"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e " \033[1mpush-node-manager status\033[0m 📊 Check node status"
echo -e " \033[1mpush-node-manager sync\033[0m 📈 Monitor sync progress"
echo -e " \033[1mpush-node-manager help\033[0m ❓ Show all commands"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
fi

# ALWAYS show PATH instruction when running from pipe (curl | bash)
if [ ! -t 0 ]; then
# Running from pipe - PATH won't persist after script exits
echo
echo -e "\033[1;33m⚠️ To use push-node-manager in this terminal, run:\033[0m"
echo -e "\033[1;32m export PATH=\"\$HOME/.local/bin:\$PATH\"\033[0m"
echo
echo "Or open a new terminal window."
fi

# Optional: Clean up the cloned repository to save space (keep only push-node-manager)
cd "$ROOT_DIR"
if [[ -d "$REPO_DIR" ]]; then
# Remove the temporary clone
rm -rf "$REPO_DIR"
fi


Loading
Loading