#!/bin/bash
set -e
BAD_COUNT=$(find /data /plugins ! -user pocketmine | wc -l)
if [ "$BAD_COUNT" -gt 0 ]; then
echo "=== WARNING ==="
echo "Detected $BAD_COUNT files in /data or /plugins not owned by the user \"pocketmine\"!"
echo "For example:"
find /data /plugins ! -user pocketmine | head
echo "This may cause problems when running the server."
echo "If you mount /data and /plugins from a local directory, consider running \`chown -R 1000:1000 \$MOUNT\` (replace \$MOUNT with your local directory) (you may need sudo to run this)"
echo "==============="
fi
if [ ! -z "$POCKETMINE_PLUGINS" ]; then
for PLUGIN in $(echo "$POCKETMINE_PLUGINS" | tr " " "\n"); do
PLUGIN_NAME=$(echo "$PLUGIN::" | cut -d: -f1)
PLUGIN_VERSION=$(echo "$PLUGIN::" | cut -d: -f2)
if [ ! -f "/plugins/$PLUGIN_NAME.phar" ]; then
echo "Installing $PLUGIN_NAME:$VERSION from Poggit"
wget -O "/plugins/$PLUGIN_NAME.phar" "https://poggit.pmmp.io/get/$PLUGIN_NAME/$PLUGIN_VERSION"
fi
done
fi
cd /opt/pocketmine
read -ra pm_args <<<"$POCKETMINE_ARGS"
exec php PocketMine-MP.phar --no-wizard --enable-ansi --data=/data --plugins=/plugins "${pm_args[@]}"