2017-09-11 17:06:40 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-12-04 17:48:37 +01:00
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/pandora
|
2017-09-11 17:06:40 +02:00
|
|
|
|
2017-11-28 10:56:59 +01:00
|
|
|
# Add Pandora repository
|
2017-09-11 17:06:40 +02:00
|
|
|
echo "deb http://ppa.launchpad.net/j/pandora/ubuntu zesty main" > /etc/apt/sources.list.d/pandora.list
|
2017-12-04 17:48:37 +01:00
|
|
|
apt-key add ${SOURCE_DIR}/pandora.gpg
|
2017-11-28 10:56:59 +01:00
|
|
|
apt-get -y update
|
2017-09-11 17:06:40 +02:00
|
|
|
|
|
|
|
# Install packages
|
2017-10-24 21:50:28 +02:00
|
|
|
apt-get -y --no-install-recommends install ffmpeg ghostscript gpac imagemagick mkvtoolnix oxframe poppler-utils python-ox python3-html5lib python3-lxml python3-numpy python3-ox python3-pil python3-pip python3-psycopg2 python3-pyinotify python3-setuptools python3-simplejson python3-virtualenv rabbitmq-server virtualenv youtube-dl
|
2017-09-11 17:06:40 +02:00
|
|
|
|
2017-11-28 10:56:59 +01:00
|
|
|
# Clone Pandora git repositories
|
2017-09-11 17:06:40 +02:00
|
|
|
git clone --depth 1 https://git.0x2620.org/pandora.git /srv/pandora
|
|
|
|
git clone --depth 1 https://git.0x2620.org/oxjs.git /srv/pandora/static/oxjs
|
|
|
|
git clone --depth 1 https://git.0x2620.org/oxtimelines.git /srv/pandora/src/oxtimelines
|
|
|
|
|
2017-10-26 09:50:58 +02:00
|
|
|
# Copy Czech translataion
|
2017-12-04 17:48:37 +01:00
|
|
|
cp ${SOURCE_DIR}/srv/pandora/static/json/locale.0xdb.cs.json /srv/pandora/static/json/locale.0xdb.cs.json
|
|
|
|
cp ${SOURCE_DIR}/srv/pandora/static/json/locale.pandora.cs.json /srv/pandora/static/json/locale.pandora.cs.json
|
|
|
|
cp ${SOURCE_DIR}/srv/pandora/static/oxjs/source/Ox/js/Constants.js /srv/pandora/static/oxjs/source/Ox/js/Constants.js
|
|
|
|
cp ${SOURCE_DIR}/srv/pandora/static/oxjs/source/Ox/json/locale.cs.json /srv/pandora/static/oxjs/source/Ox/json/locale.cs.json
|
|
|
|
cp ${SOURCE_DIR}/srv/pandora/static/oxjs/source/UI/json/locale.cs.json /srv/pandora/static/oxjs/source/UI/json/locale.cs.json
|
2017-09-15 12:15:50 +02:00
|
|
|
|
2017-11-28 10:56:59 +01:00
|
|
|
# Create Python virtualenv
|
2017-09-11 17:06:40 +02:00
|
|
|
virtualenv --system-site-packages -p /usr/bin/python3 /srv/pandora
|
2017-11-29 22:21:06 +01:00
|
|
|
/srv/pandora/bin/pip install -e /srv/pandora/src/oxtimelines
|
2017-09-11 17:06:40 +02:00
|
|
|
/srv/pandora/bin/pip install -r /srv/pandora/requirements.txt
|
|
|
|
|
|
|
|
# Create PostgreSQL user and database
|
2017-09-16 14:38:50 +02:00
|
|
|
export PANDORA_PWD=$(head -c 18 /dev/urandom | base64)
|
2017-12-04 17:48:37 +01:00
|
|
|
envsubst <${SOURCE_DIR}/tmp/pandora-createdb.sql >/tmp/pandora-createdb.sql
|
2017-09-11 17:06:40 +02:00
|
|
|
sudo -u postgres psql -f /tmp/pandora-createdb.sql
|
|
|
|
rm -f /tmp/pandora-createdb.sql
|
|
|
|
|
|
|
|
# Configure RabbitMQ
|
2017-10-24 21:51:27 +02:00
|
|
|
export PANDORA_RABBIT_PWD=$(head -c 18 /dev/urandom | base64 | tr -d "/")
|
2017-09-17 22:09:56 +02:00
|
|
|
export PANDORA_BROKER_URL="amqp://pandora:${PANDORA_RABBIT_PWD}@localhost:5672//pandora"
|
2017-09-11 17:06:40 +02:00
|
|
|
rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD}
|
|
|
|
rabbitmqctl add_vhost /pandora
|
|
|
|
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
|
|
|
|
|
|
|
# Configure Pandora
|
|
|
|
mkdir /srv/pandora/data
|
2017-12-04 17:48:37 +01:00
|
|
|
cp ${SOURCE_DIR}/srv/pandora/pandora/config.jsonc /srv/pandora/pandora/config.jsonc
|
2017-09-11 17:06:40 +02:00
|
|
|
cp /srv/pandora/pandora/gunicorn_config.py.in /srv/pandora/pandora/gunicorn_config.py
|
2017-12-04 17:48:37 +01:00
|
|
|
envsubst <${SOURCE_DIR}/srv/pandora/pandora/local_settings.py >/srv/pandora/pandora/local_settings.py
|
2017-09-11 17:06:40 +02:00
|
|
|
|
2017-11-29 21:27:11 +01:00
|
|
|
# Set "production values" (increases performance) only if the DEBUG environment variable is not set
|
|
|
|
if [ ${DEBUG:-0} -eq 0 ]; then
|
|
|
|
sed -i 's/DEBUG = True/DEBUG = False/' /srv/pandora/pandora/local_settings.py
|
|
|
|
fi
|
|
|
|
|
2017-11-28 10:56:59 +01:00
|
|
|
# Create Pandora OS user
|
2017-09-11 17:06:40 +02:00
|
|
|
adduser --system --group --home /srv/pandora --shell /bin/false pandora
|
|
|
|
chown -R pandora:pandora /srv/pandora
|
|
|
|
|
|
|
|
# Populate database
|
|
|
|
sudo -u pandora /srv/pandora/pandora/manage.py init_db
|
|
|
|
|
2017-09-17 22:09:56 +02:00
|
|
|
# Create admin account
|
|
|
|
export PANDORA_ADMIN_USER=admin
|
|
|
|
export PANDORA_ADMIN_EMAIL=admin@example.com
|
|
|
|
export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
2017-11-29 22:21:06 +01:00
|
|
|
export PANDORA_ADMIN_HASH=$(cd /srv/pandora && DJANGO_SETTINGS_MODULE=pandora.settings /srv/pandora/bin/python -c "from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))")
|
2017-12-04 17:48:37 +01:00
|
|
|
envsubst <${SOURCE_DIR}/tmp/pandora-adminpwd.sql >/tmp/pandora-adminpwd.sql
|
2017-11-29 22:21:06 +01:00
|
|
|
sudo -u postgres psql -f /tmp/pandora-adminpwd.sql pandora
|
|
|
|
rm -f /tmp/pandora-adminpwd.sql
|
2017-09-17 22:09:56 +02:00
|
|
|
|
2017-09-11 17:06:40 +02:00
|
|
|
# Create nginx site definition
|
2017-12-04 17:48:37 +01:00
|
|
|
cp ${SOURCE_DIR}/etc/nginx/sites-available/pandora /etc/nginx/sites-available/pandora
|
2017-09-11 17:06:40 +02:00
|
|
|
ln -s /etc/nginx/sites-available/pandora /etc/nginx/sites-enabled/pandora
|
|
|
|
|
2017-09-15 11:07:37 +02:00
|
|
|
# Install and start services
|
|
|
|
/srv/pandora/ctl install
|
|
|
|
/srv/pandora/ctl start
|
2017-09-11 17:06:40 +02:00
|
|
|
systemctl restart nginx
|
2017-09-14 21:56:09 +02:00
|
|
|
|
|
|
|
# Add portal application definition
|
2017-12-04 17:38:48 +01:00
|
|
|
portal-app-manager pandora "https://{host}:8001/" "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"
|