From 03ec687331b9654d6f993e2d5972080f27fc8509 Mon Sep 17 00:00:00 2001 From: byte Date: Sun, 17 Feb 2019 14:47:05 -0500 Subject: [PATCH] add elasticsearch to vagrant setup --- bin/setup | 4 ++++ vagrant/install.sh | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/setup b/bin/setup index 94fd4d797..6acf8ac04 100755 --- a/bin/setup +++ b/bin/setup @@ -28,6 +28,10 @@ chdir APP_ROOT do puts "\n== Preparing database ==" system! 'bin/rails db:setup' + puts "\n== Preparing search indices ==" + system! 'bin/rails r Post.__elasticsearch__.create_index!' + systen! 'bin/rails r Post.import' + puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' diff --git a/vagrant/install.sh b/vagrant/install.sh index b5a6b790c..e3322461a 100644 --- a/vagrant/install.sh +++ b/vagrant/install.sh @@ -37,6 +37,13 @@ if ! grep danbooru /etc/passwd >/dev/null; then usermod -aG vagrant,www-data danbooru fi +if ! package_installed elasticsearch; then + install_packages apt-transport-https default-jre-headless + add_key https://packages.elastic.co/GPG-KEY-elasticsearch + echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" > /etc/apt/sources.list.d/elasticsearch-6.x.list + script_log "Elasticsearch repository added" +fi + if ! package_installed postgresql-11; then add_key https://www.postgresql.org/media/keys/ACCC4CF8.asc echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list @@ -70,11 +77,17 @@ if ! install_packages \ mkvtoolnix cmake ffmpeg git postgresql-11 libcurl4-openssl-dev ffmpeg \ libicu-dev libjpeg-progs libpq-dev libreadline-dev libxml2-dev \ libexpat1-dev nodejs optipng redis-server postgresql-server-dev-11 \ - liblcms2-dev libjpeg62-turbo-dev libgif-dev libpng-dev libexif-dev; then - >&2 script_log "Installation of other dependencies failed, please see the errors above and re-run \`vagrant provision\`" + liblcms2-dev libjpeg62-turbo-dev libgif-dev libpng-dev libexif-dev \ + elasticsearch; then + >&2 script_log "Installation of dependencies failed, please see the errors above and re-run \`vagrant provision\`" exit 1 fi +script_log "Setting up elasticsearch..." +sed -i -e 's/\(-Xm[sx]\)1g/\1256m/' /etc/elasticsearch/jvm.options +systemctl enable elasticsearch 2>/dev/null +service elasticsearch start + script_log "Setting up postgres..." sed -i -e 's/md5/trust/' /etc/postgresql/11/main/pg_hba.conf