From 2bc55624f025ae3568cbd7c30bb85c18a42b0d8e Mon Sep 17 00:00:00 2001 From: Jordy Hulck Date: Mon, 27 Dec 2021 17:04:24 +0100 Subject: [PATCH 1/2] Download modpack when start script is disabled --- scripts/start-deployCF | 59 +++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/scripts/start-deployCF b/scripts/start-deployCF index c00c1dcfab0..7e872dcddbc 100755 --- a/scripts/start-deployCF +++ b/scripts/start-deployCF @@ -35,10 +35,38 @@ FTB_SERVER_MOD=${FTB_SERVER_MOD:-$CF_SERVER_MOD} log "Looking for Feed-The-Beast / CurseForge server modpack." requireVar FTB_SERVER_MOD +downloadModpack() { + srv_modpack=${FTB_SERVER_MOD} + if isURL "${srv_modpack}"; then + log "Downloading modpack from ${srv_modpack}..." + if ! srv_modpack=$(get -o /data --output-filename --skip-existing "${srv_modpack}"); then + log "ERROR: failed to download modpack" + exit 1 + fi + fi + if [[ "${srv_modpack:0:5}" == "data/" ]]; then + # Prepend with "/" + srv_modpack="/${srv_modpack}" + fi + if [[ ! "${srv_modpack:0:1}" == "/" ]]; then + # If not an absolute path, assume file is in "/data" + srv_modpack=/data/${srv_modpack} + fi + if [[ ! -f "${srv_modpack}" ]]; then + log "FTB server modpack ${srv_modpack} not found." + exit 2 + fi + if [[ ! "${srv_modpack: -4}" == ".zip" ]]; then + log "FTB server modpack ${srv_modpack} is not a zip archive." + log "Please set FTB_SERVER_MOD to a file with a .zip extension." + exit 2 + fi + FTB_SERVER_MOD=${srv_modpack} +} + if ! isTrue "${USE_MODPACK_START_SCRIPT:-true}"; then if ! [ -f "${FTB_SERVER_MOD}" ]; then - log "ERROR unable to find requested modpack file ${FTB_SERVER_MOD}" - exit 2 + downloadModpack fi needsInstall=true @@ -132,32 +160,9 @@ fi # also check for the start script rather than just the folder # this allows saving just the world separate from the rest of the data directory if [[ $startScriptCount = 0 ]]; then + downloadModpack srv_modpack=${FTB_SERVER_MOD} - if isURL "${srv_modpack}"; then - log "Downloading modpack from ${srv_modpack}..." - if ! srv_modpack=$(get -o /data --output-filename --skip-existing "${srv_modpack}"); then - log "ERROR: failed to download modpack" - exit 1 - fi - fi - if [[ "${srv_modpack:0:5}" == "data/" ]]; then - # Prepend with "/" - srv_modpack="/${srv_modpack}" - fi - if [[ ! "${srv_modpack:0:1}" == "/" ]]; then - # If not an absolute path, assume file is in "/data" - srv_modpack=/data/${srv_modpack} - fi - if [[ ! -f "${srv_modpack}" ]]; then - log "FTB server modpack ${srv_modpack} not found." - exit 2 - fi - if [[ ! "${srv_modpack: -4}" == ".zip" ]]; then - log "FTB server modpack ${srv_modpack} is not a zip archive." - log "Please set FTB_SERVER_MOD to a file with a .zip extension." - exit 2 - fi - + log "Unpacking FTB server modpack ${srv_modpack} ..." mkdir -p "${FTB_BASE_DIR}" unzip -o "${srv_modpack}" -d "${FTB_BASE_DIR}" | awk '{printf "."} END {print ""}' From d0eeca026a0727143430790114bb98b20e81cf32 Mon Sep 17 00:00:00 2001 From: Jordy Hulck Date: Sat, 1 Jan 2022 20:20:19 +0100 Subject: [PATCH 2/2] Remove unnecessary if block --- scripts/start-deployCF | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/start-deployCF b/scripts/start-deployCF index 7e872dcddbc..f7f9a477f19 100755 --- a/scripts/start-deployCF +++ b/scripts/start-deployCF @@ -65,9 +65,7 @@ downloadModpack() { } if ! isTrue "${USE_MODPACK_START_SCRIPT:-true}"; then - if ! [ -f "${FTB_SERVER_MOD}" ]; then - downloadModpack - fi + downloadModpack needsInstall=true installMarker=/data/.curseforge-installed