Skip to content

Instantly share code, notes, and snippets.

@JackNoordhuis
Last active February 8, 2018 12:28
Show Gist options
  • Save JackNoordhuis/2e8ea6966a7f33c8f2e36df3762d7cf4 to your computer and use it in GitHub Desktop.
Save JackNoordhuis/2e8ea6966a7f33c8f2e36df3762d7cf4 to your computer and use it in GitHub Desktop.
Simple bash script to install PocketMine straight from GitHub
#!/bin/bash
echo "~––~ Installing latest verion of PMMP ~––~"
echo ""
# Make sure we're working from the correct directory
DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
cd "$DIR"
# Default argument values
DEVTOOLS=false
COMPILE=false
SOURCE=true
# Assign arguments to variables
while [[ $# -gt 0 ]] && [[ ."$1" = .--* ]]; do
opt="$1";
shift;
case "$opt" in
"--" ) break 2;;
"--devtools" )
DEVTOOLS=true;;
"--start" )
START=true;;
"--compile" )
COMPILE=true;;
"--no-source" )
SOURCE=false;;
*) echo >&2 "Invalid option: $@"; exit 1;;
esac
done
if [ "$DEVTOOLS" == true ] || [ "$COMPILE" == true ]; then
echo "[Installer] Downloading DevTools..."
git clone https://github.com/pmmp/PocketMine-DevTools.git >/dev/null 2>&1
mkdir -p plugins
echo "[Installer] Compiling DevTools..."
bin/php7/bin/php PocketMine-DevTools/src/DevTools/ConsoleScript.php --make "PocketMine-DevTools" --relative "PocketMine-DevTools" --out "plugins/DevTools.phar" >/dev/null 2>&1
rm -rf PocketMine-DevTools
fi
if [ "$SOURCE" == true ] || [ "$COMPILE" == true ]; then
# Download the latest source files from GitHub recursivley and move them to the servers root directory
rm -rf src *.phar
echo "[Installer] Downloading latest version of PMMP..."
git clone --recursive https://github.com/pmmp/PocketMine-MP.git -b master >/dev/null 2>&1
mv PocketMine-MP/src .
mv PocketMine-MP/start.sh .
rm -rf PocketMine-MP
fi
if [ "$COMPILE" == true ]; then
echo "[Installer] Compiling phar..."
bin/php7/bin/php plugins/DevTools.phar --make src --relative ./ --entry src/pocketmine/PocketMine-MP.php --out PocketMine-MP.phar >/dev/null 2>&1
if ls PocketMine-MP.phar >/dev/null 2>&1; then
echo "[Installer] Server phar compiled successfully!"
if [ "$SOURCE" != true ]; then
rm -rf src
fi
else
echo "[Installer] Error while compiling phar!"
fi
fi
if [ "$COMPILE" == true ] && [ "$DEVTOOLS" == false ]; then
rm -rf plugins/DevTools.phar
fi
echo "[Installer] Done!"
echo ""
exit 0
Usage:
Install source: ./github-installer.sh
Install compiled server Phar without source: ./github-installer.sh --compile --no-source
Install DevTools and compiled server Phar with source: ./githubinstaller.sh --devtools --compile
Install DevTools and compiled server Phar without source: ./github-installer.sh --devtools --compile --no-source
@dktapps
Copy link

dktapps commented Feb 6, 2017

You don't need to clone DevTools separately, it's already included as a PocketMine-MP submodule under tests/plugins

@hintzsche
Copy link

i got an error on compiling the phar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment