1
mirror of https://github.com/jakejarvis/mastodon-installer.git synced 2025-04-28 05:10:29 -04:00

better random alphanumeric db password

This commit is contained in:
Jake Jarvis 2022-11-25 13:33:16 -05:00
parent 152c39d6e6
commit 96817896d6
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
3 changed files with 12 additions and 9 deletions

View File

@ -8,7 +8,7 @@ Be your own [hall monitor](https://twitter.com/elonmusk/status/15947577342677647
## Requirements
- Ubuntu 20.04 LTS
- Ubuntu 20.04 LTS (support for 22.04 is in the works!)
- A domain name (or subdomain) already pointing to your server's IP
## Usage

View File

@ -66,13 +66,15 @@ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' | sudo tee -a "$MASTODON_ROOT/.b
# clone mastodon & checkout latest version
sudo -u mastodon git clone https://github.com/mastodon/mastodon.git "$MASTODON_ROOT/live" && cd "$MASTODON_ROOT/live"
sudo -u mastodon git checkout "$(sudo -u mastodon git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)"
sudo git config --global --add safe.directory "$MASTODON_ROOT/live" || true
# permission fixes
sudo chown -R mastodon:mastodon "$MASTODON_ROOT/live" "$RBENV_ROOT"
# install ruby
sudo -u mastodon RUBY_CONFIGURE_OPTS=--with-jemalloc "$RBENV_ROOT/bin/rbenv" install "$(cat $MASTODON_ROOT/live/.ruby-version)"
sudo -u mastodon "$RBENV_ROOT/bin/rbenv" global "$(cat $MASTODON_ROOT/live/.ruby-version)"
RUBY_VERSION="$(sudo -u mastodon cat $MASTODON_ROOT/live/.ruby-version)"
sudo -u mastodon RUBY_CONFIGURE_OPTS=--with-jemalloc "$RBENV_ROOT/bin/rbenv" install "$RUBY_VERSION" || true
sudo -u mastodon "$RBENV_ROOT/bin/rbenv" global "$RUBY_VERSION"
# install npm and gem dependencies
sudo -u mastodon "$RBENV_ROOT/shims/gem" install bundler --no-document
@ -82,8 +84,8 @@ sudo -u mastodon "$RBENV_ROOT/shims/bundle" install --jobs "$(getconf _NPROCESSO
sudo -u mastodon yarn set version classic
sudo -u mastodon yarn install --pure-lockfile --network-timeout 100000
# set up database w/ secure password
DB_PASSWORD=$(openssl rand -base64 32)
# set up database w/ random alphanumeric password
DB_PASSWORD=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c32; echo)
echo "CREATE USER mastodon WITH PASSWORD '$DB_PASSWORD' CREATEDB" | sudo -u postgres psql -f -
# populate .env.production config

View File

@ -24,8 +24,9 @@ sudo -u mastodon git fetch --tags
sudo -u mastodon git checkout "$(sudo -u mastodon git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)"
# set new ruby version
sudo -u mastodon RUBY_CONFIGURE_OPTS=--with-jemalloc "$RBENV_ROOT/bin/rbenv" install "$(cat $MASTODON_ROOT/live/.ruby-version)" || true
sudo -u mastodon "$RBENV_ROOT/bin/rbenv" global "$(cat $MASTODON_ROOT/live/.ruby-version)"
RUBY_VERSION="$(sudo -u mastodon cat $MASTODON_ROOT/live/.ruby-version)"
sudo -u mastodon RUBY_CONFIGURE_OPTS=--with-jemalloc "$RBENV_ROOT/bin/rbenv" install "$RUBY_VERSION" || true
sudo -u mastodon "$RBENV_ROOT/bin/rbenv" global "$RUBY_VERSION"
# update dependencies
sudo -u mastodon "$RBENV_ROOT/shims/bundle" install --jobs "$(getconf _NPROCESSORS_ONLN)"
@ -39,7 +40,7 @@ sudo -u mastodon RAILS_ENV=production "$RBENV_ROOT/shims/bundle" exec rails asse
# restart mastodon
sudo systemctl reload mastodon-web
sudo systemctl restart mastodon-sidekiq
sudo systemctl restart mastodon-sidekiq mastodon-streaming
# clear caches & run post-deployment db migration
sudo -u mastodon RAILS_ENV=production "$RBENV_ROOT/shims/ruby" "$MASTODON_ROOT/live/bin/tootctl" cache clear
@ -47,7 +48,7 @@ sudo -u mastodon RAILS_ENV=production "$RBENV_ROOT/shims/bundle" exec rails db:m
# restart mastodon again
sudo systemctl reload mastodon-web
sudo systemctl restart mastodon-sidekiq
sudo systemctl restart mastodon-sidekiq mastodon-streaming
echo "All done! Check the latest release notes, there may be additional version-specific steps:"
echo "https://github.com/mastodon/mastodon/releases"