From bf755462d6481cf0a0d7d42b3027c988ef655c69 Mon Sep 17 00:00:00 2001 From: Stefan Pejcic Date: Mon, 2 Dec 2024 18:24:11 +0100 Subject: [PATCH] Create rebuild.sh --- demo/2087/rebuild.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 demo/2087/rebuild.sh diff --git a/demo/2087/rebuild.sh b/demo/2087/rebuild.sh new file mode 100644 index 00000000..4c22fd18 --- /dev/null +++ b/demo/2087/rebuild.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +DIGITALOCEAN_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXX" +DROPLET_ID="442891520" +DROPLET_IP="45.55.60.4" +DROPLET_IMAGE="ubuntu-24-04-x64" +SSH_KEY_PATH="~/.ssh/id_rsa" +PANEL_HOSTNAME="demo.openpanel.org" +DEMO_SCRIPT="https://raw.githubusercontent.com/stefanpejcic/OpenPanel/refs/heads/main/demo/2087/setup_demo.sh" + + +# 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_PATH" root@$DROPLET_IP <