Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Linux] PocketMine-DEV-build install/update/start script

Comments in 'Tools' started by BMicraft, Jun 17, 2014.

  1. BMicraft
    Offline

    BMicraft New Member

    Joined:
    Sep 7, 2013
    Posts:
    12
    Minecraft User:
    Bernhard000
    Hello guys! :)
    I would like to introduce you to my litte update script written in bash.

    Background:
    Dev-builds are released nearly everyday and sometimes even more frequently but until now you had to update manually (because the only plugin that would have done it for you is outdated and does not work anymore). This annoyed me to so I wrote this little script.​

    It is ment to be used as a start script even though is is not really one because all is does is updating (or installing using the official installer script) and then calling the real start script.
    You can rename the script (even with spaces) and the script will still be able to update itself BUT...

    WARNING: If any directory in the complete path to this script contains a space there is a chance that something will mess up and PocketMine-MP will install beside the first directory containing a space (If you got any idea how to fix this please tell me)!

    Here is a download (always the latest version)...
    Code:
    wget dl.bmicraft.tk/scripts/update-pm.sh && chmod 777 update-pm.sh && mv update-pm.sh "{your desired filename}"

    ...and here is the code (possibly outdated):
    Code:
    #!/bin/bash
    
    # Set (remember) variables for later
    rwdir=`pwd`
    wdir=`echo "$rwdir/PocketMine-MP-dev"`
    tdir="/tmp/PocketMine-MP-update"
    rm -rf $tdir/
    mkdir $tdir
    usname="$0"
    
    # Checking if a valid installation of PocketMint exists in ./PocketMine-MP-dev
    if [ -f $wdir/start.sh ]; then
        echo "" > $tdir/output.log
    else
        echo ""
        echo "  No installation of PocketMine-MP detected:"
        echo "  Using the official script (~20seconds)..."
        sleep 0.3
        rm -rf $wdir
        mkdir $wdir
        cd $wdir
        wget -q -O - https://raw.githubusercontent.com/PocketMine/PocketMine-MP/master/src/build/installer.sh | bash -s - -v master > $tdir/output.log
        cd ..
        echo "  The installation by the script is now complete."
    fi
    
    
    # Downloading latest zipped PocketMine build
    #    ('cause it's easier than downloading only the "PocketMine-MP.phar" file)
    echo ""
    echo "  Downloading the latest dev-build of PocketMine-MP..."
    wget -O $tdir/update.zip http://jenkins.pocketmine.net/job/PocketMine-MP/lastSuccessfulBuild/artifact/*zip*/archive.zip -q > $tdir/output.log
    echo "  Download complete."
    
    # Unzipping the archive, renaming the output folder and deleting the archive
    unzip $tdir/update.zip -d $tdir  > $tdir/output.log
    rm $tdir/update.zip
    
    # Preparing the variables for comparing
    oldver=`cat $wdir/PocketMine-MP-version.txt > $tdir/output.log 2>&1`
    newverpath=`find $tdir/archive/*`
    newver=`basename $newverpath`
    
    # Compare the versions and output if there is a newer version that will be installed
    echo ""
    if [ "$oldver" = "$newver" ]; then
        echo "  Your version is up-to-date ($newver)"
    else
        echo "  Installing new version ($newver)"
        mv $tdir/archive/PocketMine-MP*.phar $wdir/PocketMine-MP.phar
        echo "$newver" > $wdir/PocketMine-MP-version.txt
    fi
    
    # Update this script
    wget dl.bmicraft.tk/scripts/update-pm.sh -O $tdir/us.sh -q
    mv $tdir/us.sh "$rwdir/$usname"
    chmod 777 "$rwdir/$usname"
    
    rm -r $tdir
    
    bash $wdir/start.sh
    

    Please report any bugs you experience or think that they could happen!
    --BMicraft
    Last edited: Jun 17, 2014
  2. LastHunterKid
    Offline

    LastHunterKid New Member

    Joined:
    Jun 21, 2014
    Posts:
    9
    Minecraft User:
    HeroLastHunter
    are u can teach me how to use pocketmine in linux?
  3. HostingItAll
    Offline

    HostingItAll Active Member

    Joined:
    Dec 26, 2013
    Posts:
    52
    Minecraft User:
    Console
    Try this:


    Code:
    DIRECTORY="some dir"

    And use cd as follows

    Code:
    cd "$DIRECTORY"

Share This Page

Advertisement