PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
start.sh
1 #!/bin/bash
2 DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
3 cd "$DIR"
4 
5 DO_LOOP="no"
6 
7 while getopts "p:f:l" OPTION 2> /dev/null; do
8  case ${OPTION} in
9  p)
10  PHP_BINARY="$OPTARG"
11  ;;
12  f)
13  POCKETMINE_FILE="$OPTARG"
14  ;;
15  l)
16  DO_LOOP="yes"
17  ;;
18  \?)
19  break
20  ;;
21  esac
22 done
23 
24 if [ "$PHP_BINARY" == "" ]; then
25  if [ -f ./bin/php5/bin/php ]; then
26  PHP_BINARY="./bin/php5/bin/php"
27  elif [ type php 2>/dev/null ]; then
28  PHP_BINARY=$(type -p php)
29  else
30  echo "Couldn't find a working PHP binary, please use the installer."
31  exit 1
32  fi
33 fi
34 
35 if [ "$POCKETMINE_FILE" == "" ]; then
36  if [ -f ./PocketMine-MP.phar ]; then
37  POCKETMINE_FILE="./PocketMine-MP.phar"
38  elif [ -f ./src/pocketmine/PocketMine.php ]; then
39  POCKETMINE_FILE="./src/pocketmine/PocketMine.php"
40  else
41  echo "Couldn't find a valid PocketMine-MP installation"
42  exit 1
43  fi
44 fi
45 
46 LOOPS=0
47 
48 set +e
49 while [ "$LOOPS" -eq 0 ] || [ "$DO_LOOP" == "yes" ]; do
50  if [ "$DO_LOOP" == "yes" ]; then
51  "$PHP_BINARY" "$POCKETMINE_FILE" $@
52  else
53  exec "$PHP_BINARY" "$POCKETMINE_FILE" $@
54  fi
55  ((LOOPS++))
56 done
57 
58 if [ ${LOOPS} -gt 1 ]; then
59  echo "Restarted $LOOPS times"
60 fi