75 lines
3.8 KiB
Bash
Executable File
75 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SOURCE_DIR=$(realpath $(dirname "${0}"))
|
|
|
|
# Add pandora repository
|
|
echo "deb http://ppa.launchpad.net/j/pandora/ubuntu zesty main" > /etc/apt/sources.list.d/pandora.list
|
|
apt-key add ${SOURCE_DIR}/pandora/pandora.gpg
|
|
|
|
# Install packages
|
|
apt-get -y update
|
|
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
|
|
|
|
# Clone git repositories
|
|
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
|
|
|
|
# Copy Czech translataion
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/static/json/locale.0xdb.cs.json /srv/pandora/static/json/locale.0xdb.cs.json
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/static/json/locale.pandora.cs.json /srv/pandora/static/json/locale.pandora.cs.json
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/static/oxjs/source/Ox/js/Constants.js /srv/pandora/static/oxjs/source/Ox/js/Constants.js
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/static/oxjs/source/Ox/json/locale.cs.json /srv/pandora/static/oxjs/source/Ox/json/locale.cs.json
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/static/oxjs/source/UI/json/locale.cs.json /srv/pandora/static/oxjs/source/UI/json/locale.cs.json
|
|
|
|
# Create python virtualenv
|
|
virtualenv --system-site-packages -p /usr/bin/python3 /srv/pandora
|
|
cd /srv/pandora/src/oxtimelines && /srv/pandora/bin/python setup.py develop
|
|
/srv/pandora/bin/pip install -r /srv/pandora/requirements.txt
|
|
|
|
# Create PostgreSQL user and database
|
|
export PANDORA_PWD=$(head -c 18 /dev/urandom | base64)
|
|
envsubst <${SOURCE_DIR}/pandora/tmp/pandora-createdb.sql >/tmp/pandora-createdb.sql
|
|
sudo -u postgres psql -f /tmp/pandora-createdb.sql
|
|
rm -f /tmp/pandora-createdb.sql
|
|
|
|
# Configure RabbitMQ
|
|
export PANDORA_RABBIT_PWD=$(head -c 18 /dev/urandom | base64)
|
|
export PANDORA_BROKER_URL="amqp://pandora:${PANDORA_RABBIT_PWD}@localhost:5672//pandora"
|
|
rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD}
|
|
rabbitmqctl add_vhost /pandora
|
|
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
|
|
|
# Configure Pandora
|
|
mkdir /srv/pandora/data
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/pandora/config.jsonc /srv/pandora/pandora/config.jsonc
|
|
cp /srv/pandora/pandora/gunicorn_config.py.in /srv/pandora/pandora/gunicorn_config.py
|
|
envsubst <${SOURCE_DIR}/pandora/srv/pandora/pandora/local_settings.py >/srv/pandora/pandora/local_settings.py
|
|
|
|
# Create OS user
|
|
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
|
|
|
|
# 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)
|
|
cp ${SOURCE_DIR}/pandora/srv/pandora/pandora/user/management/commands/createadmin.py /srv/pandora/pandora/user/management/commands/createadmin.py
|
|
sudo -u pandora /srv/pandora/pandora/manage.py createadmin --username "${PANDORA_ADMIN_USER}" --email "${PANDORA_ADMIN_EMAIL}" --password "${PANDORA_ADMIN_PWD}"
|
|
rm -f /srv/pandora/pandora/user/management/commands/createadmin.py
|
|
|
|
# Create nginx site definition
|
|
cp ${SOURCE_DIR}/pandora/etc/nginx/sites-available/pandora /etc/nginx/sites-available/pandora
|
|
ln -s /etc/nginx/sites-available/pandora /etc/nginx/sites-enabled/pandora
|
|
|
|
# Install and start services
|
|
/srv/pandora/ctl install
|
|
/srv/pandora/ctl start
|
|
systemctl restart nginx
|
|
|
|
# Add portal application definition
|
|
${SOURCE_DIR}/basic/portal-app-manager.py pandora "https://{host}:8001/" "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"
|