Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/determine-workspace-members.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fi
echo "Found workspace members: ${WORKSPACE_MEMBERS[*]}"

# Define packages to skip
SKIP_PACKAGES=("cypher/frontend" "cypher/backend")
SKIP_PACKAGES=("cypher/frontend" "cypher/backend" "rsky-pdsadmin")

# Check if .github directory has changes
GITHUB_CHANGES=false
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/rsky-pdsadmin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: rsky-pdsadmin CI

on:
push:
branches: [main]
pull_request:
paths:
- '.github/workflows/rsky-pdsadmin.yml'
- 'rsky-pdsadmin/**'
- 'rust-toolchain'

jobs:
# Run formatting check
formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run cargo fmt
working-directory: ./rsky-pdsadmin
run: cargo fmt -- --check

# Check job for rsky-pdsadmin
check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: rsky-pdsadmin
- name: Run cargo check
working-directory: ./rsky-pdsadmin
run: cargo check

# Build and test job for rsky-pdsadmin
build-and-test:
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: rsky-pdsadmin
- name: Run cargo build
working-directory: ./rsky-pdsadmin
run: cargo build --release
- name: Run cargo test
working-directory: ./rsky-pdsadmin
run: cargo test

# Final job that depends on all tests to signal success
ci-success:
runs-on: ubuntu-latest
needs: [check, build-and-test, formatting]
if: always()
steps:
- name: CI Success
if: ${{ !contains(needs.*.result, 'failure') }}
run: echo "All CI jobs passed!"
- name: CI Failed
if: ${{ contains(needs.*.result, 'failure') }}
run: |
echo "Some CI jobs failed!"
exit 1
:wq
48 changes: 48 additions & 0 deletions rsky-pdsadmin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[workspace]
members = ["."]

[package]
name = "rsky-pdsadmin"
version = "0.1.0"
edition = "2024"
description = "Administrative CLI tool for rsky-pds"
authors = ["RSKY Team"]
license = "MIT"

[lib]
name = "rsky_pdsadmin"
path = "src/lib.rs"

[[bin]]
name = "pdsadmin"
path = "src/main.rs"

[dependencies]
anyhow = "1.0"
base64 = "0.21"
chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4.5.38", features = ["derive", "env"] }
dialoguer = "0.11"
diesel = { version = "2.2.10", features = ["postgres"] }
diesel_cli = { version = "2.2.10", features = ["postgres"], optional = true }
diesel_migrations = { version = "2.1.0", features = ["postgres"] }
dirs = "5.0"
dotenv = "0.15"
indicatif = "0.17"
rand = "0.8"
reqwest = { version = "0.11", features = ["json", "blocking"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shellexpand = "3.1"
thiserror = "1.0"
tokio = { version = "1.36", features = ["full"] }
uuid = { version = "1.6", features = ["v4", "serde"] }
which = "5.0"

[dev-dependencies]
mockito = "1.2"
tempfile = "3.9"

[features]
default = []
db_cli = ["diesel_cli"]
167 changes: 167 additions & 0 deletions rsky-pdsadmin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# RSKY-PDS Admin CLI

A Rust command-line utility for administering RSKY-PDS (Personal Data Server) instances. This tool is the Rust equivalent of the `pdsadmin.sh` script from the Bluesky PDS, built specifically for RSKY.

## Features

- **Account Management**: Create, list, delete, and reset passwords for accounts
- **Invite Code Management**: Generate invite codes for new users
- **PDS Administration**: Request crawls from relays, update the PDS to the latest version
- **Database Management**: Initialize and manage the RSKY-PDS database
- **Extensibility**: Easily add new commands through a modular architecture

## Installation

### From Source

```bash
# Clone the repository (if you haven't already)
git clone https://github.com/blacksky-algorithms/rsky.git
cd rsky

# Build the pdsadmin tool
cargo build --package rsky-pdsadmin

# Optionally, install it for system-wide access
cargo install --path rsky-pdsadmin
```

### Features

If you want to include the embedded database CLI:

```bash
cargo build --package rsky-pdsadmin --features db_cli
```

## Configuration

The CLI looks for a PDS environment file in the following locations (in order):

1. The path specified in the `PDS_ENV_FILE` environment variable
2. `./pds.env` (current working directory)
3. `/pds/pds.env`
4. `/usr/src/rsky/pds.env`
5. `$HOME/.config/rsky/rsky-pds/pds.env`

The environment file should contain the necessary configuration for connecting to your RSKY-PDS instance, including:

```
PDS_HOSTNAME=your-pds-hostname.com
PDS_ADMIN_PASSWORD=your-admin-password
```

## Usage

### General Help

```bash
pdsadmin help
```

### Account Management

List all accounts:
```bash
pdsadmin account list
```

Create a new account:
```bash
pdsadmin account create <EMAIL> <HANDLE>
```

Reset an account password:
```bash
pdsadmin account reset-password <DID>
```

Delete an account:
```bash
pdsadmin account delete <DID>
```

Takedown an account:
```bash
pdsadmin account takedown <DID>
```

Remove a takedown:
```bash
pdsadmin account untakedown <DID>
```

### Invite Codes

Create a new invite code:
```bash
pdsadmin create-invite-code
```

### Relay Interaction

Request a crawl from a relay:
```bash
pdsadmin request-crawl [RELAY_HOST]
```

### Updates

Update to the latest PDS version:
```bash
pdsadmin update
```

### RSKY-PDS Specific Commands

Initialize the database:
```bash
pdsadmin rsky-pds init-db
```

## Extending the CLI

The RSKY-PDS Admin CLI is designed to be easily extensible. You can add new commands by:

1. Creating a new module in `src/commands/`
2. Implementing the command logic
3. Adding the command to the `Commands` enum in `src/commands/mod.rs`
4. Adding the command execution to the `execute` function in `src/commands/mod.rs`

### External Commands

RSKY-PDS Admin also supports external commands through the PATH. Create executables named `rsky-pdsadmin-<command>` and place them in your PATH. The CLI will automatically discover and use them.

## Running in a Container

RSKY-PDS Admin detects if it's running inside a container by checking for the `RSKY_PDS_CONTAINER` environment variable. When running in a container, it adjusts its behavior accordingly, particularly for database connections.

## Development

### Prerequisites

- Rust (latest stable)
- PostgreSQL client libraries (for diesel)

### Building

```bash
cargo build
```

### Testing

```bash
cargo test
```

### Linting

```bash
cargo clippy
cargo fmt
```

## License

MIT License
13 changes: 13 additions & 0 deletions rsky-pdsadmin/pds.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DATABASE_URL=postgres://postgres:[email protected]:5432/postgres
AWS_ENDPOINT="yoho.digitaloceanspaces.com"
PDS_ADMIN_PASSWORD=change-me
PDS_HOST=0.0.0.0
PDS_HOSTNAME=127.0.0.1:8000
PDS_PORT=8000
PORT=8000
PDS_SERVICE_HANDLE_DOMAINS=test_dot_com
PDS_SERVICE_DID=did:web:rsky-pds
AWS_EC2_METADATA_DISABLED=true
LOG_LEVEL=debug
RUST_BACKTRACE=1
PDS_PROTOCOL=http
Loading