# -*- mode: shell-script -*- PDS_LOCAL_DATADIR=/var/lib/bluesky PDS_DATADIR="$SERVICE_DATASTORE$PDS_LOCAL_DATADIR" PDS_ENV_FILE="$PDS_DATADIR/.env" bluesky:init() { local admin_password init-config-add " $SERVICE_NAME: env_file: - \"$PDS_ENV_FILE\" " [ -e "$PDS_ENV_FILE" ] && return admin_password=$(password:get admin internal) || { err "Failed to get admin password" >&2 return 1 } mkdir -p "${PDS_ENV_FILE%/*}" if ! plc_key=$(openssl ecparam --name secp256k1 --genkey --noout --outform DER 2>&1); then err "Failed to generate PLC key" >&2 e "$plc_key" | prefix " $GRAY|$NORMAL " >&2 return 1 fi if ! plc_key=$(set -o pipefail echo "$plc_key" | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32 2>&1 ); then err "Failed to extract PLC key" >&2 e "$plc_key" | prefix " $GRAY|$NORMAL " >&2 return 1 fi if ! jwt_secret=$(openssl rand -hex 16); then err "Failed to generate JWT secret" >&2 e "$jwt_secret" | prefix " $GRAY|$NORMAL " >&2 return 1 fi cat > "$PDS_ENV_FILE" </dev/null) && [ -n "$email_from" ]; then echo "PDS_EMAIL_FROM_ADDRESS=${email_from}" >> "$PDS_ENV_FILE" fi }