Initial setup script changes as required by danbooru.

This commit is contained in:
Kira 2019-01-31 12:27:40 -08:00
parent 0c791a1257
commit dbf46d3522
6 changed files with 137 additions and 21 deletions

View File

@ -1 +1 @@
2.5.1
2.5.3

View File

@ -521,4 +521,4 @@ DEPENDENCIES
whenever
BUNDLED WITH
1.16.1
2.0.1

View File

@ -1,9 +1,9 @@
#!/bin/bash
# Run: curl -L -s https://raw.githubusercontent.com/r888888888/danbooru/master/INSTALL.debian -o install.sh ; chmod +x install.sh ; ./install.sh
# Run: curl -L -s https://raw.githubusercontent.com/zwagoth/e621ng/master/INSTALL.debian -o install.sh ; chmod +x install.sh ; ./install.sh
export RUBY_VERSION=2.5.1
export GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/r888888888/danbooru/master/script/install
export RUBY_VERSION=2.5.3
export GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/zwagoth/e621ng/master/script/install
export VIPS_VERSION=8.7.0
if [[ "$(whoami)" != "root" ]] ; then
@ -97,25 +97,26 @@ fi
# Install rbenv
echo "* Installing rbenv..."
cd /tmp
sudo -u danbooru git clone git://github.com/sstephenson/rbenv.git ~danbooru/.rbenv
sudo -u danbooru touch ~danbooru/.bash_profile
sudo -i -u danbooru git clone git://github.com/sstephenson/rbenv.git ~danbooru/.rbenv
sudo -i -u danbooru touch ~danbooru/.bash_profile
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~danbooru/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~danbooru/.bash_profile
sudo -u danbooru mkdir -p ~danbooru/.rbenv/plugins
sudo -u danbooru git clone git://github.com/sstephenson/ruby-build.git ~danbooru/.rbenv/plugins/ruby-build
sudo -u danbooru bash -l -c "rbenv install $RUBY_VERSION"
sudo -u danbooru bash -l -c "rbenv global $RUBY_VERSION"
sudo -i -u danbooru mkdir -p ~danbooru/.rbenv/plugins
sudo -i -u danbooru git clone git://github.com/sstephenson/ruby-build.git ~danbooru/.rbenv/plugins/ruby-build
sudo -i -u danbooru bash -l -c "rbenv install $RUBY_VERSION"
sudo -i -u danbooru bash -l -c "rbenv global $RUBY_VERSION"
# Generate secret token and secret key
echo "* Generating secret keys..."
sudo -u danbooru mkdir ~danbooru/.danbooru/
sudo -u danbooru sh -c 'openssl rand -hex 32 > ~danbooru/.danbooru/secret_token'
sudo -u danbooru sh -c 'openssl rand -hex 32 > ~danbooru/.danbooru/session_secret_key'
sudo -i -u danbooru mkdir ~danbooru/.danbooru/
openssl rand -hex 32 > ~danbooru/.danbooru/secret_token
openssl rand -hex 32 > ~danbooru/.danbooru/session_secret_key
chown danbooru:danbooru ~danbooru/.danbooru/*
chmod 600 ~danbooru/.danbooru/*
# Install gems
echo "* Installing gems..."
sudo -u danbooru bash -l -c 'gem install --no-ri --no-rdoc bundler'
sudo -i -u danbooru bash -l -c 'gem install --no-ri --no-rdoc bundler'
echo "* Install configuration scripts..."
@ -123,7 +124,7 @@ echo "* Install configuration scripts..."
curl -L -s $GITHUB_INSTALL_SCRIPTS/postgresql_hba_conf -o /etc/postgresql/$PG_VERSION/main/pg_hba.conf
/etc/init.d/postgresql restart
sudo -u postgres createuser -s danbooru
sudo -u danbooru createdb danbooru2
sudo -i -u danbooru createdb danbooru2
# Setup nginx
curl -L -s $GITHUB_INSTALL_SCRIPTS/nginx.danbooru.conf -o /etc/nginx/sites-enabled/danbooru.conf
@ -138,7 +139,7 @@ echo "* Enter a new password for the danbooru account"
passwd danbooru
echo "* Setting up SSH keys for the danbooru account"
sudo -u danbooru ssh-keygen
sudo -i -u danbooru ssh-keygen
mkdir -p /var/www/danbooru2/shared/config
mkdir -p /var/www/danbooru2/shared/data
@ -149,7 +150,7 @@ curl -L -s $GITHUB_INSTALL_SCRIPTS/database.yml.templ -o /var/www/danbooru2/shar
curl -L -s $GITHUB_INSTALL_SCRIPTS/danbooru_local_config.rb.templ -o /var/www/danbooru2/shared/config/danbooru_local_config.rb
echo "* Almost done! You are now ready to deploy Danbooru onto this server."
echo "* Log into Github and fork https://github.com/r888888888/danbooru into"
echo "* Log into Github and fork https://github.com/zwagoth/e621ng into"
echo "* your own repository. Clone your fork onto your local development"
echo "* machine and modify the following files:"
echo "*"
@ -178,3 +179,4 @@ echo "*"
echo "* This will start a web process running on port 3000 that you can"
echo "* connect to. This is useful for development and testing purposes."
echo "* If something breaks post about it on the Danbooru Github. Good luck!"

114
INSTALL_DEV.ubuntu Normal file
View File

@ -0,0 +1,114 @@
#!/bin/bash
# Run: curl -L -s https://raw.githubusercontent.com/zwagoth/e621ng/master/INSTALL.debian -o install.sh ; chmod +x install.sh ; ./install.sh
export RUBY_VERSION=2.5.3
export GITHUB_INSTALL_SCRIPTS=https://raw.githubusercontent.com/zwagoth/e621ng/master/script/install
export VIPS_VERSION=8.7.0
verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
# Install packages
echo "* Installing packages..."
if [ -n "$(uname -a | grep Ubuntu)" ] ; then
LIBSSL_DEV_PKG=libssl-dev
else
LIBSSL_DEV_PKG=$( verlt `lsb_release -sr` 9.0 && echo libssl-dev || echo libssl1.0-dev )
fi
sudo apt-get update
sudo apt-get -y install $LIBSSL_DEV_PKG build-essential automake libxml2-dev libxslt-dev ncurses-dev sudo libreadline-dev flex bison ragel memcached libmemcached-dev git curl libcurl4-openssl-dev sendmail-bin sendmail nginx ssh coreutils ffmpeg mkvtoolnix
sudo apt-get -y install libpq-dev postgresql-client postgresql postgresql-server-dev-10
sudo apt-get -y install liblcms2-dev libjpeg-turbo8-dev libexpat1-dev libgif-dev libpng-dev libexif-dev
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
curl -sSL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get update
sudo apt-get -y install nodejs yarn
sudo apt-get remove cmdtest
if [ $? -ne 0 ]; then
echo "* Error installing packages; aborting"
exit 1
fi
# compile and install libvips (the version in apt is too old)
cd /tmp
wget -q https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz
tar xzf vips-$VIPS_VERSION.tar.gz
cd vips-$VIPS_VERSION
./configure --prefix=/usr
sudo make install
sudo ldconfig
# Set up Postgres
export PG_VERSION=`pg_config --version | egrep -o '[0-9]{1,}\.[0-9]{1,}'`
if verlte 9.5 $PG_VERSION ; then
# only do this on postgres 9.5 and above
git clone https://github.com/r888888888/test_parser.git /tmp/test_parser
cd /tmp/test_parser
sudo make install
fi
# Install rbenv
echo "* Installing rbenv..."
cd /tmp
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
touch ~/.bash_profile
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
mkdir -p ~/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install $RUBY_VERSION
rbenv global $RUBY_VERSION
# Generate secret token and secret key
echo "* Generating secret keys..."
mkdir ~/.danbooru/
openssl rand -hex 32 > ~/.danbooru/secret_token
openssl rand -hex 32 > ~/.danbooru/session_secret_key
chmod 600 ~/.danbooru/*
# Install gems
echo "* Installing gems..."
gem install --no-ri --no-rdoc bundler
echo "* Install configuration scripts..."
# Update PostgreSQL
curl -L -s $GITHUB_INSTALL_SCRIPTS/postgresql_hba_conf -o /etc/postgresql/$PG_VERSION/main/pg_hba.conf
/etc/init.d/postgresql restart
sudo -u postgres createuser -s danbooru
sudo -u postgres createdb danbooru2
# Setup nginx
curl -L -s $GITHUB_INSTALL_SCRIPTS/nginx.danbooru.conf -o /etc/nginx/sites-enabled/danbooru.conf
sed -i -e "s/__hostname__/$HOSTNAME/g" /etc/nginx/sites-enabled/danbooru.conf
/etc/init.d/nginx restart
echo "* Clone the repo into your home folder."
echo "* Copy the database.yml and danbooru_local_config.rb templates from the "
echo "* scripts/install folder into the config folder and edit them to your needs."
echo "* Remember to add 'user: danbooru' to the database yml file for development roles."
echo "* You can then run a server locally without having to deal with deploys"
echo "* by running the following command:"
echo "*"
echo "* bundle install"
echo "* yarn install"
echo "* RAILS_ENV=development bundle exec rake db:migrate"
echo "* bundle exec rails server"
echo "*"
echo "* Run RAILS_ENV=development bundle exec rake db:seed after you have"
echo "* created a new user!"
echo "*"
echo "* This will start a web process running on port 3000 that you can"
echo "* connect to. This is useful for development and testing purposes."
echo "* If something breaks post about it on the Github. Good luck!"

View File

@ -17,7 +17,7 @@ module Danbooru
config.assets.version = '1.0'
config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical #{config.root}/app/mailers)
config.plugins = [:all]
config.time_zone = 'Eastern Time (US & Canada)'
config.time_zone = 'UTC'
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:enable_starttls_auto => false}
config.action_mailer.perform_deliveries = true

View File

@ -1,9 +1,9 @@
set :stages, %w(production development staging)
set :default_stage, "staging"
set :application, "danbooru"
set :repo_url, "git://github.com/r888888888/danbooru.git"
set :repo_url, "git://github.com/zwagoth/e621ng.git"
set :scm, :git
set :deploy_to, "/var/www/danbooru"
set :rbenv_ruby, "2.5.1"
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle')
set :branch, ENV.fetch("branch", "master")
set :branch, ENV.fetch("branch", "master")