#!/bin/bash set -eu echo "==========================" echo " Etherpad start " echo "==========================" # make npm behave a bit to improve our log display export npm_config_progress=false export npm_config_color=false export npm_config_spin=false echo "=> Ensure directories" mkdir -p /run/etherpad-lite/run /run/etherpad-lite/var /app/data/node_modules /run/etherpad-lite/npm /app/data/custom # the idea here is make the node_modules dir writable so that ep can install plugins there # the ep_cloudron has to be symlinked at the top level so that ep can find it echo "=> Fixing up node_modules" ln -Tsf /app/code/src /app/data/node_modules/ep_etherpad-lite # this symlink is "require"d by plugins echo "=> Ensuring cloudron plugin" npm install ep_cloudron@2.0.4 # Use this instead of the line above during ep_cloudron development # npm install git+https://git.cloudron.io/cloudron/ep_cloudron.git\#devel --force # We setup the app with some useful default plugins, the user may or may not uninstall them afterwards if [[ ! -f "/app/data/.installed" ]]; then echo "=> First run, installing default plugins" npm install --no-package-lock ep_page_view ep_headings2 ep_font_color ep_font_family ep_font_size ep_superscript ep_subscript touch "/app/data/.installed" fi echo "=> Ensuring templates" for f in "index" "pad" "timeslider"; do if [[ ! -f "/app/data/custom/$f.js" ]]; then cp "/app/code/src/static/custom_templates/js.template" "/app/data/custom/$f.js" fi if [[ ! -f "/app/data/custom/$f.css" ]]; then cp "/app/code/src/static/custom_templates/css.template" "/app/data/custom/$f.css" fi done echo "=> Generating settings.json" sed -e "s/##MYSQL_HOST/${MYSQL_HOST}/g" \ -e "s/##MYSQL_PORT/${MYSQL_PORT}/g" \ -e "s/##MYSQL_USERNAME/${MYSQL_USERNAME}/g" \ -e "s/##MYSQL_PASSWORD/${MYSQL_PASSWORD}/g" \ -e "s/##MYSQL_DATABASE/${MYSQL_DATABASE}/g" \ /app/code/settings.json.template > "/run/etherpad-lite/settings.json" echo "=> Ensure /app/data/settings.json" if [[ ! -f "/app/data/settings.json" ]]; then echo -e "{\n\n}" > "/app/data/settings.json" fi echo "=> Ensure folder permissions" chown -R cloudron:cloudron /run/etherpad-lite /app/data echo "=> Starting etherpad" export NODE_ENV=production # etherpad expects APIKEY, SESSIONKEY, node_modules in curdir cd /app/code exec /usr/local/bin/gosu cloudron:cloudron node /app/code/src/node/server.js --settings /run/etherpad-lite/settings.json --credentials /app/data/settings.json