Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $USER != root ] ; then
- echo "You must run this script as root"
- exit 1
- fi
- echo "Danbooru Install"
- echo "This script will install Ruby, Rails, PostgreSQL, Unicorn, 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 trunk copy or v1.16.0 and install it in"
- echo "/var/www/danbooru. It will run unicorn, starting on port 8050"
- echo
- 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
- echo -n "Enter a path for danbooru (default: /var/www/danbooru): "
- read danboorupath
- if [ -z $danboorupath ] ; then
- danboorupath="/var/www/danbooru"
- fi
- echo -n "Which danbooru version? [trunk, 1.16.0, 1.18.0, moe]"
- read danbooruversion
- if [ -z $danbooruversion ] ; then
- danbooruversion="1.16.0"
- fi
- # Install packages
- echo "install required packages via apt-get"
- apt-get -y install gcc g++ make libreadline5-dev zlib1g-dev flex bison libgd2-noxpm libgd2-noxpm-dev bzip2 postgresql-8.4 postgresql-contrib-8.4 libpq-dev ruby ruby1.8-dev ri irb rdoc rubygems ragel memcached libmemcache-dev subversion nginx libopenssl-ruby libxml2-dev libxslt-dev libcurl4-openssl-dev
- # Install Ruby gems
- echo "install Ruby/Rails"
- # this bypasses the problem with debian's stupid old version of rubygems
- # html5 requires hoe, but not the most recent version
- gem install hoe --version=2.2.0 --no-ri --no-rdoc
- for i in postgres diff-lcs html5 memcache-client aws-s3 json mechanize net-sftp passenger ; do gem install $i --no-ri --no-rdoc ; done
- gem install rails --version=2.2.2 --no-ri --no-rdoc
- # Create user account
- echo "create danbooru user, allow db access"
- useradd -m danbooru
- PG_HBA_FILE="/etc/postgresql/8.4/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 [ -f /etc/init.d/postgresql-8.4 ]; then /etc/init.d/postgresql-8.4 restart; else /etc/init.d/postgresql restart; fi
- # Install Danbooru
- cd /var/www
- echo "installing danbooru source"
- case "$danbooruversion" in
- 1.16.0)
- echo "installing version: 1.16.0"
- svn export svn://donmai.us/danbooru/tags/danbooru-1.16.0 danbooru
- ;;
- 1.18.0)
- echo "installing version: 1.18.0"
- svn export svn://donmai.us/danbooru/tags/danbooru-1.18.0 danbooru
- ;;
- trunk)
- echo "installing version: trunk"
- svn export svn://donmai.us/danbooru/trunk danbooru
- ;;
- moe)
- echo "installing imouto version: trunk"
- svn export http://svn.imouto.org/repo/svn/trunk/moe/ danbooru
- ;;
- tar16)
- echo "deflating tgz danbooru-1.16.0.tgz"
- tar xfz /tmp/danbooru-1.16.0.tgz -C /var/www
- ;;
- tar18)
- echo "deflating tgz danbooru-1.18.0.tgz"
- tar xfz /tmp/danbooru-1.18.0.tgz -C /var/www
- ;;
- esac
- chown -R danbooru:danbooru danbooru
- cd danbooru
- mkdir -p public/data/sample
- cd config
- cp database.yml.example database.yml
- cp local_config.rb.example local_config.rb
- sed -i -e "s/DAN_HOSTNAME/$hostname/g" local_config.rb
- sed -i -e "s/DAN_SITENAME/$sitename/g" local_config.rb
- cd ../lib/danbooru_image_resizer
- ruby extconf.rb
- make
- cd ../..
- echo "installing danbooru database"
- apt-get install sudo
- sudo -u postgres createuser -s danbooru
- sudo -u danbooru createdb danbooru
- sudo -u danbooru createdb danbooru_dev
- sudo -u danbooru createdb danbooru_test
- sudo -u danbooru psql danbooru < db/postgres.sql
- sudo -u danbooru psql danbooru_dev < db/postgres.sql
- sudo -u danbooru psql danbooru_test < db/postgres.sql
- # I did not run this command when I ran it, but maybe it'll do something useful...
- if [ "$danbooruversion" = "1.18.0" || "$danbooruversion" = "trunk" ]; then
- echo "initialising database"
- script/db-init.sh
- script/db-init.sh
- script/db-init.sh
- #### app/controller/application_controller in application umbenenen
- mv app/controllers/application_controller.rb app/controllers/application.rb
- #### config/envirnment.rb anpassen. ruby version rausnehmen
- sed -i -e "/^RAILS_GEM_VERSION/d" config/environment.rb
- ### middle ware entfernen
- sed -i -e "/^config.middleware.use/d" config/environments/development.rb
- fi
- # Install latest gems
- echo "installing the CORRECT RAIL"
- apt-get install sudo
- cd /var/www/danbooru
- gem install -v=2.3.11 rails --no-ri --no-rdoc
- sudo -u danbooru /var/lib/gems/1.8/bin/rake db:migrate RAILS_ENV=production
- # Install dos2unix
- apt-get install dos2unix
- # Install and configure Passenger
- echo "installing Phusion Passenger"
- /var/lib/gems/1.8/bin/passenger-install-nginx-module --auto
- # Configure nginx
- cd /opt/nginx/conf
- rm -f nginx.conf
- wget http://pastebin.com/raw.php?i=6yrJr5s5
- mv raw.php?i=6yrJr5s5 nginx.conf
- dos2unix nginx.conf
- cd /etc/init.d
- rm -f nginx
- wget http://pastebin.com/raw.php?i=ptFB0Txh
- mv raw.php?i=ptFB0Txh nginx
- dos2unix nginx
- # I don't even...
- pgrep nginx
- kill 873
- # Start nginx
- chmod a+x /etc/init.d/nginx
- /etc/init.d/nginx start
- echo
- echo "I'm done!"
- echo "You should probably set the password for the danbooru account (run passwd danbooru)."
Advertisement
Add Comment
Please, Sign In to add comment