Last active
November 12, 2020 10:02
-
-
Save MakStashkevich/36057da7a465cd03f4f0cd0c2f6693dc to your computer and use it in GitHub Desktop.
Start loader server from folder (to PocketMine-MP cores)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" | |
cd "$DIR" | |
while getopts "p:f:l" OPTION 2> /dev/null; do | |
case ${OPTION} in | |
p) | |
PHP_BINARY="$OPTARG" | |
;; | |
f) | |
POCKETMINE_FILE="$OPTARG" | |
;; | |
l) | |
DO_LOOP="yes" | |
;; | |
\?) | |
break | |
;; | |
esac | |
done | |
if [ "$PHP_BINARY" == "" ]; then | |
if [ -f ./bin/php7/bin/php ]; then | |
export PHPRC="" | |
PHP_BINARY="./bin/php7/bin/php" | |
elif [ -f ./../_php/bin/php7/bin/php ]; then | |
export PHPRC="" | |
PHP_BINARY="./../_php/bin/php7/bin/php" | |
elif [[ ! -z $(type php) ]]; then | |
PHP_BINARY=$(type -p php) | |
else | |
echo "Couldn't find a working PHP 7 binary, please use the installer." | |
exit 1 | |
fi | |
fi | |
if [ "$POCKETMINE_FILE" == "" ]; then | |
if [ -f ./PocketMine-MP.phar ]; then | |
POCKETMINE_FILE="./PocketMine-MP.phar" | |
elif [ -f ./src/pocketmine/PocketMine.php ]; then | |
POCKETMINE_FILE="./src/pocketmine/PocketMine.php" | |
elif [ -f ./Altay.phar ]; then | |
POCKETMINE_FILE="./Altay.phar" | |
else | |
echo "PocketMine-MP.phar or Altay.phar not found" | |
echo "Downloads can be found at https://github.com/pmmp/PocketMine-MP/releases" | |
echo "Or at https://github.com/TuranicTeam/Altay/releases" | |
exit 1 | |
fi | |
fi | |
LOOPS=0 | |
set +e | |
if [ "$DO_LOOP" == "yes" ]; then | |
while true; do | |
if [ ${LOOPS} -gt 0 ]; then | |
echo "Restarted $LOOPS times" | |
fi | |
"$PHP_BINARY" "$POCKETMINE_FILE" $@ | |
echo "To escape the loop, press CTRL+C now. Otherwise, wait 5 seconds for the server to restart." | |
echo "" | |
sleep 5 | |
((LOOPS++)) | |
done | |
else | |
exec "$PHP_BINARY" "$POCKETMINE_FILE" $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment