Enabled iterative development with SCRIPTS var

This commit is contained in:
Geoff Bourne 2020-06-19 11:05:32 -05:00
parent 2b7f923865
commit f5dde77efe
22 changed files with 79 additions and 51 deletions

28
DEVELOPMENT.md Normal file
View File

@ -0,0 +1,28 @@
Individual scripts can be iteratively developed and tested using the following procedure.
First, build a baseline of the image to include the packages needed by existing or new scripts:
```shell script
docker build -t mc-dev .
```
Using the baseline image, an interactive container can be started to iteratively run the scripts to be developed. By attaching the current workspace directory, you can use the local editor of your choice to iteratively modify scripts while using the container to run them.
```shell script
docker run -it --rm -v ${PWD}:/scripts -e SCRIPTS=/scripts/ --entrypoint bash mc-dev
```
From within the container you can run individual scripts via the attached `/scripts/` path; however, be sure to set any environment variables expected by the scripts by either `export`ing them manually:
```shell script
export VANILLA_VERSION=1.12.2
/scripts/start-magma
```
...or pre-pending script execution:
```shell script
VANILLA_VERSION=1.12.2 /scripts/start-magma
```
> NOTE: You may want to temporarily add an `exit` statement near the end of your script to isolate execution to just the script you're developing.

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
if isTrue "${ENABLE_AUTOPAUSE}" && [[ "$( ps -a -o stat,comm | grep 'java' | awk '{ print $1 }')" =~ ^T.*$ ]]; then
echo "Java process suspended by Autopause function"

6
start
View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
umask 0002
chmod g+w /data
@ -45,7 +45,7 @@ if [ $(id -u) = 0 ]; then
echo 'hosts: files dns' > /etc/nsswitch.conf
fi
exec su-exec ${runAsUser}:${runAsGroup} /start-configuration $@
exec su-exec ${runAsUser}:${runAsGroup} ${SCRIPTS:-/}start-configuration $@
else
exec /start-configuration $@
exec ${SCRIPTS:-/}start-configuration $@
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
log "Autopause functionality enabled"

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
shopt -s nullglob
@ -69,53 +69,53 @@ cd /data || exit 1
export ORIGINAL_TYPE=${TYPE^^}
if isTrue "${ENABLE_AUTOPAUSE}"; then
/start-autopause
${SCRIPTS:-/}start-autopause
fi
log "Resolving type given ${TYPE}"
case "${TYPE^^}" in
*BUKKIT|SPIGOT)
exec /start-deployBukkitSpigot "$@"
exec ${SCRIPTS:-/}start-deployBukkitSpigot "$@"
;;
PAPER)
exec /start-deployPaper "$@"
exec ${SCRIPTS:-/}start-deployPaper "$@"
;;
TUINITY)
exec /start-deployTuinity "$@"
exec ${SCRIPTS:-/}start-deployTuinity "$@"
;;
FORGE)
exec /start-deployForge "$@"
exec ${SCRIPTS:-/}start-deployForge "$@"
;;
FABRIC)
exec /start-deployFabric "$@"
exec ${SCRIPTS:-/}start-deployFabric "$@"
;;
FTB|CURSEFORGE)
exec /start-deployFTB "$@"
exec ${SCRIPTS:-/}start-deployFTB "$@"
;;
VANILLA)
exec /start-deployVanilla "$@"
exec ${SCRIPTS:-/}start-deployVanilla "$@"
;;
SPONGEVANILLA)
exec /start-deploySpongeVanilla "$@"
exec ${SCRIPTS:-/}start-deploySpongeVanilla "$@"
;;
CUSTOM)
exec /start-deployCustom "$@"
exec ${SCRIPTS:-/}start-deployCustom "$@"
;;
CURSE_INSTANCE)
exec /start-validateCurseInstance "$@"
exec ${SCRIPTS:-/}start-validateCurseInstance "$@"
;;
MAGMA)
exec /start-magma "$@"
exec ${SCRIPTS:-/}start-magma "$@"
;;
*)

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
set -e
@ -102,4 +102,4 @@ export TYPE=SPIGOT
export SKIP_LOG4J_CONFIG=true
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
if isURL ${CUSTOM_SERVER}; then
filename=$(basename ${CUSTOM_SERVER})
@ -28,4 +28,4 @@ fi
export SKIP_LOG4J_CONFIG=true
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
export FTB_BASE_DIR=/data/FeedTheBeast
legacyJavaFixerUrl=http://ftb.cursecdn.com/FTB2/maven/net/minecraftforge/lex/legacyjavafixer/1.0/legacyjavafixer-1.0.jar
@ -135,4 +135,4 @@ elif [ -e "${FTB_DIR}/Install.sh" ]; then
fi
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -eu
. /start-utils
. ${SCRIPTS:-/}start-utils
export TYPE=FABRIC
@ -75,4 +75,4 @@ else
fi
# Contineut to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
export TYPE=FORGE
@ -113,4 +113,4 @@ else
fi
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
: ${PAPERBUILD:=latest}
export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar
@ -20,4 +20,4 @@ export TYPE=SPIGOT
export SKIP_LOG4J_CONFIG=true
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
export TYPE=spongevanilla
@ -36,4 +36,4 @@ if [ ! -e $SERVER ] || [ -n "$FORCE_REDOWNLOAD" ]; then
fi
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
if [ "${VERSION}" != "LATEST" ]; then
log "ERROR: Tunity server type only supports VERSION=LATEST"
@ -24,4 +24,4 @@ fi
export TYPE=SPIGOT
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
isDebugging && set -x
set -o pipefail
@ -43,4 +43,4 @@ fi
isDebugging && ls -l
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
set -e
isDebugging && set -x
@ -51,4 +51,4 @@ if [[ "$WORLD" ]] && [ ! -d "$worldDest" ]; then
fi
fi
exec /start-finalSetup02Modpack $@
exec ${SCRIPTS:-/}start-finalSetup02Modpack $@

View File

@ -2,7 +2,7 @@
set -e
. /start-utils
. ${SCRIPTS:-/}start-utils
# CURSE_URL_BASE used in manifest downloads below
CURSE_URL_BASE=${CURSE_URL_BASE:-https://minecraft.curseforge.com/projects}
@ -154,4 +154,4 @@ if [[ "${GENERIC_PACK}" ]]; then
fi
fi
exec /start-finalSetup03Modconfig $@
exec ${SCRIPTS:-/}start-finalSetup03Modconfig $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
# If supplied with a URL for a config (simple zip of configurations), download it and unpack
if [[ "$MODCONFIG" ]]; then
@ -24,4 +24,4 @@ case "X$MODCONFIG" in
esac
fi
exec /start-finalSetup04ServerProperties $@
exec ${SCRIPTS:-/}start-finalSetup04ServerProperties $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
# FUNCTIONS
function setServerProp {
@ -194,4 +194,4 @@ if isDebugging; then
cat /data/server.properties
fi
exec /start-finalSetup05EnvVariables $@
exec ${SCRIPTS:-/}start-finalSetup05EnvVariables $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
if [ "${REPLACE_ENV_VARIABLES^^}" = "TRUE" ]; then
log "Replacing env variables in configs that match the prefix $ENV_VARIABLE_PREFIX..."
@ -25,4 +25,4 @@ if [ "${REPLACE_ENV_VARIABLES^^}" = "TRUE" ]; then
done < <(env)
fi
exec /start-minecraftFinalSetup $@
exec ${SCRIPTS:-/}start-minecraftFinalSetup $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
export SERVER="/data/magma-server-${VANILLA_VERSION}.jar"
@ -15,4 +15,4 @@ fi
export SKIP_LOG4J_CONFIG=true
# Continue to Final Setup
exec /start-finalSetup01World $@
exec ${SCRIPTS:-/}start-finalSetup01World $@

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
if [ -n "$OPS" ]; then
log "Setting/adding ops"

View File

@ -1,6 +1,6 @@
#!/bin/bash
. /start-utils
. ${SCRIPTS:-/}start-utils
if ! [[ -v CURSE_INSTANCE_JSON ]]; then
log "ERROR: CURSE_INSTANCE_JSON needs to be set"
@ -15,4 +15,4 @@ fi
log "Resolved CURSE_INSTANCE_JSON as ${CURSE_INSTANCE_JSON}"
# Continue to Final Setup
exec /start-finalSetup01World "$@"
exec ${SCRIPTS:-/}start-finalSetup01World "$@"