Spotter-VM/seeddms.sh

50 lines
1.7 KiB
Bash

#!/bin/bash
SOURCE_DIR=$(realpath $(dirname "${0}"))
# Install dependencies for SeedDMS
apt-get -y --no-install-recommends install php7.0-gd php7.0-fpm php7.0-mbstring php7.0-pgsql php7.0-xml php-log php-mail php-pear
# Install SeedDMS
git clone https://git.code.sf.net/p/seeddms/code /srv/seeddms
git -C /srv/seeddms checkout seeddms-5.1.x
rm -rf /srv/seeddms/.git
# Populate database
export SEEDDMS_PWD=$(head -c 260 /dev/urandom | tr -cd '[:alnum:]' | head -c 26)
envsubst <${SOURCE_DIR}/seeddms/tmp/createdb-seeddms.sql >/tmp/createdb-seeddms.sql
sudo -u postgres psql -f /tmp/createdb-seeddms.sql
rm -f /tmp/createdb-seeddms.sql
export PGPASSWORD=${SEEDDMS_PWD}
psql -f /srv/seeddms/install/create_tables-postgres.sql seeddms seeddms
unset PGPASSWORD
# Configure SeedDMS
envsubst <${SOURCE_DIR}/seeddms/srv/seeddms/conf/settings.xml >/srv/seeddms/conf/settings.xml
# Adjust directory structure
mkdir -p /srv/seeddms/data/{lucene,staging,cache}
mkdir /srv/seeddms/SeedDMS
mv /srv/seeddms/SeedDMS_Core/Core* /srv/seeddms/SeedDMS/
mv /srv/seeddms/SeedDMS_Lucene/Lucene* /srv/seeddms/SeedDMS/
mv /srv/seeddms/SeedDMS_Preview/Preview* /srv/seeddms/SeedDMS/
mv /srv/seeddms/SeedDMS_SQLiteFTS/SQLiteFTS* /srv/seeddms/SeedDMS/
rm -rf /srv/seeddms/SeedDMS_*
rm -rf /srv/seeddms/install/
rm -rf /srv/seeddms/ext/example/
chown -R www-data:www-data /srv/seeddms/
# Create nginx app definition
cp ${SOURCE_DIR}/seeddms/etc/nginx/apps-available/seeddms /etc/nginx/apps-available/seeddms
ln -s /etc/nginx/apps-available/seeddms /etc/nginx/apps-enabled/seeddms
# Restart services
systemctl restart nginx
# TODO: Custom user
# TODO: Set cgroups
# TODO: id3 ssconvers pdftotext catdoc
# TODO: Test Lucene fulltext search