Skip to content

Commit

Permalink
Update the installer script for production network usage (#39)
Browse files Browse the repository at this point in the history
* update the installer script for production network usage

* installer: prompt user to create an account after installation

* fix incorrectly named env
  • Loading branch information
Jacob2161 authored Feb 22, 2024
1 parent 307e235 commit 643a9ff
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ GENERATE_K256_PRIVATE_KEY_CMD="openssl ecparam --name secp256k1 --genkey --noout
# The Docker compose file.
COMPOSE_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/compose.yaml"

# The pdsadmin script.
PDSADMIN_URL="https://raw.githubusercontent.com/bluesky-social/pds/main/pdsadmin.sh"

# System dependencies.
REQUIRED_SYSTEM_PACKAGES="
ca-certificates
curl
gnupg
jq
lsb-release
openssl
xxd
"
# Docker packages.
REQUIRED_DOCKER_PACKAGES="
containerd.io
docker-ce
docker-ce-cli
docker-compose-plugin
containerd.io
"

PUBLIC_IP=""
Expand All @@ -45,10 +49,10 @@ METADATA_URLS+=("http://169.254.169.254/hetzner/v1/metadata/public-ipv4") # Hetz
PDS_DATADIR="${1:-/pds}"
PDS_HOSTNAME="${2:-}"
PDS_ADMIN_EMAIL="${3:-}"
PDS_DID_PLC_URL="https://plc.bsky-sandbox.dev"
PDS_BSKY_APP_VIEW_ENDPOINT="https://api.bsky-sandbox.dev"
PDS_BSKY_APP_VIEW_DID="did:web:api.bsky-sandbox.dev"
PDS_CRAWLERS="https://bgs.bsky-sandbox.dev"
PDS_DID_PLC_URL="https://plc.directory"
PDS_BSKY_APP_VIEW_URL="https://api.bsky.app"
PDS_BSKY_APP_VIEW_DID="did:web:api.bsky.app"
PDS_CRAWLERS="https://bsky.network"

function usage {
local error="${1}"
Expand Down Expand Up @@ -102,6 +106,12 @@ function main {
exit 1
fi

# Enforce that the data directory is /pds since we're assuming it for now.
# Later we can make this actually configurable.
if [[ "${PDS_DATADIR}" != "/pds" ]]; then
usage "The data directory must be /pds. Exiting..."
fi

# Check if PDS is already installed.
if [[ -e "${PDS_DATADIR}/pds.sqlite" ]]; then
echo
Expand All @@ -125,7 +135,6 @@ function main {
exit 1
fi


#
# Attempt to determine server's public IP.
#
Expand Down Expand Up @@ -213,7 +222,6 @@ INSTALLER_MESSAGE
usage "No admin email specified"
fi


#
# Install system packages.
#
Expand Down Expand Up @@ -295,7 +303,7 @@ DOCKERD_CONFIG
{
email ${PDS_ADMIN_EMAIL}
on_demand_tls {
ask http://localhost:3000
ask http://localhost:3000/check-handle
}
}
Expand All @@ -321,7 +329,7 @@ PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=$(eval "${GENERATE_K256_PRIVATE_KEY_CM
PDS_DB_SQLITE_LOCATION=${PDS_DATADIR}/pds.sqlite
PDS_BLOBSTORE_DISK_LOCATION=${PDS_DATADIR}/blocks
PDS_DID_PLC_URL=${PDS_DID_PLC_URL}
PDS_BSKY_APP_VIEW_ENDPOINT=${PDS_BSKY_APP_VIEW_ENDPOINT}
PDS_BSKY_APP_VIEW_URL=${PDS_BSKY_APP_VIEW_ENDPOINT}
PDS_BSKY_APP_VIEW_DID=${PDS_BSKY_APP_VIEW_DID}
PDS_CRAWLERS=${PDS_CRAWLERS}
PDS_CONFIG
Expand Down Expand Up @@ -378,6 +386,18 @@ SYSTEMD_UNIT_FILE
fi
fi

#
# Download and install pdadmin.
#
echo "* Downloading pdsadmin"
curl \
--silent \
--show-error \
--fail \
--output "/usr/local/bin/pdsadmin" \
"${PDSADMIN_URL}"
chmod +x /usr/local/bin/pdsadmin

cat <<INSTALLER_MESSAGE
========================================================================
PDS installation successful!
Expand All @@ -386,6 +406,7 @@ PDS installation successful!
Check service status : sudo systemctl status pds
Watch service logs : sudo docker logs -f pds
Backup service data : ${PDS_DATADIR}
PDS Admin command : pdsadmin
Required Firewall Ports
------------------------------------------------------------------------
Expand All @@ -403,18 +424,18 @@ ${PDS_HOSTNAME} A ${PUBLIC_IP}
Detected public IP of this server: ${PUBLIC_IP}
# To create an invite code, run the following command:
curl --silent \\
--show-error \\
--request POST \\
--user "admin:${PDS_ADMIN_PASSWORD}" \\
--header "Content-Type: application/json" \\
--data '{"useCount": 1}' \\
https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode
To see pdsadmin commands, run "pdsadmin help"
========================================================================
INSTALLER_MESSAGE

CREATE_ACCOUNT_PROMPT=""
read -p "Create a PDS user account? (y/N): " CREATE_ACCOUNT_PROMPT

if [[ "${CREATE_ACCOUNT_PROMPT}" =~ ^[Yy] ]]; then
pdsadmin account create
fi

}

# Run main function.
Expand Down

0 comments on commit 643a9ff

Please sign in to comment.