Skip to content

Commit 6c9b043

Browse files
committed
WIP
1 parent 6610ecc commit 6c9b043

28 files changed

+1397
-219
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ and Tailscale's mesh networking for secure inter-server communication.
3232
└─────────────────┘ └─────────────────┘
3333
│ │
3434
▼ ▼
35-
┌─────────────────┐ Tailscale ┌─────────────────┐
36-
│ magnet-atheme │◄─────────────────►│ magnet-postgres │
37-
│ (US Services) │ Private Mesh │ (Fly MPG) │
38-
│ OpenSSL+EPYC │ │ │
39-
└─────────────────┘ └─────────────────┘
35+
┌─────────────────┐
36+
│ magnet-atheme │
37+
│ (US Services) │
38+
│ opensex backend │
39+
│ OpenSSL+EPYC │
40+
└─────────────────┘
4041
```
4142

4243
### Components
@@ -54,12 +55,7 @@ and Tailscale's mesh networking for secure inter-server communication.
5455
3. **magnet-atheme** - IRC Services (US/Chicago)
5556
- User registration and authentication (NickServ)
5657
- Channel management services (ChanServ)
57-
- Persistent data storage via PostgreSQL
58-
59-
4. **magnet-postgres** - Database (US/Chicago)
60-
- PostgreSQL database for services persistence
61-
- User accounts, channel registrations, configurations
62-
- Automated backups and high availability
58+
- Persistent data storage via opensex flat file backend
6359

6460
## Getting Started
6561

@@ -73,22 +69,27 @@ and Tailscale's mesh networking for secure inter-server communication.
7369

7470
## Deployment
7571

72+
**IMPORTANT**: All deployments must be run from the project root directory due to Docker build context requirements.
73+
7674
### Development Deployment
7775

7876
For testing and development purposes, use development-specific app names to avoid
7977
conflicts with production:
8078

8179
```bash
80+
# Deploy from project root directory (REQUIRED)
81+
cd /path/to/magnet
82+
8283
# Create development apps with -dev suffix
8384
fly apps create magnet-hub-dev --org magnet-irc
8485
fly apps create magnet-atheme-dev --org magnet-irc
8586

8687
# Set up Tailscale authentication for dev
8788
fly secrets set TAILSCALE_AUTHKEY=tskey-auth-xxxxx --app magnet-9rl-dev
8889

89-
# Deploy base infrastructure (development)
90-
fly deploy --app magnet-hub-dev
91-
fly deploy --app magnet-atheme-dev
90+
# Deploy base infrastructure (from root directory)
91+
fly deploy --app magnet-hub-dev --dockerfile solanum/Dockerfile --config servers/magnet-9rl/fly.toml
92+
fly deploy --app magnet-atheme-dev --dockerfile atheme/Dockerfile --config servers/magnet-atheme/fly.toml
9293

9394
# Validate mesh connectivity
9495
fly ssh console --app magnet-hub-dev
@@ -196,7 +197,7 @@ All components include comprehensive health checks:
196197
- Tailscale mesh connectivity
197198
- IRC server responsiveness
198199
- Services authentication status
199-
- Database connectivity
200+
- Flat file backend accessibility
200201
- SSL certificate validity
201202

202203
## Development

atheme/Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ RUN git clone https://github.com/atheme/atheme -b v${ATHEME_VERSION} --depth=1 /
3131
RUN cd /atheme-src/libmowgli-2 && git pull origin master
3232

3333
# Generate autotools files if needed and configure with PostgreSQL support
34+
# Force rebuild 2025-08-25 for PostgreSQL backend module
3435
RUN cd /atheme-src && \
3536
autoreconf -fiv && \
3637
./configure \
@@ -53,6 +54,9 @@ RUN apk add --no-cache \
5354
ca-certificates \
5455
curl \
5556
gettext \
57+
pwgen \
58+
su-exec \
59+
pcre \
5660
&& rm -rf /var/cache/apk/*
5761

5862
# Copy Atheme from builder
@@ -69,11 +73,20 @@ RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale /app
6973
RUN adduser -D -h /atheme -u $ATHEME_UID atheme
7074
RUN chown -R atheme /atheme
7175

72-
# Copy configuration templates and startup script
76+
# Force cache invalidation with build timestamp
77+
ARG BUILD_TIMESTAMP
78+
RUN echo "Build timestamp: $BUILD_TIMESTAMP" > /tmp/build_info
79+
80+
# Test build context - copy test file first
81+
COPY test-build-context.txt /tmp/test.txt
82+
83+
# Copy configuration templates and startup script
7384
COPY atheme/atheme.conf.template /atheme/etc/atheme.conf.template
7485
COPY atheme/entrypoint.sh /app/entrypoint.sh
7586
RUN chmod +x /app/entrypoint.sh
7687

88+
89+
7790
# Health check
7891
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
7992
CMD curl -f http://localhost:8080/health || exit 1

atheme/atheme.conf.template

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
# ABOUTME: Atheme IRC services configuration template with environment variable substitution
2-
# ABOUTME: Optimized with OpenSSL for AMD EPYC performance and PostgreSQL backend
2+
# ABOUTME: Optimized with OpenSSL for AMD EPYC performance and opensex flat file backend
33

44
# Atheme Configuration Template for ${ATHEME_NETWORK}
55
# Optimized with OpenSSL for AMD EPYC performance
66

7-
/* Database configuration */
7+
/* Database configuration - using opensex flat file backend */
88
database {
9-
module = "postgresql";
10-
host = "${ATHEME_POSTGRES_HOST}";
11-
port = 5432;
12-
database = "${ATHEME_POSTGRES_DB}";
13-
username = "postgres";
14-
password = ""; # Will be set via DATABASE_URL env var
9+
module = "opensex";
1510
};
1611

1712
/* Network information */
@@ -38,18 +33,18 @@ serverinfo {
3833
emailtime = 300;
3934
};
4035

41-
/* Uplink configuration via Tailscale */
42-
uplink "${ATHEME_HUB_SERVER}.raptor-betelgeuse.ts.net" {
43-
host = "${ATHEME_HUB_HOSTNAME}"; /* Tailscale hostname */
36+
/* Uplink configuration */
37+
uplink "${ATHEME_HUB_SERVER}.${HUB_NAME}" {
38+
host = "${ATHEME_HUB_SERVER}.${HUB_NAME}";
4439
send_password = "${SERVICES_PASSWORD}";
4540
receive_password = "${SERVICES_PASSWORD}";
4641
port = 6667;
47-
vhost = "0.0.0.0";
42+
/* No vhost specified - let it use the default interface */
4843
};
4944

5045
/* Operator configuration */
51-
operator "${OPERATOR_PASSWORD}" {
52-
name = "admin";
46+
operator "admin" {
47+
password = "${OPERATOR_PASSWORD}";
5348
class = "sra";
5449
};
5550

@@ -65,7 +60,7 @@ nickserv {
6560
user = "services";
6661
host = "services.raptor-betelgeuse.ts.net";
6762
real = "Nickname Services";
68-
aliases = { "NS" };
63+
aliases = "NS";
6964
};
7065

7166
/* ChanServ configuration */
@@ -74,7 +69,7 @@ chanserv {
7469
user = "services";
7570
host = "services.raptor-betelgeuse.ts.net";
7671
real = "Channel Services";
77-
aliases = { "CS" };
72+
aliases = "CS";
7873
};
7974

8075
/* OperServ configuration */
@@ -83,7 +78,7 @@ operserv {
8378
user = "services";
8479
host = "services.raptor-betelgeuse.ts.net";
8580
real = "Operator Services";
86-
aliases = { "OS" };
81+
aliases = "OS";
8782
};
8883

8984
/* MemoServ configuration */
@@ -92,11 +87,11 @@ memoserv {
9287
user = "services";
9388
host = "services.raptor-betelgeuse.ts.net";
9489
real = "Memo Services";
95-
aliases = { "MS" };
90+
aliases = "MS";
9691
};
9792

9893
/* Protocol module */
99-
loadmodule "modules/protocol/solanum";
94+
loadmodule "modules/protocol/charybdis";
10095

10196
/* Backend modules */
10297
loadmodule "modules/backend/opensex";

atheme/entrypoint.sh

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/bash
2-
# ABOUTME: Atheme IRC services startup script with Tailscale integration and database connectivity
3-
# ABOUTME: Handles ephemeral Tailscale auth, password generation, and PostgreSQL connection
1+
#!/bin/sh
2+
# ABOUTME: Atheme IRC services startup script with Tailscale integration
3+
# ABOUTME: Handles ephemeral Tailscale auth, password generation, and opensex flat file backend
44

55
set -e
66

@@ -12,7 +12,7 @@ sleep 5
1212

1313
# Connect to Tailscale network
1414
HOSTNAME=${SERVER_NAME:-atheme-${FLY_REGION:-unknown}}
15-
/usr/local/bin/tailscale up --auth-key=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --ephemeral --ssh --accept-routes=false --accept-dns=true
15+
/usr/local/bin/tailscale up --auth-key=${TAILSCALE_AUTHKEY} --hostname=${HOSTNAME} --ssh --accept-routes=false --accept-dns=true
1616

1717
echo "Connected to Tailscale as ${HOSTNAME}"
1818

@@ -39,16 +39,9 @@ source /atheme/etc/passwords.conf
3939
# Process atheme.conf template with generated passwords
4040
echo "Instantiating atheme.conf from template..."
4141

42-
# Extract database details from DATABASE_URL if available
43-
if [ -n "$DATABASE_URL" ]; then
44-
echo "Using DATABASE_URL for PostgreSQL connection"
45-
# Parse DATABASE_URL: postgres://user:pass@host:port/dbname
46-
export ATHEME_POSTGRES_HOST=$(echo "$DATABASE_URL" | sed -n 's/.*@\([^:]*\):.*/\1/p')
47-
export ATHEME_POSTGRES_DB=$(echo "$DATABASE_URL" | sed -n 's/.*\/\([^?]*\).*/\1/p')
48-
echo "Extracted from DATABASE_URL: host=$ATHEME_POSTGRES_HOST, db=$ATHEME_POSTGRES_DB"
49-
fi
42+
# Atheme uses opensex flat file backend - no database configuration needed
5043

51-
envsubst '${ATHEME_NETWORK} ${ATHEME_NETWORK_DOMAIN} ${SERVICES_PASSWORD} ${OPERATOR_PASSWORD} ${ATHEME_POSTGRES_HOST} ${ATHEME_POSTGRES_DB} ${ATHEME_HUB_SERVER} ${ATHEME_HUB_HOSTNAME}' \
44+
envsubst '${ATHEME_NETWORK} ${ATHEME_NETWORK_DOMAIN} ${SERVICES_PASSWORD} ${OPERATOR_PASSWORD} ${ATHEME_HUB_SERVER} ${HUB_NAME}' \
5245
< /atheme/etc/atheme.conf.template \
5346
> /atheme/etc/atheme.conf
5447

@@ -59,31 +52,11 @@ echo "Atheme configuration instantiated successfully"
5952
echo "Tailscale hostname: ${HOSTNAME}"
6053
echo "Services password: ${SERVICES_PASSWORD}"
6154

62-
# Wait for PostgreSQL to be available (if DATABASE_URL is set)
63-
if [ -n "$DATABASE_URL" ]; then
64-
echo "Waiting for PostgreSQL to be available..."
65-
max_attempts=30
66-
attempt=1
67-
68-
while [ $attempt -le $max_attempts ]; do
69-
if pg_isready -d "$DATABASE_URL" >/dev/null 2>&1; then
70-
echo "PostgreSQL is ready!"
71-
break
72-
fi
73-
74-
echo "PostgreSQL not ready, attempt $attempt/$max_attempts..."
75-
sleep 2
76-
attempt=$((attempt + 1))
77-
done
78-
79-
if [ $attempt -gt $max_attempts ]; then
80-
echo "WARNING: PostgreSQL not available after $max_attempts attempts, proceeding anyway"
81-
fi
82-
fi
55+
# Atheme uses opensex flat file backend - no database connection needed
8356

8457
# Simple HTTP health endpoint
8558
(while true; do
86-
echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nAtheme Services Health OK" | nc -l -p 8080 -q 1
59+
echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nAtheme Services Health OK" | nc -l -p 8080
8760
done) &
8861

8962
# Start Atheme as atheme user

0 commit comments

Comments
 (0)