80 lines
2.3 KiB
Bash
Executable file
80 lines
2.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
function installDebDeps {
|
|
. /etc/os-release
|
|
# install curl
|
|
sudo apt install curl gnupg --no-install-recommends -y
|
|
|
|
# setup node repo if not running ubuntu
|
|
if [ $NAME == "Ubuntu" && $VERSION_ID -ge "18.04" ]
|
|
then
|
|
echo "Skipping node repository 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 \
|
|
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 {
|
|
rbMasto=`cat .ruby-version`
|
|
rbVersions=`rbenv versions`
|
|
|
|
# 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
|
|
if [[ *$rbMasto* == $rbVersions ]]; then
|
|
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install $rbMasto
|
|
fi
|
|
}
|
|
|
|
function installMastoDeps {
|
|
# create database user
|
|
echo "CREATE USER $(whoami) CREATEDB;" | sudo -u postgres psql
|
|
|
|
# update gem
|
|
printf 'y\n' | gem update --system --no-document
|
|
|
|
# install ruby and nodejs deps
|
|
gem install bundler foreman --no-document
|
|
bundle install -j$(getconf _NPROCESSORS_ONLN)
|
|
yarn install --pure-lockfile
|
|
|
|
# setup db
|
|
bundle exec rails db:setup
|
|
}
|
|
|
|
installDebDeps
|
|
installRuby
|
|
installMastoDeps
|
|
|
|
# Done!
|
|
echo "Setup done! Run 'foreman start' to start sidekiq, streaming, web, and webpack
|
|
Username: admin@localhost:3000
|
|
Password: mastodonadmin"
|