1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

making limited loops in start.sh

Discussion in 'Help' started by Vadim Bogoratov, Dec 9, 2017.

  1. Vadim Bogoratov

    Vadim Bogoratov Spider

    Messages:
    14
    Dear friends,

    Could you help me to make limited loops in start.sh script? For example, I got fucked up plugin and my server keeps trying to start. Is it possible to limit those loops? I know that I should just delete or rewrite the plugin, but in my case I want to limit loops.

    Here the start.sh:

    Code:
    #!/bin/bash
    
    # start.sh for Genisys #
    #
    # Please input ./start.sh to start server #
    
    # Variable define
    
    DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
    cd "$DIR"
    
    # Loop starting
    # Do not edit without knowing what are you doing!
    
    DO_LOOP="yes"
    
    ###########################################
    # DO NOT EDIT ANY THING BEHIND THIS LINE! #
    ###########################################
    
    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 [ type php 2>/dev/null ]; then
            PHP_BINARY=$(type -p php)
        else
            echo "Couldn't find a working PHP binary, please use the installer."
            exit 1
        fi
    fi
    
    if [ "$POCKETMINE_FILE" == "" ]; then
        if [ -f ./PocketMine-iTX.phar ]; then
            POCKETMINE_FILE="./PocketMine-iTX.phar"
        elif [ -f ./Genisys_1.0dev_#*.phar ]; then
            POCKETMINE_FILE="./Genisys_1.0dev_*.phar"
        elif [ -f ./PocketMine-MP.phar ]; then
            POCKETMINE_FILE="./PocketMine-MP.phar"
        elif [ -f ./src/pocketmine/PocketMine.php ]; then
            POCKETMINE_FILE="./src/pocketmine/PocketMine.php"
        else
            echo "Couldn't find a valid Genisys installation"
            exit 1
        fi
    fi
    
    LOOPS=0
    
    set +e
    while [ "$LOOPS" -eq 0 ] || [ "$DO_LOOP" == "yes" ]; do
        if [ "$DO_LOOP" == "yes" ]; then
            "$PHP_BINARY" "$POCKETMINE_FILE" $@
        else
            exec "$PHP_BINARY" "$POCKETMINE_FILE" $@
        fi
        ((LOOPS++))
    done
    
    if [ ${LOOPS} -gt 1 ]; then
        echo "Restarted $LOOPS times"
    fi
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
  4. Vadim Bogoratov

    Vadim Bogoratov Spider

    Messages:
    14
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Oops, I shouldn't answer half-asleep. Try this start.sh and edit MAX_LOOPS
     

    Attached Files:

    Vadim Bogoratov likes this.
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
     
    EdwardHamHam likes this.
  7. Vadim Bogoratov

    Vadim Bogoratov Spider

    Messages:
    14
    thanks a lot! That's really what I want! You're the best!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.