#!/bin/bash fail() { echo "$*" >&2 exit -1 } if [[ "${TARGET_PORT}" != "" ]]; then sed -i -e "s,8123,${TARGET_PORT},g" /etc/nginx/sites-enabled/default fi if [[ "${BASE_PATH}" != "" ]]; then sed -i -E "s,([ \^])/ident,\1${BASE_PATH}/ident,g" \ /etc/nginx/snippets/active.location sed -i -E "s,host./api,host}${BASE_PATH}/api,g" \ /etc/nginx/snippets/active.location fi /usr/sbin/nginx mkdir -p /var/lib/shellinabox chmod a+rwX /var/lib/shellinabox /usr/bin/shellinaboxd --debug --no-beep --disable-peer-check \ -t \ -b \ -c /var/lib/shellinabox \ -s "/:root:root:/website:/bin/bash" if [[ -z "${DEVELOPMENT}" ]]; then echo "Running in PRODUCTION mode." cd /website/server { while true; do npm start ; sleep 3 ; done ; } else echo "Running in DEVELOPMENT mode." if [[ ! -d /website/frontend ]]; then fail "/website/frontend not found. Is the volume mounted? Did you run via './launch.sh'?" fi if [[ ! -d /website/frontend/bower_components ]]; then echo "...installing bower_components for frontend" cd /website/frontend npx -y bower --allow-root -y install || fail "Unable to install frontend" fi if [[ ! -d /website/client/node_modules ]]; then echo "...installing node_modules for client" cd /website/client npm install || fail "Unable to install client" fi if [[ ! -d /website/node_modules ]]; then echo "...installing node_modules for base website" cd /website npm install || fail "Unable to install website" fi if [[ ! -d /website/server/node_modules ]]; then echo "...installing node_modules for server" cd /website/server npm install || fail "Unable to install server" fi cd /website/server { while true; do npm start ; sleep 3 ; done ; } & cd /website/client { while true; do npm start ; sleep 3 ; done ; } fi