summaryrefslogtreecommitdiff
path: root/functions/resize_vps.sh
diff options
context:
space:
mode:
Diffstat (limited to 'functions/resize_vps.sh')
-rwxr-xr-xfunctions/resize_vps.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/functions/resize_vps.sh b/functions/resize_vps.sh
new file mode 100755
index 0000000..c06ea91
--- /dev/null
+++ b/functions/resize_vps.sh
@@ -0,0 +1,27 @@
+resize_vps() {
+ LABEL="$1"
+ NEW_TYPE="$2"
+
+ LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \
+ https://api.linode.com/v4/linode/instances | \
+ jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id')
+
+ if [ -z "$LINODE_ID" ]; then
+ echo "❌ No Linode found with label '$LABEL'"
+ exit 1
+ fi
+
+ echo "Resizing Linode '$LABEL' to type '$NEW_TYPE'..."
+
+ HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer $LINODE_API_TOKEN" \
+ -d '{"type": "'"$NEW_TYPE"'"}' \
+ https://api.linode.com/v4/linode/instances/$LINODE_ID/resize)
+
+ if [[ "$HTTP_STATUS" == "200" ]]; then
+ echo "✅ Linode $LABEL resized to $NEW_TYPE."
+ else
+ echo "❌ Failed to resize VPS. HTTP status: $HTTP_STATUS"
+ fi
+}