51 lines
1.8 KiB
Bash
51 lines
1.8 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/openmapkit
|
||
|
|
||
|
# Add NodeJS repository
|
||
|
wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O - | apt-key add -
|
||
|
echo 'deb https://deb.nodesource.com/node_8.x stretch main' > /etc/apt/sources.list.d/nodejs.list
|
||
|
apt-get -y update
|
||
|
|
||
|
# Install OpenMapKit dependencies
|
||
|
apt-get install --no-install-recommends -y build-essential nodejs python-dev python-virtualenv virtualenv
|
||
|
|
||
|
# Clone repositories
|
||
|
git clone --depth 1 https://github.com/AmericanRedCross/OpenMapKitServer /srv/omk
|
||
|
git -C /srv/omk submodule update --init
|
||
|
|
||
|
# Install OpenMapKit python virtual environment
|
||
|
virtualenv --no-site-packages --python=/usr/bin/python2.7 /srv/omk
|
||
|
/srv/omk/bin/pip install -r /srv/omk/requirements.txt
|
||
|
|
||
|
# Create OpenMapKit OS user
|
||
|
adduser --system --group --home /srv/omk --shell /bin/bash omk
|
||
|
chown -R omk:omk /srv/omk
|
||
|
|
||
|
# Install NodeJS dependencies
|
||
|
sudo -u omk -i npm install yarn
|
||
|
sudo -u omk -i npm install libxmljs
|
||
|
sudo -u omk -i /srv/omk/node_modules/yarn/bin/yarn
|
||
|
|
||
|
# Configure OpenMapKit
|
||
|
export OMK_ADMIN_USER="admin"
|
||
|
export OMK_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
|
||
|
envsubst <${SOURCE_DIR}/srv/omk/settings.js >/srv/omk/settings.js
|
||
|
|
||
|
# Configure OpenMapKit service
|
||
|
cp ${SOURCE_DIR}/lib/systemd/system/openmapkit.service /lib/systemd/system/openmapkit.service
|
||
|
systemctl daemon-reload
|
||
|
systemctl enable openmapkit
|
||
|
systemctl start openmapkit
|
||
|
|
||
|
# Create nginx site definition
|
||
|
cp ${SOURCE_DIR}/etc/nginx/sites-available/openmapkit /etc/nginx/sites-available/openmapkit
|
||
|
ln -s /etc/nginx/sites-available/openmapkit /etc/nginx/sites-enabled/openmapkit
|
||
|
|
||
|
# Restart services
|
||
|
systemctl restart nginx
|
||
|
|
||
|
# Add portal application definition
|
||
|
portal-app-manager openmapkit "https://{host}:8007/" admin "${OMK_ADMIN_PWD}"
|
||
|
portal-app-manager openmapkit-clients -p clienturl "http://{host}:8096"
|