Skip to content

Commit c9db30e

Browse files
committed
refactor: streamline binary deployment in health.sh
- Replaced direct SSH commands with `exec_on_host` for creating remote directories, improving code clarity and maintainability. - Updated binary transfer functions to use `copy_to_host`, enhancing consistency in deployment logic. - Removed redundant variable assignments for SSH user and IP, simplifying the function's parameters.
1 parent 50a2ab0 commit c9db30e

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

scripts/ipc-subnet-manager/lib/health.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,23 +1904,19 @@ deploy_binaries_to_validator() {
19041904
local binary_dir="$2"
19051905

19061906
local name="${VALIDATORS[$validator_idx]}"
1907-
local ip=$(get_config_value "validators[$validator_idx].ip")
1908-
local ssh_user=$(get_config_value "validators[$validator_idx].ssh_user")
1909-
local ipc_user=$(get_config_value "validators[$validator_idx].ipc_user")
19101907
local ipc_repo=$(get_config_value "paths.ipc_repo")
19111908
local remote_release="$ipc_repo/target/release"
19121909

19131910
log_info "[$name] Deploying binaries..."
19141911

1915-
# Ensure remote directory exists
1916-
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 "$ssh_user@$ip" \
1917-
"sudo mkdir -p $remote_release && sudo chown $ipc_user:$ipc_user $remote_release" 2>/dev/null || true
1912+
# Ensure directory exists (exec_on_host handles local/remote via is_local_mode)
1913+
exec_on_host "$validator_idx" "mkdir -p $remote_release" >/dev/null 2>&1 || true
19181914

1919-
if ! scp_to_host "$ip" "$ssh_user" "$ipc_user" "$binary_dir/ipc-cli" "$remote_release/ipc-cli"; then
1915+
if ! copy_to_host "$validator_idx" "$binary_dir/ipc-cli" "$remote_release/ipc-cli"; then
19201916
log_error "[$name] Failed to copy ipc-cli"
19211917
return 1
19221918
fi
1923-
if ! scp_to_host "$ip" "$ssh_user" "$ipc_user" "$binary_dir/fendermint" "$remote_release/fendermint"; then
1919+
if ! copy_to_host "$validator_idx" "$binary_dir/fendermint" "$remote_release/fendermint"; then
19241920
log_error "[$name] Failed to copy fendermint"
19251921
return 1
19261922
fi

0 commit comments

Comments
 (0)