#!/usr/bin/env bash script_log() { echo -e "[setup.sh] >>> $@" } APP_DIR=$1 CHRUBY_PATH=$2 source $CHRUBY_PATH RUBY_VER_NUM=$(cat $APP_DIR/.ruby-version) RUBY_VER="ruby-$RUBY_VER_NUM" if ! command -v ruby >/dev/null || ruby -v | grep -v "$RUBY_VER_NUM" >/dev/null 2>&1; then script_log "Downloading, compiling and installing $RUBY_VER... (this will take a while)" ruby-install $RUBY_VER source $CHRUBY_PATH chruby $RUBY_VER script_log "Installed ruby version: $(ruby -v)" fi if [ ! -f "$APP_DIR/config/nginx.local.conf" ]; then script_log "Setting up nginx configuration..." cp "$APP_DIR/config/nginx.conf.example" "$APP_DIR/config/nginx.local.conf" sed -i -e "s|/home/derpibooru/derpibooru|$APP_DIR|g" "$APP_DIR/config/nginx.local.conf" sed -i -e "s/server_name .*;/server_name derp.lc;/" "$APP_DIR/config/nginx.local.conf" fi if [ ! -f "$APP_DIR/config/booru/settings.yml" ]; then script_log "Copying settings files..." cd "$APP_DIR/config/booru" for f in *.yml.sample; do cp "$f" "${f%.sample}" done fi cd "$APP_DIR" script_log "Dropping existing databases (if any)..." dropdb --if-exists derpibooru_test dropdb --if-exists derpibooru_development script_log "Installing bundler gem..." gem install bundler:2.0.1 bundler config github.https true script_log "Running setup..." ./bin/setup --root "derp.lc" --seed -a || exit 1