Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-27T23:32:57.617Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

digital-ocean-db.sh

39 lines · 1.0 KB · shellscript
1#!/bin/bash
2set -e
3
4# Check if database name is provided
5if [ $# -eq 0 ]; then
6    echo "Usage: $0 <database-name>"
7    doctl databases list
8    exit 1
9fi
10
11DATABASE_NAME="$1"
12DATABASE_ID=$(doctl databases list --format ID,Name --no-header | grep "$DATABASE_NAME" | awk '{print $1}')
13
14if [ -z "$DATABASE_ID" ]; then
15    echo "Error: Database '$DATABASE_NAME' not found"
16    exit 1
17fi
18CURRENT_IP=$(curl -s https://api.ipify.org)
19if [ -z "$CURRENT_IP" ]; then
20    echo "Error: Failed to get current IP address"
21    exit 1
22fi
23
24EXISTING_RULE=$(doctl databases firewalls list "$DATABASE_ID" | grep "ip_addr" | grep "$CURRENT_IP")
25
26if [ -z "$EXISTING_RULE" ]; then
27    echo "IP not found in whitelist. Adding $CURRENT_IP to database firewall..."
28    doctl databases firewalls append "$DATABASE_ID" --rule ip_addr:"$CURRENT_IP"
29fi
30
31CONNECTION_URL=$(doctl databases connection "$DATABASE_ID" --format URI --no-header)
32
33if [ -z "$CONNECTION_URL" ]; then
34    echo "Error: Failed to get database connection details"
35    exit 1
36fi
37
38psql "$CONNECTION_URL"
39
Served at tenant.openagents/omega Member data and write actions are omitted.