2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ -n "$OPS" -a ! -e ops.txt.converted ]; then
|
|
|
|
echo "Setting ops"
|
|
|
|
echo $OPS | awk -v RS=, '{print}' >> ops.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$WHITELIST" -a ! -e white-list.txt.converted ]; then
|
|
|
|
echo "Setting whitelist"
|
|
|
|
echo $WHITELIST | awk -v RS=, '{print}' >> white-list.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$ICON" -a ! -e server-icon.png ]; then
|
|
|
|
echo "Using server icon from $ICON..."
|
|
|
|
# Not sure what it is yet...call it "img"
|
2018-06-26 00:13:47 +00:00
|
|
|
curl -sSL -o /tmp/icon.img $ICON
|
2017-11-01 05:42:44 +00:00
|
|
|
specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
|
|
|
|
if [ "$specs" = "PNG 64x64" ]; then
|
|
|
|
mv /tmp/icon.img /data/server-icon.png
|
|
|
|
else
|
|
|
|
echo "Converting image to 64x64 PNG..."
|
|
|
|
convert /tmp/icon.img -resize 64x64! /data/server-icon.png
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
|
2018-10-14 17:47:39 +00:00
|
|
|
echo "Checking for JSON files."
|
|
|
|
JSON_FILES=$(find . -name '*.json')
|
|
|
|
for j in $JSON_FILES; do
|
|
|
|
if [[ $(python -c "print open('$j').read().strip()==''") = True ]]; then
|
|
|
|
echo "Fixing JSON $j"
|
|
|
|
echo '[]' > $j
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
|
|
|
|
# If any modules have been provided, copy them over
|
|
|
|
mkdir -p /data/mods
|
2018-12-15 07:29:43 +00:00
|
|
|
if [ -d /mods ]; then
|
|
|
|
echo "Copying any mods over..."
|
2018-12-15 07:56:05 +00:00
|
|
|
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --include '*/' --include '*.jar' -include '*.zip' --exclude '*' --update /mods /data
|
2018-12-15 07:29:43 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
[ -d /data/config ] || mkdir /data/config
|
|
|
|
for c in /config/*
|
|
|
|
do
|
|
|
|
if [ -f "$c" ]; then
|
|
|
|
echo Copying configuration `basename "$c"`
|
|
|
|
cp -rf "$c" /data/config
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-12-15 07:29:43 +00:00
|
|
|
mkdir -p /data/plugins
|
2017-11-01 05:42:44 +00:00
|
|
|
if [ "$TYPE" = "SPIGOT" ]; then
|
|
|
|
if [ -d /plugins ]; then
|
2018-12-15 07:29:43 +00:00
|
|
|
echo "Copying any Bukkit plugins over..."
|
2018-12-14 07:13:19 +00:00
|
|
|
# Copy plugins over using rsync to allow deeply nested updates of plugins
|
|
|
|
# only updates files if the source file is newer and print updated files
|
2018-12-15 07:56:05 +00:00
|
|
|
rsync -a --out-format="update:%f:Last Modified %M" --prune-empty-dirs --include '*/' --include '*.jar' --exclude '*' --update /plugins /data
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
EXTRA_ARGS=""
|
|
|
|
# Optional disable console
|
|
|
|
if [[ ${CONSOLE} = false || ${CONSOLE} = FALSE ]]; then
|
|
|
|
EXTRA_ARGS+="--noconsole"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Optional disable GUI for headless servers
|
|
|
|
if [[ ${GUI} = false || ${GUI} = FALSE ]]; then
|
|
|
|
EXTRA_ARGS="${EXTRA_ARGS} nogui"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# put these prior JVM_OPTS at the end to give any memory settings there higher precedence
|
2018-07-13 21:35:56 +00:00
|
|
|
echo "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}"
|
2017-11-01 05:42:44 +00:00
|
|
|
|
2019-01-14 04:22:27 +00:00
|
|
|
expandedDOpts=
|
|
|
|
if [ -n "$JVM_DD_OPTS" ]; then
|
|
|
|
for dopt in $JVM_DD_OPTS
|
|
|
|
do
|
|
|
|
expandedDOpts="${expandedDOpts} -D${dopt/:/=}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2019-01-25 00:39:26 +00:00
|
|
|
mcServerRunnerArgs="--stop-duration 60s"
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
if [[ ${TYPE} == "FEED-THE-BEAST" ]]; then
|
2018-03-05 01:01:31 +00:00
|
|
|
if [ ! -e ${FTB_DIR}/ops.json -a -e /data/ops.txt ]; then
|
2018-02-06 20:21:23 +00:00
|
|
|
cp -f /data/ops.txt ${FTB_DIR}/
|
|
|
|
fi
|
|
|
|
|
2018-03-05 01:01:31 +00:00
|
|
|
if [ ! -e ${FTB_DIR}/whitelist.json -a -e /data/white-list.txt ]; then
|
|
|
|
cp -f /data/white-list.txt ${FTB_DIR}/
|
2018-02-06 20:21:23 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-12 22:25:16 +00:00
|
|
|
cp -f /data/eula.txt ${FTB_DIR}/
|
2018-02-06 20:21:23 +00:00
|
|
|
|
2018-07-13 21:35:56 +00:00
|
|
|
cat > ${FTB_DIR}/settings-local.sh <<EOF
|
|
|
|
export MIN_RAM="${INIT_MEMORY}"
|
|
|
|
export MAX_RAM="${MAX_MEMORY}"
|
2019-01-14 04:22:27 +00:00
|
|
|
export JAVA_PARAMETERS="-Xms${INIT_MEMORY} $expandedDOpts"
|
2018-07-13 21:35:56 +00:00
|
|
|
EOF
|
|
|
|
|
2019-01-26 22:35:00 +00:00
|
|
|
# patch CurseForge cfg file, if present
|
|
|
|
if [ -f ${FTB_DIR}/settings.cfg ]; then
|
|
|
|
sed -i "/MAX_RAM=.*/ c MAX_RAM=${MAX_MEMORY};" ${FTB_DIR}/settings.cfg
|
|
|
|
fi
|
|
|
|
|
2017-11-01 05:42:44 +00:00
|
|
|
cd ${FTB_DIR}
|
2018-08-12 22:25:16 +00:00
|
|
|
echo "Running FTB ${FTB_SERVER_START} in ${FTB_DIR} ..."
|
2019-01-25 00:39:26 +00:00
|
|
|
exec mc-server-runner ${mcServerRunnerArgs} ${FTB_SERVER_START}
|
2017-11-01 05:42:44 +00:00
|
|
|
else
|
2018-07-13 21:35:56 +00:00
|
|
|
# If we have a bootstrap.txt file... feed that in to the server stdin
|
|
|
|
if [ -f /data/bootstrap.txt ]; then
|
|
|
|
bootstrapArgs="--bootstrap /data/bootstrap.txt"
|
|
|
|
fi
|
2018-12-28 08:56:28 +00:00
|
|
|
|
2018-07-13 21:35:56 +00:00
|
|
|
JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}"
|
2019-01-25 00:39:26 +00:00
|
|
|
exec mc-server-runner ${bootstrapArgs} ${mcServerRunnerArgs} java $JVM_XX_OPTS $JVM_OPTS $expandedDOpts -jar $SERVER "$@" $EXTRA_ARGS
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|