eBooru/INSTALL.debian

183 lines
6.4 KiB
Plaintext
Raw Normal View History

2010-02-06 16:48:40 -05:00
#!/bin/bash
# Run: curl -L -s https://raw.githubusercontent.com/zwagoth/e621ng/master/INSTALL.debian -o install.sh ; chmod +x install.sh ; ./install.sh
2011-08-28 13:28:53 -04:00
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
2011-08-24 17:04:26 -04:00
if [[ "$(whoami)" != "root" ]] ; then
2010-02-06 16:48:40 -05:00
echo "You must run this script as root"
exit 1
fi
verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
2014-05-02 23:27:14 -04:00
echo "* DANBOORU INSTALLATION SCRIPT"
echo "*"
echo "* This script will install all the necessary packages to run Danbooru on a "
echo "* Debian server."
2011-08-26 17:24:07 -04:00
echo
2014-05-02 23:27:14 -04:00
echo -n "* Enter the hostname for this server (ex: danbooru.donmai.us): "
2011-08-30 13:17:32 -04:00
read HOSTNAME
2011-08-26 17:24:07 -04:00
2011-08-30 13:17:32 -04:00
if [[ -z "$HOSTNAME" ]] ; then
2014-05-02 23:27:14 -04:00
echo "* Must enter a hostname"
2011-08-26 17:24:07 -04:00
exit 1
fi
echo -n "* Enter the VLAN IP address for this server (ex: 172.16.0.1, enter nothing to skip): "
read VLAN_IP_ADDR
2010-02-06 16:48:40 -05:00
2011-08-24 16:56:30 -04:00
# Install packages
2014-05-02 23:27:14 -04:00
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
apt-get update
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
apt-get -y install libpq-dev postgresql-client
2018-10-03 16:52:04 -04:00
apt-get -y install liblcms2-dev libjpeg-turbo8-dev libexpat1-dev libgif-dev libpng-dev libexif-dev
# vrack specific stuff
if [ -n "$VLAN_IP_ADDR" ] ; then
apt-get -y install vlan
modprobe 8021q
echo "8021q" >> /etc/modules
vconfig add eno2 99
ip addr add $VLAN_IP_ADDR/24 dev eno2.99
ip link set up eno2.99
curl -L -s $GITHUB_INSTALL_SCRIPTS/vrack-cfg.yaml -o /etc/netplan/01-netcfg.yaml
fi
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
curl -sSL https://deb.nodesource.com/setup_10.x | sudo -E bash -
2011-09-16 17:08:47 -04:00
apt-get update
apt-get -y install nodejs yarn
apt-get remove cmdtest
2011-08-26 17:06:54 -04:00
if [ $? -ne 0 ]; then
2014-05-02 23:27:14 -04:00
echo "* Error installing packages; aborting"
2011-08-26 17:06:54 -04:00
exit 1
fi
2010-02-06 16:48:40 -05:00
# 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
make install
ldconfig
2011-08-26 17:24:07 -04:00
# Create user account
useradd -m danbooru
2011-08-29 14:49:34 -04:00
chsh -s /bin/bash danbooru
2014-05-02 23:27:14 -04:00
usermod -G danbooru,sudo danbooru
2012-09-05 15:47:37 -04:00
2016-10-10 19:19:50 -04:00
# 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
make install
fi
2016-10-10 19:19:50 -04:00
2012-09-05 15:47:37 -04:00
# Install rbenv
2014-05-02 23:27:14 -04:00
echo "* Installing rbenv..."
cd /tmp
sudo -i -u danbooru git clone git://github.com/sstephenson/rbenv.git ~danbooru/.rbenv
sudo -i -u danbooru touch ~danbooru/.bash_profile
2014-05-02 23:27:14 -04:00
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~danbooru/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~danbooru/.bash_profile
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"
2012-09-05 15:47:37 -04:00
2014-05-02 23:27:14 -04:00
# Generate secret token and secret key
echo "* Generating secret keys..."
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/*
2014-05-02 23:27:14 -04:00
chmod 600 ~danbooru/.danbooru/*
2012-09-05 15:47:37 -04:00
# Install gems
2014-05-02 23:27:14 -04:00
echo "* Installing gems..."
sudo -i -u danbooru bash -l -c 'gem install --no-ri --no-rdoc bundler'
2012-09-05 15:47:37 -04:00
2014-05-02 23:27:14 -04:00
echo "* Install configuration scripts..."
2011-08-26 17:24:07 -04:00
2014-05-02 23:27:14 -04:00
# Update PostgreSQL
2016-10-10 19:19:50 -04:00
curl -L -s $GITHUB_INSTALL_SCRIPTS/postgresql_hba_conf -o /etc/postgresql/$PG_VERSION/main/pg_hba.conf
2011-08-26 17:24:07 -04:00
/etc/init.d/postgresql restart
sudo -u postgres createuser -s danbooru
sudo -i -u danbooru createdb danbooru2
2011-08-26 17:24:07 -04:00
2011-08-24 16:56:30 -04:00
# Setup nginx
2016-10-10 19:19:50 -04:00
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
2014-05-02 23:27:14 -04:00
/etc/init.d/nginx restart
2011-08-29 14:49:34 -04:00
2011-08-28 13:17:38 -04:00
# Setup logrotate
2014-05-02 23:27:14 -04:00
curl -L -s $GITHUB_INSTALL_SCRIPTS/danbooru_logrotate_conf -o /etc/logrotate.d/danbooru.conf
2011-08-28 13:17:38 -04:00
2014-05-02 23:27:14 -04:00
# Setup danbooru account
echo "* Enter a new password for the danbooru account"
passwd danbooru
echo "* Setting up SSH keys for the danbooru account"
sudo -i -u danbooru ssh-keygen
2014-05-02 23:27:14 -04:00
2015-10-02 17:51:02 -04:00
mkdir -p /var/www/danbooru2/shared/config
mkdir -p /var/www/danbooru2/shared/data
mkdir -p /var/www/danbooru2/shared/data/preview
mkdir -p /var/www/danbooru2/shared/data/sample
chown -R danbooru:danbooru /var/www/danbooru2
2016-10-10 19:19:50 -04:00
curl -L -s $GITHUB_INSTALL_SCRIPTS/database.yml.templ -o /var/www/danbooru2/shared/config/database.yml
curl -L -s $GITHUB_INSTALL_SCRIPTS/danbooru_local_config.rb.templ -o /var/www/danbooru2/shared/config/danbooru_local_config.rb
2014-05-02 23:27:14 -04:00
2016-09-12 16:49:57 -04:00
echo "* Almost done! You are now ready to deploy Danbooru onto this server."
echo "* Log into Github and fork https://github.com/zwagoth/e621ng into"
2016-09-12 16:49:57 -04:00
echo "* your own repository. Clone your fork onto your local development"
echo "* machine and modify the following files:"
echo "*"
echo "* config/deploy.rb (github repo url)"
echo "* config/deploy/production.rb (servers and users)"
echo "* config/unicorn/production.rb (users)"
echo "* config/application.rb (time zone)"
echo "*"
echo "* On the remote server you will want to modify this file:"
echo "*"
echo "* /var/www/danbooru2/shared/config/danbooru_local_config.rb"
echo "*"
2016-10-10 19:45:37 -04:00
read -p "Press [enter] to continue..."
2016-09-12 16:49:57 -04:00
echo "* Commit your changes and push them to your fork. You are now ready to"
echo "* deploy with the following command:"
echo "*"
echo "* bundle exec capistrano production deploy"
echo "*"
echo "* You can also run a server locally without having to deal with deploys"
echo "* by running the following command:"
echo "*"
2016-10-17 18:53:37 -04:00
echo "* bundle install"
echo "* bundle exec rake db:create db:migrate"
2016-09-12 16:49:57 -04:00
echo "* bundle exec rails server"
2014-05-02 23:27:14 -04:00
echo "*"
2016-09-12 16:49:57 -04:00
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!"