#!/bin/bash if [[ "$(whoami)" != "root" ]] ; then echo "You must run this script as root" exit 1 fi # echo "Danbooru Install" # echo "This script will install Ruby, Rails, PostgreSQL, and Nginx. By the end," # echo "you should be able to connect to the server and create an account." # echo # echo "It will create a new user called danbooru which will run the Danbooru" # echo "processes. It will download the latest copy and install it in" # echo "/var/www/danbooru." # echo # echo -n "Enter the hostname for this server (ex: danbooru.donmai.us): " # read hostname # # if [[ -z "$hostname" ]] ; then # echo "Must enter a hostname" # exit 1 # fi # # echo -n "Enter a name for the site (default: Danbooru): " # read sitename # # if [[ -z "$sitename" ]] ; then # sitename=Danbooru # fi # Install packages echo "Installing packages..." apt-get -y install build-essential automake openssl libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf ncurses-dev sudo gcc g++ libreadline-dev zlib1g-dev flex bison libgd2-noxpm libgd2-noxpm-dev bzip2 ragel memcached libmemcache-dev git curl libcurl4-openssl-dev # Install PostgreSQL 9.1 apt-get -y install python-software-properties add-apt-repository ppa:pitti/postgresql apt-get update apt-get install -y postgresql-9.1 libpq-dev POSTGRESQL_EXIT=$? # Install RVM echo "Installing RVM..." bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) echo "source /usr/local/rvm/scripts/rvm" >> /etc/bash.bashrc source /usr/local/rvm/scripts/rvm rvm install ruby-1.9.2-p290 --with-openssl-dir=/usr/local rvm 1.9.2 --default # Install gems gem install --no-ri --no-rdoc capistrano # Install Passenger gem install --no-ri --no-rdoc -v 3.0.8 passenger rvm exec passenger-install-nginx-module RVM_EXIT=$? # Setup nginx curl -s https://raw.github.com/ascarter/nginx-ubuntu-rvm/master/nginx > /etc/init.d/nginx chmod +x,g-w /etc/init.d/nginx update-rc.d -f nginx defaults mkdir -p /opt/nginx/sites curl -s https://raw.github.com/r888888888/danbooru/master/script/install/nginx.conf > /opt/nginx/conf/nginx.conf curl -s https://raw.github.com/r888888888/danbooru/master/script/install/nginx.danbooru.conf > /opt/nginx/conf/sites/danbooru.conf if [ $RVM_EXIT -ne 0 ] ; then echo "Passenger installation failed; not starting nginx" else /etc/init.d/nginx start fi # Create user account # useradd -m danbooru PG_HBA_FILE="/etc/postgresql/9.1/main/pg_hba.conf" echo "local all postgres,danbooru trust" > $PG_HBA_FILE echo "host all postgres,danbooru 127.0.0.1/32 trust" >> $PG_HBA_FILE if [ $POSTGRESQL_EXIT -ne 0 ]; then echo "PostgreSQL installation failed; not starting server" else /etc/init.d/postgresql-9.1 restart sudo -u postgres createuser -s danbooru fi echo echo "I'm done!" echo "You should probably set the password for the danbooru account (run passwd danbooru)."