#!/bin/sh set -e log() { echo 1>&2 echo "== $* ==" 1>&2 } here=`dirname "$0"` APP_ROOT=`cd "$here"/.. && env - pwd` cd "$APP_ROOT" log Beginning system bootstrap # System-specific bootstrapping # TODO: Add support for more systems # TODO: Add system detection if test -r /etc/os-release; then id=`. /etc/os-release && echo "$ID"` if test -r bin/bootstrap.d/"$id".sh; then . bin/bootstrap.d/"$id".sh fi fi log Initializing the database echo "CREATE ROLE derpibooru WITH createdb LOGIN PASSWORD 'password';" | (cd / && exec sudo sudo -u $DB_USER $DB_PROG) log System bootstrap complete log Beginning user bootstrap if ! test -x "$HOME"/.rbenv/bin/rbenv; then log Installing rbenv git clone https://github.com/rbenv/rbenv.git "$HOME"/.rbenv (cd "$HOME"/.rbenv && src/configure && exec make -C src) fi if ! test -d "$HOME"/.rbenv/plugins/ruby-build; then log Installing ruby-build git clone https://github.com/rbenv/ruby-build.git "$HOME"/.rbenv/plugins/ruby-build fi PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH export PATH echo 'eval "$(rbenv init -)"' >>"$HOME"/.bashrc RUBY_VERSION=`head -1 <.ruby-version` log Installing Ruby $RUBY_VERSION rbenv install -s "$RUBY_VERSION" rbenv global "$RUBY_VERSION" log Installing Ruby gems gem install bundler log User bootstrap complete