added masto setup script

This commit is contained in:
Zoey Mae 2019-01-31 14:22:34 -05:00
parent e6f71c5d37
commit fc594e3469
2 changed files with 88 additions and 2 deletions

View file

@ -1,19 +1,24 @@
#!/bin/sh
HDPART=/dev/sdb2
ROOT=/dev/sdb2
FS=ext4
CHDIR=/mnt/root
# Mount the root partition
sudo mount $HDPART -t $FS $CHDIR -o noatime,nodiratime
sudo mount $ROOT -t $FS $CHDIR -o noatime,nodiratime
# Various needed pseudo fs dirs
sudo mount --bind /dev $CHDIR/dev
sudo mount --bind /proc $CHDIR/proc
sudo mount --bind /sys $CHDIR/sys
sudo mount --bind /dev/pts $CHDIR/dev/pts
# Uncomment to include /home
#sudo mount --bind /home $CHDIR/home
# Extra mounts
#sudo mount --bind /mnt/data $CHDIR/mnt/data
sudo chroot $CHDIR
sudo umount -R $CHDIR

81
setupmasto.sh Executable file
View file

@ -0,0 +1,81 @@
#!/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 a fresh Debian Stretch install
###
function installDeps {
# install curl
sudo apt install curl --no-install-recommends -y
# setup node and yarn repos
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
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 ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
# add rubyenv to bashrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# refresh env
source ~/.bashrc
# 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 https://github.com/glitch-soc/mastodon.git ~/mastodon-dev
cd ~/mastodon-dev
# cpdate gem
gem update --system
# install ruby and nodejs deps
gem install bundler
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile
gem install foreman
# setup db
bundle exec rails db:setup
}
installDeps()
installRuby()
installMastodon()
# Done!
echo "Setup done! Run 'foreman start' to start sidekiq, streaming, web, and webpack
Username: admin@localhost:3000
Password: mastodonadmin"