unoffical wafrn mirror wafrn.net
atproto social-network activitypub
at testPDSNotExplode 238 lines 7.7 kB view raw
1#!/bin/bash 2set -o errexit 3set -o pipefail 4 5if [ "$EUID" -eq 0 ]; then 6 echo "Please run as a regular user that has 'sudo' access" 7 exit 8fi 9 10export ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 11 12if [ "$1" == "--unattended" ]; then 13 # This will be put there by cloud-init. We only need it to load up the variables then we can discard 14 if [ -f /wafrn-cloud-config ]; then 15 sudo chmod 755 /wafrn-cloud-config 16 source /wafrn-cloud-config 17 sudo rm /wafrn-cloud-config 18 fi 19else 20 cat $ROOT_DIR/docs/assets/logo.ansi.txt || true 21 echo 22 echo "Remember, this script is made for Debian/Ubuntu based systems. It will install Docker, and then set up wafrn under it. Make sure you don't have anything running under ports 80 and 443" 23 echo 24 echo "Please make sure to read the docs before continuing. Or don't. You have been warned" 25 echo 26 echo "Please write the domain name of your wafrn instance." 27 echo "Make sure you have the domain pointing to this server" 28 read DOMAIN_NAME 29 echo 30 echo "Ok now we need an email for the administrator user" 31 read ADMIN_EMAIL 32 echo 33 echo "We now need a handle for your administrator user. If this will be a personal, single-user instance then you can enter the username you wish to use as your main." 34 echo "Otherwise 'admin' is a good choice. You can also have a separate 'admin' and personal account as well." 35 read ADMIN_USER 36 echo 37 echo Do you wish to support Bluesky? 38 echo Enter 'Y' for yes 39 read BLUESKY_SUPPORT 40 41 if [[ $BLUESKY_SUPPORT =~ ^[Yy]$ ]]; then 42 echo 43 echo "Please enter your bluesky domain." 44 echo "This needs to be different from your wafrn instance, for example bsky.example.com" 45 echo "Make sure you point both <domain> AND *.<domain> to this server" 46 read PDS_DOMAIN_NAME 47 echo 48 echo "Please enter the handle for your admin user. Your user will then be available at @<username>.bsky.example.com" 49 echo "Note: there are some limitations on what is supported and there are a lot of reserved words you cannot use, like 'admin'" 50 echo "Check the following site for a full list: https://github.com/bluesky-social/atproto/blob/main/packages/pds/src/handle/reserved.ts" 51 echo "If unsure enter 'wafrnadmin'" 52 read PDS_ADMIN_USERNAME 53 fi 54 55 echo 56 echo Do you wish to send emails? This mainly includes invites and reset password requests. 57 echo "Note: You should have emails enabled unless you are doing a single-user instance, otherwise people won't be able to reset their password properly" 58 echo Enter 'Y' for yes 59 read EMAIL_SUPPORT 60 61 if [[ $EMAIL_SUPPORT =~ ^[Yy]$ ]]; then 62 echo 63 echo "Did you read the manual? We need a SMTP server config in this case" 64 echo 65 echo "Tell us the SMTP host" 66 read SMTP_HOST 67 echo 68 echo "Tell us the SMTP port. E.g. 587" 69 read SMTP_PORT 70 echo 71 echo "We need the SMTP username" 72 read SMTP_USER 73 echo 74 echo "Tell us the SMTP user password" 75 read SMTP_PASSWORD 76 echo 77 echo "We need the email address that will send the emails, e.g wafrn@example.com" 78 read SMTP_FROM 79 echo 80 echo "Do you want to send welcome emails to users needing approval?" 81 echo "While it's a nice thing to do, this might allow attackers to spam people through you, and therefore you can get blocked by your SMTP provider" 82 echo Enter 'Y' for yes 83 read SEND_ACTIVATION_MAIL 84 fi 85 86 echo Please select from the following packages: 87 # workers dont work well on minimum install and ªªªª 88 #echo "1: Minimum install (default); Runs the bare minimum to get Wafrn running" 89 #echo "2: Monitoring support; Minimum install with added Grafana to monitor your instance" 90 echo "3: Advanced install (recommended); More advanced config, with separate workers to handle the load. Preferred options for larger instances." 91 echo "4: Advanced install with monitoring support; The full package: advanced install plus Grafana support" 92 93 read INSTALL_TYPE 94 95 echo 96 echo 97 echo "--------------------------------------------" 98 echo "Ok that was all. Let's get the party started" 99 echo "--------------------------------------------" 100fi 101 102export DOCKER_COMPOSE_FILENAME=docker-compose.simple.yml 103 104if [[ $INSTALL_TYPE == "2" ]]; then 105 export DOCKER_COMPOSE_FILENAME=docker-compose.simple.metrics.yml 106fi 107 108if [[ $INSTALL_TYPE == "3" ]]; then 109 export DOCKER_COMPOSE_FILENAME=docker-compose.advanced.yml 110fi 111 112if [[ $INSTALL_TYPE == "4" ]]; then 113 export DOCKER_COMPOSE_FILENAME=docker-compose.advanced.metrics.yml 114fi 115 116if [[ ! $BLUESKY_SUPPORT =~ ^[Yy]$ ]]; then 117 export COMPOSE_PROFILES=default 118 export PDS_DOMAIN_NAME=bsky.example.com 119fi 120 121if [[ $EMAIL_SUPPORT =~ ^[Yy]$ ]]; then 122 if [[ ! $SEND_ACTIVATION_MAIL =~ ^[Yy]$ ]]; then 123 export DISABLE_REQUIRE_SEND_EMAIL=true 124 fi 125else 126 export DISABLE_REQUIRE_SEND_EMAIL=true 127fi 128 129 130export DOMAIN_NAME PDS_DOMAIN_NAME ADMIN_EMAIL ADMIN_USER SMTP_HOST SMTP_PORT SMTP_USER SMTP_PASSWORD SMTP_FROM BLUESKY_SUPPORT 131 132export CACHE_DOMAIN=cdn.${DOMAIN_NAME} 133export MEDIA_DOMAIN=media.${DOMAIN_NAME} 134export ACME_EMAIL=${ADMIN_EMAIL} 135export FRONTEND_MEDIA_URL=https://${MEDIA_DOMAIN} 136export FRONTEND_CACHE_URL=https://${CACHE_DOMAIN}/api/cache?media= 137 138echo 139echo "-------------------" 140echo "Installing packages" 141echo "-------------------" 142 143sudo apt update 144sudo apt install -y git postgresql-client curl lsb-release wget build-essential sudo jq xxd 145 146echo 147echo "-----------------" 148echo "Installing docker" 149echo "-----------------" 150 151pushd $(mktemp -d) 152curl -fsSL https://get.docker.com -o get-docker.sh 153sudo sh ./get-docker.sh 154popd 155 156sudo groupadd docker || true 157sudo usermod -aG docker $USER 158 159newgrp docker <<POST_DOCKER 160#!/bin/bash 161set -o errexit 162set -o pipefail 163 164echo 165echo "-------------------------" 166echo "Installing the repository" 167echo "-------------------------" 168 169cd $HOME 170git clone https://codeberg.org/wafrn/wafrn.git 171cd wafrn 172 173echo 174echo "---------------------" 175echo "Setting up the config" 176echo "---------------------" 177 178source install/env_secret_setup.sh 179cp $DOCKER_COMPOSE_FILENAME docker-compose.yml 180 181echo 182echo "--------------------------" 183echo "Building and starting apps" 184echo "--------------------------" 185docker compose build 186docker compose up -d 187 188case $BLUESKY_SUPPORT in 189 Y|y) 190 echo 191 echo "--------------------------" 192 echo "Setting up Bluesky support" 193 echo "--------------------------" 194 195 ./install/bsky/create-admin.sh $PDS_ADMIN_USERNAME 196 ./install/bsky/add-insert-code.sh 197 sed -i 's/ENABLE_BSKY=.*/ENABLE_BSKY=true/' .env 198 docker compose build 199 docker compose up -d 200 ;; 201esac 202 203POST_DOCKER 204 205echo "------------------" 206echo "Setting up backups" 207echo "------------------" 208 209cat <<CROND_FILE | sudo tee /etc/cron.d/wafrn-backup 21022 3 * * * $(whoami) $HOME/wafrn/install/manage.sh backup 211CROND_FILE 212 213echo "-------------------------" 214echo "Setting up cache cleanups" 215echo "-------------------------" 216 217cat <<CROND_FILE | sudo tee /etc/cron.d/wafrn-cleanup 21822 4 * * * $(whoami) $HOME/wafrn/install/manage.sh clean 219CROND_FILE 220 221echo 222echo "----" 223echo "Done" 224echo "----" 225 226source $HOME/wafrn/.env 227 228echo "Well done. The database user and password have been introduced in the config file over at '~/wafrn/.env'" 229echo 230echo "You can log in at https://${DOMAIN_NAME} with the email '${ADMIN_EMAIL}' and the password '${ADMIN_PASSWORD}'" 231echo 232echo "For the Bluesky integration to work make sure to read the docs on what to do as next steps." 233echo "Before doing any activity however it is **highly** advised to log out and log back in to the shell" 234 235if [[ $INSTALL_TYPE =~ ^[24]$ ]]; then 236 echo 237 echo "For monitoring please go to https://monitoring.${DOMAIN_NAME} with username 'admin' and password '${GF_SECURITY_ADMIN_PASSWORD}'" 238fi