mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
Create rebuild.sh
This commit is contained in:
42
demo/2087/rebuild.sh
Normal file
42
demo/2087/rebuild.sh
Normal file
@@ -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 <<EOF
|
||||
wget -O /root/demo.sh $DEMO_SCRIPT
|
||||
bash <(curl -sSL https://openpanel.org) --hostname=$PANEL_HOSTNAME --post_install=/root/demo.sh
|
||||
EOF
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to connect or execute commands on the droplet."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Panel installation and demo setup completed successfully."
|
||||
Reference in New Issue
Block a user