···78As well, the Bluesky PDS is not currently accepting incoming migrations (it will in the future). Therefore this is currently a one-way street. If you migrate off of `bsky.social`, _you will not be able to return_. However, you will be able to migrate between other PDSs.
910-
001112Account Migration occurs in 4 main steps:
13- Creating an account on the new PDS
···6768## Example Code
6970-The below Typescript code gives an example of how this account migration flow may function. Please note that it is for documentation purposes only and can not be run exactly as is as there is an out-of-band step where you need to get a confirmation token from your email.
7172It does also not handle some of the more advanced steps such as verifying a full import, looking for missing blobs, adding your own recovery key, or validating the PLC operation itself.
73
···78As well, the Bluesky PDS is not currently accepting incoming migrations (it will in the future). Therefore this is currently a one-way street. If you migrate off of `bsky.social`, _you will not be able to return_. However, you will be able to migrate between other PDSs.
910+...
11+12+
1314Account Migration occurs in 4 main steps:
15- Creating an account on the new PDS
···6970## Example Code
7172+The below code gives an example of how this account migration flow may function. Please note that it is for documentation purposes only and can not be run exactly as is as there is an out-of-band step where you need to get a confirmation token from your email.
7374It does also not handle some of the more advanced steps such as verifying a full import, looking for missing blobs, adding your own recovery key, or validating the PLC operation itself.
75
+4-8
Dockerfile
···1-FROM node:20.11-alpine3.18 as build
2-3-RUN npm install -g pnpm
45# Move files into the image and install
6WORKDIR /app
7COPY ./service ./
8-RUN pnpm install --production --frozen-lockfile > /dev/null
910# Uses assets from build stage to reduce build size
11-FROM node:20.11-alpine3.18
1213RUN apk add --update dumb-init
14···21EXPOSE 3000
22ENV PDS_PORT=3000
23ENV NODE_ENV=production
24-# potential perf issues w/ io_uring on this version of node
25-ENV UV_USE_IO_URING=0
2627CMD ["node", "--enable-source-maps", "index.js"]
2829LABEL org.opencontainers.image.source=https://github.com/bluesky-social/pds
30-LABEL org.opencontainers.image.description="AT Protocol PDS"
31LABEL org.opencontainers.image.licenses=MIT
···1+FROM node:18-alpine as build
0023# Move files into the image and install
4WORKDIR /app
5COPY ./service ./
6+RUN yarn install --production --frozen-lockfile > /dev/null
78# Uses assets from build stage to reduce build size
9+FROM node:18-alpine
1011RUN apk add --update dumb-init
12···19EXPOSE 3000
20ENV PDS_PORT=3000
21ENV NODE_ENV=production
002223CMD ["node", "--enable-source-maps", "index.js"]
2425LABEL org.opencontainers.image.source=https://github.com/bluesky-social/pds
26+LABEL org.opencontainers.image.description="ATP Personal Data Server (PDS)"
27LABEL org.opencontainers.image.licenses=MIT
+279-60
README.md
···45## Table of Contents
67-<!-- markdown-toc -i README.md -->
8-9-<!-- toc -->
10-11-- [FAQ](#faq)
12 * [What is Bluesky?](#what-is-bluesky)
13 * [What is AT Protocol?](#what-is-at-protocol)
014 * [Where is the code?](#where-is-the-code)
15 * [What is the current status of federation?](#what-is-the-current-status-of-federation)
16 * [What should I know about running a PDS in the developer sandbox?](#what-should-i-know-about-running-a-pds-in-the-developer-sandbox)
17-- [Self-hosting PDS](#self-hosting-pds)
18- * [Preparation for self-hosting PDS](#preparation-for-self-hosting-pds)
19 * [Open your cloud firewall for HTTP and HTTPS](#open-your-cloud-firewall-for-http-and-https)
20 * [Configure DNS for your domain](#configure-dns-for-your-domain)
21 * [Check that DNS is working as expected](#check-that-dns-is-working-as-expected)
22- * [Installer on Ubuntu 20.04/22.04 and Debian 11/12](#installer-on-ubuntu-20042204-and-debian-1112)
23- * [Verifying that your PDS is online and accessible](#verifying-that-your-pds-is-online-and-accessible)
24- * [Creating an account using pdsadmin](#creating-an-account-using-pdsadmin)
25- * [Creating an account using an invite code](#creating-an-account-using-an-invite-code)
26- * [Using the Bluesky app with your PDS](#using-the-bluesky-app-with-your-pds)
27- * [Updating your PDS](#updating-your-pds)
0000000000000002829-<!-- tocstop -->
3031## FAQ
32···3435Bluesky is a social media application built on AT Protocol.
3637-Please visit the [Bluesky website](https://bsky.social/) for more information.
3839### What is AT Protocol?
40···4243Please visit the [AT Protocol docs](https://atproto.com/guides/overview) for additional information.
44000045### Where is the code?
4647-* [TypeScript code](https://github.com/bluesky-social/atproto)
48-* [Go code](https://github.com/bluesky-social/indigo)
4950### What is the current status of federation?
5152-As of Feb, 2024, the AT Protocol data service (PDS) is now open to federation for self-hosters!
53-54-โ Federated domain handles (e.g. `@nytimes.com`)
55-56-โ Federated feed generators (custom algorithms)
57-58-โ Federated relays (event firehose)
59-60-โ Federated app views (API service)
61-62-โ Federated data for self-hosters (PDS hosting)
63-64-๐ฉ Federated moderation (labeling) (coming soon)
65-66-๐ฉ Federated data for large service providers (coming soon)
6768### What should I know about running a PDS in the developer sandbox?
69-70-Developers may now run self-hosted PDS hosts on the production network!
71-72-Though it is still recommended to run experiments in the developer sandbox network.
7374Read the [SANDBOX.md](https://github.com/bluesky-social/pds/blob/main/SANDBOX.md) for an overview of the sandbox network.
75···137138These should all return your server's public IP.
139140-### Installer on Ubuntu 20.04/22.04 and Debian 11/12
141142-On your server via ssh, download the installer script using wget:
143144```bash
145wget https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh
146```
147148-or download it using curl:
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000149150```bash
151-curl https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh >installer.sh
0000000000000000152```
153154-And then run the installer using bash:
1550156```bash
157-sudo bash installer.sh
00000158```
159160-### Verifying that your PDS is online and accessible
000161162-You can check if your server is online and healthy by requesting the healthcheck endpoint.
163164-You can visit `https://example.com/xrpc/_health` in your browser. You should see a JSON response with a version.
165166-For example:
0016700168```
0000000169{"version":"0.2.2-beta.2"}
170```
171172-### Creating an account using pdsadmin
00173174-Using ssh on your server, use `pdsadmin` to create an account if you haven't already.
175176```bash
177-sudo pdsadmin account create
00178```
0179180-### Creating an account using an invite code
181182-Using ssh on your server, use `pdsadmin` to create an invite code.
183184```bash
185-sudo pdsadmin create-invite-code
000000000186```
187188-When creating an account using the app, enter this invite code.
189190-### Using the Bluesky app with your PDS
191192-You can use the Bluesky app to connect to your PDS.
1931941. Get the Bluesky app
195- * [Bluesky for Web](https://bsky.app/)
196 * [Bluesky for iPhone](https://apps.apple.com/us/app/bluesky-social/id6444370199)
197 * [Bluesky for Android](https://play.google.com/store/apps/details?id=xyz.blueskyweb.app)
1981. Enter the URL of your PDS (e.g. `https://example.com/`)
0000199200-_Note: because the subdomain TLS certificate is created on-demand, it may take 10-30s for your handle to be accessible. If you aren't seeing your first post/profile, wait 30s and try to make another post._
00201202-### Updating your PDS
203204-It is recommended that you keep your PDS up to date with new versions, otherwise things may break. You can use the `pdsadmin` tool to update your PDS.
0002050206```bash
207-sudo pdsadmin update
208```
0000000000000000000000
···45## Table of Contents
67+* [FAQ](#faq)
00008 * [What is Bluesky?](#what-is-bluesky)
9 * [What is AT Protocol?](#what-is-at-protocol)
10+ * [How can developers get invite codes?](#how-can-developers-get-invite-codes)
11 * [Where is the code?](#where-is-the-code)
12 * [What is the current status of federation?](#what-is-the-current-status-of-federation)
13 * [What should I know about running a PDS in the developer sandbox?](#what-should-i-know-about-running-a-pds-in-the-developer-sandbox)
14+* [Self\-hosting PDS](#self-hosting-pds)
15+ * [Preparation for self\-hosting PDS](#preparation-for-self-hosting-pds)
16 * [Open your cloud firewall for HTTP and HTTPS](#open-your-cloud-firewall-for-http-and-https)
17 * [Configure DNS for your domain](#configure-dns-for-your-domain)
18 * [Check that DNS is working as expected](#check-that-dns-is-working-as-expected)
19+ * [Automatic install on Ubuntu 20\.04/22\.04 or Debian 11/12](#automatic-install-on-ubuntu-20042204-or-debian-1112)
20+ * [Installing manually on Ubuntu 22\.04](#installing-manually-on-ubuntu-2204)
21+ * [Open ports on your Linux firewall](#open-ports-on-your-linux-firewall)
22+ * [Install Docker](#install-docker)
23+ * [Uninstall old versions](#uninstall-old-versions)
24+ * [Set up the repository](#set-up-the-repository)
25+ * [Install Docker Engine](#install-docker-engine)
26+ * [Verify Docker Engine installation](#verify-docker-engine-installation)
27+ * [Set up the PDS directory](#set-up-the-pds-directory)
28+ * [Create the Caddyfile](#create-the-caddyfile)
29+ * [Create the PDS env configuration file](#create-the-pds-env-configuration-file)
30+ * [Start the PDS containers](#start-the-pds-containers)
31+ * [Download the Docker compose file](#download-the-docker-compose-file)
32+ * [Create the systemd service](#create-the-systemd-service)
33+ * [Start the service](#start-the-service)
34+ * [Verify your PDS is online](#verify-your-pds-is-online)
35+ * [Obtain your PDS admin password](#obtain-your-pds-admin-password)
36+ * [Generate an invite code for your PDS](#generate-an-invite-code-for-your-pds)
37+ * [Connecting to your server](#connecting-to-your-server)
38+ * [Manually updating your PDS](#manually-updating-your-pds)
39+* [PDS environment variables](#pds-environment-variables)
4004142## FAQ
43···4546Bluesky is a social media application built on AT Protocol.
4748+Please visit the [Bluesky website](https://bsky.app/) for more information.
4950### What is AT Protocol?
51···5354Please visit the [AT Protocol docs](https://atproto.com/guides/overview) for additional information.
5556+### How can developers get invite codes?
57+58+There is no invite required to join the sandbox network. Simply set up your own PDS and generate your own invite codes to create accounts. If you desire an account on the production network (on the official Bluesky PDS) please check out the [Bluesky Developer Waitlist](https://docs.google.com/forms/d/e/1FAIpQLSfCuguykw3HaPxIZMJQKRu8_-vsRew90NALVTDOjCSPDmsGNg/viewform) which prioritizes access for developers wanting to build software on atproto.
59+60### Where is the code?
6162+* [Canonical TypeScript code](https://github.com/bluesky-social/atproto)
63+* [Experimental Go code](https://github.com/bluesky-social/indigo)
6465### What is the current status of federation?
6667+We do not currently support PDS federation on the production network but it is now possible to federate in the developer sandbox.
000000000000006869### What should I know about running a PDS in the developer sandbox?
00007071Read the [SANDBOX.md](https://github.com/bluesky-social/pds/blob/main/SANDBOX.md) for an overview of the sandbox network.
72···134135These should all return your server's public IP.
136137+### Automatic install on Ubuntu 20.04/22.04 or Debian 11/12
138139+On your server via ssh, run the installer script:
140141```bash
142wget https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh
143```
144145+```bash
146+sudo bash installer.sh
147+```
148+149+### Installing manually on Ubuntu 22.04
150+151+#### Open ports on your Linux firewall
152+153+If your server is running a Linux firewall managed with `ufw`, you will need to open these ports:
154+155+```bash
156+$ sudo ufw allow 80/tcp
157+$ sudo ufw allow 443/tcp
158+```
159+160+#### Install Docker
161+162+On your server, install Docker CE (Community Edition), using the the following instructions. For other operating systems you may reference the [official Docker install guides](https://docs.docker.com/engine/install/).
163+164+**Note:** All of the following commands should be run on your server via ssh.
165+166+##### Uninstall old versions
167+168+```bash
169+sudo apt-get remove docker docker-engine docker.io containerd runc
170+```
171+172+##### Set up the repository
173+174+```bash
175+sudo apt-get update
176+sudo apt-get install \
177+ ca-certificates \
178+ curl \
179+ gnupg
180+```
181+182+```bash
183+sudo install -m 0755 -d /etc/apt/keyrings
184+curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
185+sudo chmod a+r /etc/apt/keyrings/docker.gpg
186+```
187+188+```bash
189+echo \
190+ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
191+ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
192+ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
193+```
194+195+##### Install Docker Engine
196+197+```bash
198+sudo apt-get update
199+```
200+201+```bash
202+sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
203+```
204+205+##### Verify Docker Engine installation
206+207+```bash
208+sudo docker run hello-world
209+```
210+211+#### Set up the PDS directory
212+213+```bash
214+sudo mkdir /pds
215+sudo mkdir --parents /pds/caddy/data
216+sudo mkdir --parents /pds/caddy/etc/caddy
217+```
218+219+#### Create the Caddyfile
220+221+Be sure to replace `example.com` with your own domain.
222+223+```bash
224+cat <<CADDYFILE | sudo tee /pds/caddy/etc/caddy/Caddyfile
225+{
226+ email you@example.com
227+}
228+229+*.example.com, example.com {
230+ tls {
231+ on_demand
232+ }
233+ reverse_proxy http://localhost:3000
234+}
235+CADDYFILE
236+```
237+238+#### Create the PDS env configuration file
239+240+You should fill in the first 5 values, but leave the rest untouched unless you have good reason to change it.
241+242+See the PDS environment variables section at the end of this README for explanations of each value
243+244+Your PDS will need two secp256k1 private keys provided as hex strings. You can securely generate these keys using `openssl` with the following command:
245+246+**Note:**
247+* Replace `example.com` with your domain name.
248+249+```bash
250+PDS_HOSTNAME="example.com"
251+PDS_JWT_SECRET="$(openssl rand --hex 16)"
252+PDS_ADMIN_PASSWORD="$(openssl rand --hex 16)"
253+PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX="$(openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32)"
254+PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX="$(openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32)"
255+256+cat <<PDS_CONFIG | sudo tee /pds/pds.env
257+PDS_HOSTNAME=${PDS_HOSTNAME}
258+PDS_JWT_SECRET=${PDS_JWT_SECRET}
259+PDS_ADMIN_PASSWORD=${PDS_ADMIN_PASSWORD}
260+PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX=${PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX}
261+PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=${PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX}
262+PDS_DB_SQLITE_LOCATION=/pds/pds.sqlite
263+PDS_BLOBSTORE_DISK_LOCATION=/pds/blocks
264+PDS_DID_PLC_URL=https://plc.bsky-sandbox.dev
265+PDS_BSKY_APP_VIEW_URL=https://api.bsky-sandbox.dev
266+PDS_BSKY_APP_VIEW_DID=did:web:api.bsky-sandbox.dev
267+PDS_CRAWLERS=https://bgs.bsky-sandbox.dev
268+PDS_CONFIG
269+```
270+271+#### Start the PDS containers
272+273+##### Download the Docker compose file
274+275+Download the `compose.yaml` to run your PDS, which includes the following containers:
276+277+* `pds` Node PDS server running on http://localhost:3000
278+* `caddy` HTTP reverse proxy handling TLS and proxying requests to the PDS server
279+* `watchtower` Daemon responsible for auto-updating containers to keep the server secure and federating
280+281+```bash
282+curl https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml | sudo tee /pds/compose.yaml
283+```
284+285+##### Create the systemd service
286287```bash
288+ cat <<SYSTEMD_UNIT_FILE >/etc/systemd/system/pds.service
289+[Unit]
290+Description=Bluesky PDS Service
291+Documentation=https://github.com/bluesky-social/pds
292+Requires=docker.service
293+After=docker.service
294+295+[Service]
296+Type=oneshot
297+RemainAfterExit=yes
298+WorkingDirectory=/pds
299+ExecStart=/usr/bin/docker compose --file /pds/compose.yaml up --detach
300+ExecStop=/usr/bin/docker compose --file /pds/compose.yaml down
301+302+[Install]
303+WantedBy=default.target
304+SYSTEMD_UNIT_FILE
305```
306307+##### Start the service
308309+**Reload the systemd daemon to create the new service:**
310```bash
311+sudo systemctl daemon-reload
312+```
313+314+**Enable the systemd service:**
315+```bash
316+sudo systemctl enable pds
317```
318319+**Start the pds systemd service:**
320+```bash
321+sudo systemctl start pds
322+```
323324+**Ensure that containers are running**
325326+There should be a caddy, pds, and watchtower container running.
327328+```bash
329+sudo systemctl status pds
330+```
331332+```bash
333+sudo docker ps
334```
335+336+### Verify your PDS is online
337+338+You can check if your server is online and healthy by requesting the healthcheck endpoint.
339+340+```bash
341+curl https://example.com/xrpc/_health
342{"version":"0.2.2-beta.2"}
343```
344345+### Obtain your PDS admin password
346+347+Your PDS admin password should be in your `pds.env` file if you used the installer script.
348349+**For example:**
350351```bash
352+$ source /pds/pds.env
353+$ echo $PDS_ADMIN_PASSWORD
354+a7b5970b6a5077bb41fc68a26d30adda
355```
356+### Generate an invite code for your PDS
357358+By default, your PDS will require an invite code to create an account.
359360+You can generate a new invite code with the following command:
361362```bash
363+PDS_HOSTNAME="example.com"
364+PDS_ADMIN_PASSWORD="<YOUR PDS ADMIN PASSWORD>"
365+366+curl --silent \
367+ --show-error \
368+ --request POST \
369+ --user "admin:${PDS_ADMIN_PASSWORD}" \
370+ --header "Content-Type: application/json" \
371+ --data '{"useCount": 1}' \
372+ https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode
373```
374375+**Note:** the `useCount` field specifies how many times an invite code can be used
376377+### Connecting to your server
378379+You can use the Bluesky app to connect to your server to create an account.
3803811. Get the Bluesky app
382+ * [Bluesky for Web (sandbox)](https://app.bsky-sandbox.dev/)
383 * [Bluesky for iPhone](https://apps.apple.com/us/app/bluesky-social/id6444370199)
384 * [Bluesky for Android](https://play.google.com/store/apps/details?id=xyz.blueskyweb.app)
3851. Enter the URL of your PDS (e.g. `https://example.com/`)
386+1. Create an account using the generated invite code
387+1. Create a post
388+389+_Note: because we use on-the-fly TLS certs, it may take 10-30s for your handle to be accessible. If you aren't seeing your first post/profile, wait 30s and try to make another post._
390391+Checkout [SANDBOX.md](./SANDBOX.md) for an overview of participating in the sandbox network.
392+393+### Manually updating your PDS
394395+If you use use Docker `compose.yaml` file in this repo, your PDS will automatically update nightly. To manually update to the latest version use the following commands.
396397+**Pull the latest PDS container image:**
398+```bash
399+sudo docker pull ghcr.io/bluesky-social/pds:latest
400+```
401402+**Restart PDS with the new container image:**
403```bash
404+sudo systemctl restart pds
405```
406+407+## PDS environment variables
408+409+You will need to customize various settings configured through the PDS environment variables. See the below table to find the variables you'll need to set.
410+411+| Environment Variable | Value | Should update? | Notes |
412+| ----------------------------------------- | ---------------------------- | -------------- | --------------------------------------------------------------------------- |
413+| PDS_HOSTNAME | example.com | โ | Public domain you intend to deploy your service at |
414+| PDS_JWT_SECRET | jwt-secret | โ | Use a secure high-entropy string that is 32 characters in length |
415+| PDS_ADMIN_PASSWORD | admin-pass | โ | Use a secure high-entropy string that is 32 characters in length |
416+| PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX | 3ee68... | โ | See above Generate Keys section - once set, do not change |
417+| PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX | e049f... | โ | See above Generate Keys section - once set, do not change |
418+| PDS_DB_SQLITE_LOCATION | /pds/pds.sqlite | โ | Or use `PDS_DB_POSTGRES_URL` depending on which database you intend to use |
419+| PDS_BLOBSTORE_DISK_LOCATION | /pds/blocks | โ | Only update if you update the mounted volume for your docker image as well |
420+| PDS_DID_PLC_URL | https://plc.bsky-sandbox.dev | โ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
421+| PDS_BSKY_APP_VIEW_URL | https://api.bsky-sandbox.dev | โ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
422+| PDS_BSKY_APP_VIEW_DID | did:web:api.bsky-sandbox.dev | โ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
423+| PDS_CRAWLERS | https://bgs.bsky-sandbox.dev | โ | Do not adjust if you intend to federate with the Bluesky federation sandbox |
424+425+There are additional environment variables that can be tweaked depending on how you're running your service. For instance, storing blobs in AWS S3, keys in AWS KMS, or setting up an email service.
426+427+Feel free to explore those [Here](https://github.com/bluesky-social/atproto/blob/simplify-pds/packages/pds/src/config/env.ts). However, we will not be providing support for more advanced configurations.
+3-29
SANDBOX.md
···1011Given that this is a testing environment, we will be defederating from any instances that do not abide by these guidelines, or that cause unnecessary trouble, and will not be providing specific justifications for these decisions.
1213-<!-- markdown-toc -i SANDBOX.md -->
14-15-<!-- toc -->
16-17-- [Guidelines that must be followed](#guidelines-that-must-be-followed)
18- * [Post responsibly](#post-responsibly)
19- * [Keep the emphasis on testing](#keep-the-emphasis-on-testing)
20- * [Do limit account creation](#do-limit-account-creation)
21- * [Donโt expect persistence or uptime](#dont-expect-persistence-or-uptime)
22- * [Don't advertise your service as being "Bluesky"](#dont-advertise-your-service-as-being-bluesky)
23- * [Do not mirror sandbox did:plcs to production](#do-not-mirror-sandbox-didplcs-to-production)
24- * [Status and Wipes](#status-and-wipes)
25- + [๐ Beware of dragons!](#%F0%9F%90%89-beware-of-dragons)
26- + [Routine wipes](#routine-wipes)
27-- [Getting started](#getting-started)
28- * [Auto-updates](#auto-updates)
29- * [Odds & Ends & Warnings & Reminders](#odds--ends--warnings--reminders)
30-- [Learn more about atproto federation](#learn-more-about-atproto-federation)
31- * [Network Services](#network-services)
32- + [PLC](#plc)
33- + [BGS](#bgs)
34- + [Bluesky App View](#bluesky-app-view)
35-- [The PDS](#the-pds)
36-37-<!-- tocstop -->
38-39# Guidelines that must be followed
4041Using the sandbox environment means you agree to adhere to our Guidelines. Please read the following carefully:
···4445The sandbox environment is intended to test infrastructure, but user content may be created as part of this testing process. Content generation can be automated or manual.
4647-Do not post content that requires active moderation or violates the [Bluesky Community Guidelines](https://bsky.social/about/support/community-guidelines).
4849## Keep the emphasis on testing
50···119120# Learn more about atproto federation
121122-Check out the [high-level view of federation](https://bsky.social/about/blog/5-5-2023-federation-architecture).
123124Dive deeper with the [atproto docs](https://atproto.com/docs).
125···165166Weโre not actually running a Bluesky PDS in sandbox. You might see Bluesky team members' accounts in the sandbox environment, but those are self-hosted too.
167168-The PDS that youโll be running is much of the same code that is running on the Bluesky production PDS. Notably, all of the in-pds-appview code has been torn out. You can see the actual PDS code that youโre running on the [atproto/simplify-pds](https://github.com/bluesky-social/atproto/pull/1198) branch.
···1011Given that this is a testing environment, we will be defederating from any instances that do not abide by these guidelines, or that cause unnecessary trouble, and will not be providing specific justifications for these decisions.
120000000000000000000000000013# Guidelines that must be followed
1415Using the sandbox environment means you agree to adhere to our Guidelines. Please read the following carefully:
···1819The sandbox environment is intended to test infrastructure, but user content may be created as part of this testing process. Content generation can be automated or manual.
2021+Do not post content that requires active moderation or violates the [Bluesky Community Guidelines](https://blueskyweb.xyz/support/community-guidelines).
2223## Keep the emphasis on testing
24···9394# Learn more about atproto federation
9596+Check out the [high-level view of federation](https://blueskyweb.xyz/blog/5-5-2023-federation-architecture).
9798Dive deeper with the [atproto docs](https://atproto.com/docs).
99···139140Weโre not actually running a Bluesky PDS in sandbox. You might see Bluesky team members' accounts in the sandbox environment, but those are self-hosted too.
141142+The PDS that youโll be running is much of the same code that is running on the Bluesky production PDS. Notably, all of the in-pds-appview code has been torn out. You can see the actual PDS code that youโre running on the [atproto/simplify-pds](https://github.com/bluesky-social/atproto/pull/1198) branch.
···18# The Docker compose file.
19COMPOSE_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml"
2021-# The pdsadmin script.
22-PDSADMIN_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/pdsadmin.sh"
23-24# System dependencies.
25REQUIRED_SYSTEM_PACKAGES="
26 ca-certificates
27 curl
28 gnupg
29- jq
30 lsb-release
31 openssl
32- sqlite3
33 xxd
34"
35# Docker packages.
36REQUIRED_DOCKER_PACKAGES="
37- containerd.io
38 docker-ce
39 docker-ce-cli
40 docker-compose-plugin
041"
4243PUBLIC_IP=""
···50PDS_DATADIR="${1:-/pds}"
51PDS_HOSTNAME="${2:-}"
52PDS_ADMIN_EMAIL="${3:-}"
53-PDS_DID_PLC_URL="https://plc.directory"
54-PDS_BSKY_APP_VIEW_URL="https://api.bsky.app"
55-PDS_BSKY_APP_VIEW_DID="did:web:api.bsky.app"
56-PDS_REPORT_SERVICE_URL="https://mod.bsky.app"
57-PDS_REPORT_SERVICE_DID="did:plc:ar7c4by46qjdydhdevvrndac"
58-PDS_CRAWLERS="https://bsky.network"
5960function usage {
61 local error="${1}"
···93 elif [[ "${DISTRIB_CODENAME}" == "jammy" ]]; then
94 SUPPORTED_OS="true"
95 echo "* Detected supported distribution Ubuntu 22.04 LTS"
96- elif [[ "${DISTRIB_CODENAME}" == "mantic" ]]; then
97- SUPPORTED_OS="true"
98- echo "* Detected supported distribution Ubuntu 23.10 LTS"
99 fi
100 elif [[ "${DISTRIB_ID}" == "debian" ]]; then
101 if [[ "${DISTRIB_CODENAME}" == "bullseye" ]]; then
···112 exit 1
113 fi
114115- # Enforce that the data directory is /pds since we're assuming it for now.
116- # Later we can make this actually configurable.
117- if [[ "${PDS_DATADIR}" != "/pds" ]]; then
118- usage "The data directory must be /pds. Exiting..."
119- fi
120-121 # Check if PDS is already installed.
122 if [[ -e "${PDS_DATADIR}/pds.sqlite" ]]; then
123 echo
···140 echo "For assistance, check https://github.com/bluesky-social/pds"
141 exit 1
142 fi
0143144 #
145 # Attempt to determine server's public IP.
···181182 From your DNS provider's control panel, create the required
183 DNS record with the value of your server's public IP address.
184-185 + Any DNS name that can be resolved on the public internet will work.
186 + Replace example.com below with any valid domain name you control.
187 + A TTL of 600 seconds (10 minutes) is recommended.
188-189 Example DNS record:
190-191 NAME TYPE VALUE
192 ---- ---- -----
193 example.com A ${PUBLIC_IP:-Server public IP}
···228 usage "No admin email specified"
229 fi
2300231 #
232 # Install system packages.
233 #
···241 sleep 2
242 done
243 fi
244-245 apt-get update
246 apt-get install --yes ${REQUIRED_SYSTEM_PACKAGES}
247···309{
310 email ${PDS_ADMIN_EMAIL}
311 on_demand_tls {
312- ask http://localhost:3000/tls-check
313 }
314}
315···330PDS_HOSTNAME=${PDS_HOSTNAME}
331PDS_JWT_SECRET=$(eval "${GENERATE_SECURE_SECRET_CMD}")
332PDS_ADMIN_PASSWORD=${PDS_ADMIN_PASSWORD}
0333PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=$(eval "${GENERATE_K256_PRIVATE_KEY_CMD}")
334-PDS_DATA_DIRECTORY=${PDS_DATADIR}
335PDS_BLOBSTORE_DISK_LOCATION=${PDS_DATADIR}/blocks
336PDS_DID_PLC_URL=${PDS_DID_PLC_URL}
337-PDS_BSKY_APP_VIEW_URL=${PDS_BSKY_APP_VIEW_URL}
338PDS_BSKY_APP_VIEW_DID=${PDS_BSKY_APP_VIEW_DID}
339-PDS_REPORT_SERVICE_URL=${PDS_REPORT_SERVICE_URL}
340-PDS_REPORT_SERVICE_DID=${PDS_REPORT_SERVICE_DID}
341PDS_CRAWLERS=${PDS_CRAWLERS}
342-LOG_ENABLED=true
343PDS_CONFIG
344345 #
···394 fi
395 fi
396397- #
398- # Download and install pdadmin.
399- #
400- echo "* Downloading pdsadmin"
401- curl \
402- --silent \
403- --show-error \
404- --fail \
405- --output "/usr/local/bin/pdsadmin" \
406- "${PDSADMIN_URL}"
407- chmod +x /usr/local/bin/pdsadmin
408-409 cat <<INSTALLER_MESSAGE
410========================================================================
411-PDS installation successful!
412------------------------------------------------------------------------
413414Check service status : sudo systemctl status pds
415Watch service logs : sudo docker logs -f pds
416Backup service data : ${PDS_DATADIR}
417-PDS Admin command : pdsadmin
418419Required Firewall Ports
420------------------------------------------------------------------------
···425426Required DNS entries
427------------------------------------------------------------------------
428-Name Type Value
429------- --------- ---------------
430-${PDS_HOSTNAME} A ${PUBLIC_IP}
431-*.${PDS_HOSTNAME} A ${PUBLIC_IP}
432433Detected public IP of this server: ${PUBLIC_IP}
434435-To see pdsadmin commands, run "pdsadmin help"
00000000436437========================================================================
438INSTALLER_MESSAGE
439-440- CREATE_ACCOUNT_PROMPT=""
441- read -p "Create a PDS user account? (y/N): " CREATE_ACCOUNT_PROMPT
442-443- if [[ "${CREATE_ACCOUNT_PROMPT}" =~ ^[Yy] ]]; then
444- pdsadmin account create
445- fi
446-447}
448449# Run main function.
···18# The Docker compose file.
19COMPOSE_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml"
2000021# System dependencies.
22REQUIRED_SYSTEM_PACKAGES="
23 ca-certificates
24 curl
25 gnupg
026 lsb-release
27 openssl
028 xxd
29"
30# Docker packages.
31REQUIRED_DOCKER_PACKAGES="
032 docker-ce
33 docker-ce-cli
34 docker-compose-plugin
35+ containerd.io
36"
3738PUBLIC_IP=""
···45PDS_DATADIR="${1:-/pds}"
46PDS_HOSTNAME="${2:-}"
47PDS_ADMIN_EMAIL="${3:-}"
48+PDS_DID_PLC_URL="https://plc.bsky-sandbox.dev"
49+PDS_BSKY_APP_VIEW_ENDPOINT="https://api.bsky-sandbox.dev"
50+PDS_BSKY_APP_VIEW_DID="did:web:api.bsky-sandbox.dev"
51+PDS_CRAWLERS="https://bgs.bsky-sandbox.dev"
005253function usage {
54 local error="${1}"
···86 elif [[ "${DISTRIB_CODENAME}" == "jammy" ]]; then
87 SUPPORTED_OS="true"
88 echo "* Detected supported distribution Ubuntu 22.04 LTS"
00089 fi
90 elif [[ "${DISTRIB_ID}" == "debian" ]]; then
91 if [[ "${DISTRIB_CODENAME}" == "bullseye" ]]; then
···102 exit 1
103 fi
104000000105 # Check if PDS is already installed.
106 if [[ -e "${PDS_DATADIR}/pds.sqlite" ]]; then
107 echo
···124 echo "For assistance, check https://github.com/bluesky-social/pds"
125 exit 1
126 fi
127+128129 #
130 # Attempt to determine server's public IP.
···166167 From your DNS provider's control panel, create the required
168 DNS record with the value of your server's public IP address.
169+170 + Any DNS name that can be resolved on the public internet will work.
171 + Replace example.com below with any valid domain name you control.
172 + A TTL of 600 seconds (10 minutes) is recommended.
173+174 Example DNS record:
175+176 NAME TYPE VALUE
177 ---- ---- -----
178 example.com A ${PUBLIC_IP:-Server public IP}
···213 usage "No admin email specified"
214 fi
215216+217 #
218 # Install system packages.
219 #
···227 sleep 2
228 done
229 fi
230+231 apt-get update
232 apt-get install --yes ${REQUIRED_SYSTEM_PACKAGES}
233···295{
296 email ${PDS_ADMIN_EMAIL}
297 on_demand_tls {
298+ ask http://localhost:3000
299 }
300}
301···316PDS_HOSTNAME=${PDS_HOSTNAME}
317PDS_JWT_SECRET=$(eval "${GENERATE_SECURE_SECRET_CMD}")
318PDS_ADMIN_PASSWORD=${PDS_ADMIN_PASSWORD}
319+PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX=$(eval "${GENERATE_K256_PRIVATE_KEY_CMD}")
320PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=$(eval "${GENERATE_K256_PRIVATE_KEY_CMD}")
321+PDS_DB_SQLITE_LOCATION=${PDS_DATADIR}/pds.sqlite
322PDS_BLOBSTORE_DISK_LOCATION=${PDS_DATADIR}/blocks
323PDS_DID_PLC_URL=${PDS_DID_PLC_URL}
324+PDS_BSKY_APP_VIEW_ENDPOINT=${PDS_BSKY_APP_VIEW_ENDPOINT}
325PDS_BSKY_APP_VIEW_DID=${PDS_BSKY_APP_VIEW_DID}
00326PDS_CRAWLERS=${PDS_CRAWLERS}
0327PDS_CONFIG
328329 #
···378 fi
379 fi
380000000000000381 cat <<INSTALLER_MESSAGE
382========================================================================
383+PDS installation successful!
384------------------------------------------------------------------------
385386Check service status : sudo systemctl status pds
387Watch service logs : sudo docker logs -f pds
388Backup service data : ${PDS_DATADIR}
0389390Required Firewall Ports
391------------------------------------------------------------------------
···396397Required DNS entries
398------------------------------------------------------------------------
399+Name Type Value
400------- --------- ---------------
401+${PDS_HOSTNAME} A ${PUBLIC_IP}
402+*.${PDS_HOSTNAME} A ${PUBLIC_IP}
403404Detected public IP of this server: ${PUBLIC_IP}
405406+# To create an invite code, run the following command:
407+408+curl --silent \\
409+ --show-error \\
410+ --request POST \\
411+ --user "admin:${PDS_ADMIN_PASSWORD}" \\
412+ --header "Content-Type: application/json" \\
413+ --data '{"useCount": 1}' \\
414+ https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode
415416========================================================================
417INSTALLER_MESSAGE
00000000418}
419420# Run main function.
-234
pdsadmin/account.sh
···1-#!/bin/bash
2-set -o errexit
3-set -o nounset
4-set -o pipefail
5-6-PDS_ENV_FILE="/pds/pds.env"
7-source "${PDS_ENV_FILE}"
8-9-# curl a URL and fail if the request fails.
10-function curl_cmd_get {
11- curl --fail --silent --show-error "$@"
12-}
13-14-# curl a URL and fail if the request fails.
15-function curl_cmd_post {
16- curl --fail --silent --show-error --request POST --header "Content-Type: application/json" "$@"
17-}
18-19-# curl a URL but do not fail if the request fails.
20-function curl_cmd_post_nofail {
21- curl --silent --show-error --request POST --header "Content-Type: application/json" "$@"
22-}
23-24-# The subcommand to run.
25-SUBCOMMAND="${1:-}"
26-27-#
28-# account list
29-#
30-if [[ "${SUBCOMMAND}" == "list" ]]; then
31- DIDS="$(curl_cmd_get \
32- "https://${PDS_HOSTNAME}/xrpc/com.atproto.sync.listRepos?limit=100" | jq --raw-output '.repos[].did'
33- )"
34- OUTPUT='[{"handle":"Handle","email":"Email","did":"DID"}'
35- for did in ${DIDS}; do
36- ITEM="$(curl_cmd_get \
37- --user "admin:${PDS_ADMIN_PASSWORD}" \
38- "https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.getAccountInfo?did=${did}"
39- )"
40- OUTPUT="${OUTPUT},${ITEM}"
41- done
42- OUTPUT="${OUTPUT}]"
43- echo "${OUTPUT}" | jq --raw-output '.[] | [.handle, .email, .did] | @tsv' | column --table
44-45-#
46-# account create
47-#
48-elif [[ "${SUBCOMMAND}" == "create" ]]; then
49- EMAIL="${2:-}"
50- HANDLE="${3:-}"
51-52- if [[ "${EMAIL}" == "" ]]; then
53- read -p "Enter an email address (e.g. alice@${PDS_HOSTNAME}): " EMAIL
54- fi
55- if [[ "${HANDLE}" == "" ]]; then
56- read -p "Enter a handle (e.g. alice.${PDS_HOSTNAME}): " HANDLE
57- fi
58-59- if [[ "${EMAIL}" == "" || "${HANDLE}" == "" ]]; then
60- echo "ERROR: missing EMAIL and/or HANDLE parameters." >/dev/stderr
61- echo "Usage: $0 ${SUBCOMMAND} <EMAIL> <HANDLE>" >/dev/stderr
62- exit 1
63- fi
64-65- PASSWORD="$(openssl rand -base64 30 | tr -d "=+/" | cut -c1-24)"
66- INVITE_CODE="$(curl_cmd_post \
67- --user "admin:${PDS_ADMIN_PASSWORD}" \
68- --data '{"useCount": 1}' \
69- "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode" | jq --raw-output '.code'
70- )"
71- RESULT="$(curl_cmd_post_nofail \
72- --data "{\"email\":\"${EMAIL}\", \"handle\":\"${HANDLE}\", \"password\":\"${PASSWORD}\", \"inviteCode\":\"${INVITE_CODE}\"}" \
73- "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createAccount"
74- )"
75-76- DID="$(echo $RESULT | jq --raw-output '.did')"
77- if [[ "${DID}" != did:* ]]; then
78- ERR="$(echo ${RESULT} | jq --raw-output '.message')"
79- echo "ERROR: ${ERR}" >/dev/stderr
80- echo "Usage: $0 ${SUBCOMMAND} <EMAIL> <HANDLE>" >/dev/stderr
81- exit 1
82- fi
83-84- echo
85- echo "Account created successfully!"
86- echo "-----------------------------"
87- echo "Handle : ${HANDLE}"
88- echo "DID : ${DID}"
89- echo "Password : ${PASSWORD}"
90- echo "-----------------------------"
91- echo "Save this password, it will not be displayed again."
92- echo
93-94-#
95-# account delete
96-#
97-elif [[ "${SUBCOMMAND}" == "delete" ]]; then
98- DID="${2:-}"
99-100- if [[ "${DID}" == "" ]]; then
101- echo "ERROR: missing DID parameter." >/dev/stderr
102- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
103- exit 1
104- fi
105-106- if [[ "${DID}" != did:* ]]; then
107- echo "ERROR: DID parameter must start with \"did:\"." >/dev/stderr
108- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
109- exit 1
110- fi
111-112- echo "This action is permanent."
113- read -r -p "Are you sure you'd like to delete ${DID}? [y/N] " response
114- if [[ ! "${response}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
115- exit 0
116- fi
117-118- curl_cmd_post \
119- --user "admin:${PDS_ADMIN_PASSWORD}" \
120- --data "{\"did\": \"${DID}\"}" \
121- "https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.deleteAccount" >/dev/null
122-123- echo "${DID} deleted"
124-125-#
126-# account takedown
127-#
128-elif [[ "${SUBCOMMAND}" == "takedown" ]]; then
129- DID="${2:-}"
130- TAKEDOWN_REF="$(date +%s)"
131-132- if [[ "${DID}" == "" ]]; then
133- echo "ERROR: missing DID parameter." >/dev/stderr
134- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
135- exit 1
136- fi
137-138- if [[ "${DID}" != did:* ]]; then
139- echo "ERROR: DID parameter must start with \"did:\"." >/dev/stderr
140- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
141- exit 1
142- fi
143-144- PAYLOAD="$(cat <<EOF
145- {
146- "subject": {
147- "\$type": "com.atproto.admin.defs#repoRef",
148- "did": "${DID}"
149- },
150- "takedown": {
151- "applied": true,
152- "ref": "${TAKEDOWN_REF}"
153- }
154- }
155-EOF
156-)"
157-158- curl_cmd_post \
159- --user "admin:${PDS_ADMIN_PASSWORD}" \
160- --data "${PAYLOAD}" \
161- "https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.updateSubjectStatus" >/dev/null
162-163- echo "${DID} taken down"
164-165-#
166-# account untakedown
167-#
168-elif [[ "${SUBCOMMAND}" == "untakedown" ]]; then
169- DID="${2:-}"
170-171- if [[ "${DID}" == "" ]]; then
172- echo "ERROR: missing DID parameter." >/dev/stderr
173- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
174- exit 1
175- fi
176-177- if [[ "${DID}" != did:* ]]; then
178- echo "ERROR: DID parameter must start with \"did:\"." >/dev/stderr
179- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
180- exit 1
181- fi
182-183- PAYLOAD=$(cat <<EOF
184- {
185- "subject": {
186- "\$type": "com.atproto.admin.defs#repoRef",
187- "did": "${DID}"
188- },
189- "takedown": {
190- "applied": false
191- }
192- }
193-EOF
194-)
195-196- curl_cmd_post \
197- --user "admin:${PDS_ADMIN_PASSWORD}" \
198- --data "${PAYLOAD}" \
199- "https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.updateSubjectStatus" >/dev/null
200-201- echo "${DID} untaken down"
202-#
203-# account reset-password
204-#
205-elif [[ "${SUBCOMMAND}" == "reset-password" ]]; then
206- DID="${2:-}"
207- PASSWORD="$(openssl rand -base64 30 | tr -d "=+/" | cut -c1-24)"
208-209- if [[ "${DID}" == "" ]]; then
210- echo "ERROR: missing DID parameter." >/dev/stderr
211- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
212- exit 1
213- fi
214-215- if [[ "${DID}" != did:* ]]; then
216- echo "ERROR: DID parameter must start with \"did:\"." >/dev/stderr
217- echo "Usage: $0 ${SUBCOMMAND} <DID>" >/dev/stderr
218- exit 1
219- fi
220-221- curl_cmd_post \
222- --user "admin:${PDS_ADMIN_PASSWORD}" \
223- --data "{ \"did\": \"${DID}\", \"password\": \"${PASSWORD}\" }" \
224- "https://${PDS_HOSTNAME}/xrpc/com.atproto.admin.updateAccountPassword" >/dev/null
225-226- echo
227- echo "Password reset for ${DID}"
228- echo "New password: ${PASSWORD}"
229- echo
230-231-else
232- echo "Unknown subcommand: ${SUBCOMMAND}" >/dev/stderr
233- exit 1
234-fi
···1-#!/bin/bash
2-set -o errexit
3-set -o nounset
4-set -o pipefail
5-6-# This script is used to display help information for the pdsadmin command.
7-cat <<HELP
8-pdsadmin help
9---
10-update
11- Update to the latest PDS version.
12- e.g. pdsadmin update
13-14-account
15- list
16- List accounts
17- e.g. pdsadmin account list
18- create <EMAIL> <HANDLE>
19- Create a new account
20- e.g. pdsadmin account create alice@example.com alice.example.com
21- delete <DID>
22- Delete an account specified by DID.
23- e.g. pdsadmin account takedown did:plc:xyz123abc456
24- takedown <DID>
25- Takedown an account specified by DID.
26- e.g. pdsadmin account takedown did:plc:xyz123abc456
27- untakedown <DID>
28- Remove a takedown an account specified by DID.
29- e.g. pdsadmin account takedown did:plc:xyz123abc456
30- password-reset <DID>
31- Reset a password for an account specified by DID.
32- e.g. pdsadmin account reset-password did:plc:xyz123abc456
33-34-request-crawl [<RELAY HOST>]
35- Request a crawl from a relay host.
36- e.g. pdsadmin request-crawl bsky.network
37-38-create-invite-code
39- Create a new invite code.
40- e.g. pdsadmin create-invite-code
41-42-help
43- Display this help information.
44-45-HELP
···1-#!/bin/bash
2-set -o errexit
3-set -o nounset
4-set -o pipefail
5-6-PDS_DATADIR="/pds"
7-COMPOSE_FILE="${PDS_DATADIR}/compose.yaml"
8-COMPOSE_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml"
9-10-# TODO: allow the user to specify a version to update to.
11-TARGET_VERSION="${1:-}"
12-13-COMPOSE_TEMP_FILE="${COMPOSE_FILE}.tmp"
14-15-echo "* Downloading PDS compose file"
16-curl \
17- --silent \
18- --show-error \
19- --fail \
20- --output "${COMPOSE_TEMP_FILE}" \
21- "${COMPOSE_URL}"
22-23-if cmp --quiet "${COMPOSE_FILE}" "${COMPOSE_TEMP_FILE}"; then
24- echo "PDS is already up to date"
25- rm --force "${COMPOSE_TEMP_FILE}"
26- exit 0
27-fi
28-29-echo "* Updating PDS"
30-mv "${COMPOSE_TEMP_FILE}" "${COMPOSE_FILE}"
31-32-echo "* Restarting PDS"
33-systemctl restart pds
34-35-cat <<MESSAGE
36-PDS has been updated
37----------------------
38-Check systemd logs: journalctl --unit pds
39-Check container logs: docker logs pds
40-41-MESSAGE
···00000000000000000000000000000000000000000
-30
pdsadmin.sh
···1-#!/bin/bash
2-set -o errexit
3-set -o nounset
4-set -o pipefail
5-6-PDSADMIN_BASE_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/pdsadmin"
7-8-# Command to run.
9-COMMAND="${1:-help}"
10-shift || true
11-12-# Ensure the user is root, since it's required for most commands.
13-if [[ "${EUID}" -ne 0 ]]; then
14- echo "ERROR: This script must be run as root"
15- exit 1
16-fi
17-18-# Download the script, if it exists.
19-SCRIPT_URL="${PDSADMIN_BASE_URL}/${COMMAND}.sh"
20-SCRIPT_FILE="$(mktemp /tmp/pdsadmin.${COMMAND}.XXXXXX)"
21-22-if ! curl --fail --silent --show-error --location --output "${SCRIPT_FILE}" "${SCRIPT_URL}"; then
23- echo "ERROR: ${COMMAND} not found"
24- exit 2
25-fi
26-27-chmod +x "${SCRIPT_FILE}"
28-if "${SCRIPT_FILE}" "$@"; then
29- rm --force "${SCRIPT_FILE}"
30-fi