From f5dde77efe253e7ac668acb721f6257db32f818d Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 19 Jun 2020 11:05:32 -0500 Subject: [PATCH] Enabled iterative development with SCRIPTS var --- DEVELOPMENT.md | 28 ++++++++++++++++++++++++++++ health.sh | 2 +- start | 6 +++--- start-autopause | 2 +- start-configuration | 26 +++++++++++++------------- start-deployBukkitSpigot | 4 ++-- start-deployCustom | 4 ++-- start-deployFTB | 4 ++-- start-deployFabric | 4 ++-- start-deployForge | 4 ++-- start-deployPaper | 4 ++-- start-deploySpongeVanilla | 4 ++-- start-deployTuinity | 4 ++-- start-deployVanilla | 4 ++-- start-finalSetup01World | 4 ++-- start-finalSetup02Modpack | 4 ++-- start-finalSetup03Modconfig | 4 ++-- start-finalSetup04ServerProperties | 4 ++-- start-finalSetup05EnvVariables | 4 ++-- start-magma | 4 ++-- start-minecraftFinalSetup | 2 +- start-validateCurseInstance | 4 ++-- 22 files changed, 79 insertions(+), 51 deletions(-) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 00000000..d879bc7b --- /dev/null +++ b/DEVELOPMENT.md @@ -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. diff --git a/health.sh b/health.sh index eab0f5c0..0ce34be1 100644 --- a/health.sh +++ b/health.sh @@ -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" diff --git a/start b/start index c50aef4f..f6d467e7 100644 --- a/start +++ b/start @@ -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 diff --git a/start-autopause b/start-autopause index d73f8302..32c5e64a 100755 --- a/start-autopause +++ b/start-autopause @@ -1,6 +1,6 @@ #!/bin/bash -. /start-utils +. ${SCRIPTS:-/}start-utils log "Autopause functionality enabled" diff --git a/start-configuration b/start-configuration index 55a157ea..737c960a 100644 --- a/start-configuration +++ b/start-configuration @@ -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 "$@" ;; *) diff --git a/start-deployBukkitSpigot b/start-deployBukkitSpigot index fec3f655..d995089a 100644 --- a/start-deployBukkitSpigot +++ b/start-deployBukkitSpigot @@ -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 $@ diff --git a/start-deployCustom b/start-deployCustom index 5b7e6f8d..31105e4e 100644 --- a/start-deployCustom +++ b/start-deployCustom @@ -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 $@ diff --git a/start-deployFTB b/start-deployFTB index 2a3c12b5..5006f24b 100644 --- a/start-deployFTB +++ b/start-deployFTB @@ -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 $@ diff --git a/start-deployFabric b/start-deployFabric index d8305568..b0bc1329 100644 --- a/start-deployFabric +++ b/start-deployFabric @@ -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 $@ diff --git a/start-deployForge b/start-deployForge index 739808b0..8feb33ea 100644 --- a/start-deployForge +++ b/start-deployForge @@ -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 $@ diff --git a/start-deployPaper b/start-deployPaper index 07d77117..018efa63 100644 --- a/start-deployPaper +++ b/start-deployPaper @@ -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 $@ diff --git a/start-deploySpongeVanilla b/start-deploySpongeVanilla index f6ab1934..28c5ab73 100644 --- a/start-deploySpongeVanilla +++ b/start-deploySpongeVanilla @@ -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 $@ diff --git a/start-deployTuinity b/start-deployTuinity index b998bdd9..8e6adc62 100644 --- a/start-deployTuinity +++ b/start-deployTuinity @@ -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 $@ diff --git a/start-deployVanilla b/start-deployVanilla index 0c161639..52dc92e7 100644 --- a/start-deployVanilla +++ b/start-deployVanilla @@ -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 $@ diff --git a/start-finalSetup01World b/start-finalSetup01World index 1a0bd753..31a6e156 100644 --- a/start-finalSetup01World +++ b/start-finalSetup01World @@ -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 $@ diff --git a/start-finalSetup02Modpack b/start-finalSetup02Modpack index bdd0b40b..15347cf9 100644 --- a/start-finalSetup02Modpack +++ b/start-finalSetup02Modpack @@ -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 $@ diff --git a/start-finalSetup03Modconfig b/start-finalSetup03Modconfig index f4219a73..5758a25c 100644 --- a/start-finalSetup03Modconfig +++ b/start-finalSetup03Modconfig @@ -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 $@ diff --git a/start-finalSetup04ServerProperties b/start-finalSetup04ServerProperties index d95ddaa1..e77ea8a1 100644 --- a/start-finalSetup04ServerProperties +++ b/start-finalSetup04ServerProperties @@ -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 $@ diff --git a/start-finalSetup05EnvVariables b/start-finalSetup05EnvVariables index 90a85d52..3df6b5a2 100644 --- a/start-finalSetup05EnvVariables +++ b/start-finalSetup05EnvVariables @@ -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 $@ diff --git a/start-magma b/start-magma index 70b201f4..a8c7c6a3 100755 --- a/start-magma +++ b/start-magma @@ -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 $@ diff --git a/start-minecraftFinalSetup b/start-minecraftFinalSetup index 6b1e858c..5b706ad0 100644 --- a/start-minecraftFinalSetup +++ b/start-minecraftFinalSetup @@ -1,6 +1,6 @@ #!/bin/bash -. /start-utils +. ${SCRIPTS:-/}start-utils if [ -n "$OPS" ]; then log "Setting/adding ops" diff --git a/start-validateCurseInstance b/start-validateCurseInstance index 09af3ab5..60bb2edd 100755 --- a/start-validateCurseInstance +++ b/start-validateCurseInstance @@ -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 "$@"