Files
danbooru/INSTALL.debian
2011-08-26 17:24:07 -04:00

86 lines
2.7 KiB
Bash

#!/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
if [ $? -ne 0 ]; then
exit 1
fi
# 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
if [ $? -ne 0 ]; then
exit 1
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
/etc/init.d/postgresql restart
sudo -u postgres createuser -s danbooru
# 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
sed -i -e 's/HOSTNAME/$hostname/g' /opt/nginx/conf/sites/danbooru.conf
/etc/init.d/nginx start
echo
echo "I'm done!"
echo "You should probably set the password for the danbooru account (run passwd danbooru)."