Created
May 10, 2026 20:39
-
-
Save koliadych/a1834077d220e4d034f84a13ebee02d1 to your computer and use it in GitHub Desktop.
fintechner install node on EC2
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 | |
| # fintechner — install Node.js on the EC2 (the dashboard's server.js needs it). | |
| set -euo pipefail | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| echo "=== Installing nodejs20 on EC2 + restarting dashboard ===" | |
| CMD_ID=$(aws --region "$REGION" ssm send-command \ | |
| --instance-ids "$INSTANCE_ID" \ | |
| --document-name AWS-RunShellScript \ | |
| --parameters 'commands=[ | |
| "sudo dnf install -y nodejs20 || sudo dnf install -y nodejs", | |
| "ls -l /usr/bin/node", | |
| "node --version", | |
| "sudo systemctl restart fintechner-dashboard", | |
| "sleep 5", | |
| "sudo systemctl is-active fintechner-dashboard", | |
| "sudo ss -tlnp | grep :3000 || echo NO LISTENER ON 3000" | |
| ]' \ | |
| --query Command.CommandId --output text) | |
| echo " Command ID: $CMD_ID" | |
| 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 " ($i) $STATUS" ;; | |
| esac | |
| done | |
| echo | |
| echo "============================================================" | |
| echo " RESULT" | |
| echo "============================================================" | |
| aws --region "$REGION" ssm get-command-invocation \ | |
| --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" \ | |
| --query StandardOutputContent --output text | |
| echo | |
| 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