diff options
author | doc <doc@filenotfound.org> | 2025-06-30 20:14:17 +0000 |
---|---|---|
committer | doc <doc@filenotfound.org> | 2025-06-30 20:14:17 +0000 |
commit | a8cd1c324c0541b0d26542168aeced085ec13201 (patch) | |
tree | a99d398008b46aa4df5dcae997e1690298d2fc70 /vps/functions/resize_vps.sh |
Diffstat (limited to 'vps/functions/resize_vps.sh')
-rwxr-xr-x | vps/functions/resize_vps.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vps/functions/resize_vps.sh b/vps/functions/resize_vps.sh new file mode 100755 index 0000000..c06ea91 --- /dev/null +++ b/vps/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 +} |