scripts/bin/setupmasto.sh

98 lines
2.7 KiB
Bash
Executable file

#!/usr/bin/env bash
###
# setupmasto.sh v0.1
#
# This script will do everything necessary to download and install a dev Mastodon instance.
# No user interaction required :3
#
# Currently only tested on Debian Stretch and Ubuntu Cosmic
###
#MASTO_REPO=https://github.com/tootsuite/mastodon
MASTO_REPO=https://github.com/glitch-soc/mastodon
MASTO_PATH=$HOME/mastodon-dev
# get os info for proper dep installation
. /etc/os-release
function installDebDeps {
# install curl
sudo apt install curl gnupg --no-install-recommends -y
# setup node repo if not running ubuntu
if [ $NAME == "Ubuntu" ]
then
echo "Skipping node repos since it's uneccessary on this OS"
else
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
fi
# setup yarn repo
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# update repos
sudo apt update
# install needed libraries & programs for ruby & mastodon
sudo apt install --no-install-recommends -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \
g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf libjemalloc-dev \
bison build-essential libssl-dev libyaml-dev libreadline-dev \
zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev \
redis-server redis-tools postgresql postgresql-contrib \
yarn libidn11-dev libicu-dev libjemalloc-dev
}
function installRuby {
# setup rbenv
git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv
cd $HOME/.rbenv && src/configure && make -C src
# add rubyenv to bashrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.bashrc
echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc
# apply env
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
# install ruby-build
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# build and install ruby with jemalloc
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.0
rbenv global 2.6.0
}
function installMastodon {
# create database user
echo "CREATE USER $(whoami) CREATEDB;" | sudo -u postgres psql
# clone glitch-soc
git clone $MASTO_REPO $MASTO_PATH
cd $MASTO_PATH
# update gem
gem update --system --no-document
# install ruby and nodejs deps
#printf 'y\n' | gem install bundler
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile
gem install foreman
# setup db
bundle exec rails db:setup
}
installDebDeps
installRuby
installMastodon
# Done!
echo "Setup done! Run 'foreman start' to start sidekiq, streaming, web, and webpack
Username: admin@localhost:3000
Password: mastodonadmin"