#!/bin/bash DROPLET_IMAGE="ubuntu-24-04-x64" SSH_KEY="~/.ssh/id_rsa" PANEL_HOSTNAME="demo.openpanel.org" # Step 1: Rebuild the droplet echo "Rebuilding the droplet..." REBUILD_RESPONSE=$(curl -s -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d "{\"type\":\"rebuild\",\"image\":\"$DROPLET_IMAGE\"}" \ "https://api.digitalocean.com/v2/droplets/$DROPLET_ID/actions") ACTION_STATUS=$(echo "$REBUILD_RESPONSE" | jq -r '.action.status') if [[ "$ACTION_STATUS" != "in-progress" ]]; then echo "Droplet rebuild failed. Response: $REBUILD_RESPONSE" exit 1 fi echo "Droplet rebuild initiated. Waiting for completion..." sleep 300 # Step 2: SSH to the droplet and run commands echo "Connecting to the droplet via SSH to set up the panel..." ssh -o StrictHostKeyChecking=no -i "$SSH_KEY" root@$DROPLET_IP <