Last active
May 10, 2026 20:49
-
-
Save koliadych/2fd6111e4382b66f25c1736eb3972230 to your computer and use it in GitHub Desktop.
fintechner direct-link node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" # disable AWS CLI's auto-pager (the trailing ':' prompt) | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| CMD_ID=$(aws --region "$REGION" ssm send-command \ | |
| --instance-ids "$INSTANCE_ID" \ | |
| --document-name AWS-RunShellScript \ | |
| --parameters 'commands=[ | |
| "echo --- alternatives target ---", | |
| "ls -l /etc/alternatives/node 2>&1 || echo no-alt-link", | |
| "echo --- find node binaries ---", | |
| "find /usr -name node -type f 2>/dev/null", | |
| "find /usr -name node20 -type f 2>/dev/null", | |
| "echo --- rpm contents ---", | |
| "rpm -ql nodejs20 | grep -E /node$ || true", | |
| "echo --- removing broken symlinks + creating direct link ---", | |
| "sudo rm -f /usr/bin/node /etc/alternatives/node", | |
| "REAL=$(rpm -ql nodejs20 2>/dev/null | grep -E /node$ | head -1)", | |
| "if [ -z \"$REAL\" ]; then REAL=$(find /usr -name node -type f 2>/dev/null | head -1); fi", | |
| "echo \"REAL=$REAL\"", | |
| "if [ -n \"$REAL\" ] && [ -x \"$REAL\" ]; then sudo ln -sf \"$REAL\" /usr/bin/node; fi", | |
| "ls -l /usr/bin/node", | |
| "/usr/bin/node --version", | |
| "echo --- restart dashboard ---", | |
| "sudo systemctl reset-failed fintechner-dashboard", | |
| "sudo systemctl restart fintechner-dashboard", | |
| "sleep 6", | |
| "sudo systemctl is-active fintechner-dashboard", | |
| "sudo ss -tlnp | grep :3000 || echo NO-LISTENER-3000", | |
| "echo --- localhost test ---", | |
| "curl -sS -o /dev/null -w \"http=%{http_code}\\n\" http://localhost:3000/ || echo curl-failed" | |
| ]' \ | |
| --query Command.CommandId --output text) | |
| for i in $(seq 1 30); do | |
| sleep 4 | |
| STATUS=$(aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query Status --output text 2>/dev/null || echo Pending) | |
| case "$STATUS" in Success|Failed|Cancelled|TimedOut) echo " $STATUS"; break ;; *) echo " $STATUS";; esac | |
| done | |
| echo | |
| echo "=== STDOUT ===" | |
| aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query StandardOutputContent --output text | |
| echo | |
| echo "=== STDERR ===" | |
| aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query StandardErrorContent --output text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment