2022-01-25 21:30:38 +00:00
#!/usr/bin/env bash
2022-01-29 18:17:30 +00:00
set -e
2022-01-25 22:44:39 +00:00
# Set some vars
2022-01-29 19:24:20 +00:00
PRE_POPULATED_VOLUMES = ( "config" "mods" "art" ) # These are folders which contain runtime needed files, and need to be represented in the host
BBS_ROOT_DIR = /enigma-bbs # Install location
BBS_STAGING_PATH = /enigma-bbs-pre # Staging location for pre populated volumes (PRE_POPULATED_VOLUMES)
2022-01-29 19:21:38 +00:00
CONFIG_NAME = config.hjson # This is the default name, this script is intended for easy get-go - make changes as needed
2022-01-25 22:44:39 +00:00
# Setup happens when there is no existing config file
2022-01-29 19:24:20 +00:00
if [ [ ! -f $BBS_ROOT_DIR /config/$CONFIG_NAME ] ] ; then
2022-01-29 19:28:14 +00:00
for VOLUME in " ${ PRE_POPULATED_VOLUMES [@] } "
2022-01-25 21:30:38 +00:00
do
2022-01-29 19:28:14 +00:00
if [ -n " $( find " $BBS_ROOT_DIR / $VOLUME " -maxdepth 0 -type d -empty 2>/dev/null) " ] ; then
cp -rp $BBS_STAGING_PATH /$VOLUME /* $BBS_ROOT_DIR /$VOLUME /
2022-01-25 21:30:38 +00:00
else
2022-01-29 19:28:14 +00:00
printf " WARN: skipped $BBS_ROOT_DIR / $VOLUME : Volume not empty or not a new setup; Files required to run ENiGMA 1/2 may be missing.\n Possible bad state\n "
2022-01-29 19:16:02 +00:00
printf "INFO: You have mounted folders with existing data - but no existing config json.\n\nPossible solutions:\n1. Make sure all volumes are set correctly specifically config volume... \n2. Check your configuration name if non-default\n\n\n"
2022-01-25 21:30:38 +00:00
fi
done
./oputil.js config new
fi
2022-01-29 19:24:20 +00:00
if [ [ ! -f $BBS_ROOT_DIR /config/$CONFIG_NAME ] ] ; then # Make sure once more, otherwise pm2-runtime will loop if missing the config
2022-01-29 18:17:30 +00:00
printf "ERROR: Missing configuration - ENiGMA 1/2 will not work. please run config\n"
2022-01-25 22:44:39 +00:00
exit 1
else
2022-01-29 21:04:29 +00:00
exec pm2-runtime main.js
2022-01-25 22:44:39 +00:00
fi