Script To Easily Switch CraftBukkit Builds (*nix only)

Discussion in 'Bukkit Help' started by weirdbeard, Mar 4, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    weirdbeard

    I have received some inquiries about CB builds and some feedback on my detailed signature. (Thanks, by the way!) :) Anyway, I thought I would share this script which might help those running on *nix save some time when testing new versions of CraftBukkit.

    For those who are new to Linux, you must create a file with your favorite text editor. I use vi to create a file called "update_craftbukkit.sh". Copy the source below into the file and save it. Finally, make the file executable by typing the following Linux comand:

    chmod +x filename

    The script downloads the version specified and creates a backup of it with the version number attached to the filename.

    • You must have wget installed to use this script.
    • Remember to change the BUKKIT_FILE variable to point to the full path of your craftbukkit.jar file.

    Enjoy! Source follows:
    -WB

    Code:
    #!/bin/bash
    # Check for proper number of command line args. -------
    EXPECTED_ARGS=1
    E_BADARGS=65
    if [ $# -ne $EXPECTED_ARGS ]
    then
      echo "Usage: `basename $0` {arg}"
      exit $E_BADARGS
    fi
    # Set vars we will work with --------------------------
    BUKKIT_FILE=/full/path/to/craftbukkit.jar
    BUILD_NUM=$1
    BUILD_PATH_START=http://ci.bukkit.org/job/dev-CraftBukkit/
    BUILD_PATH_END=/artifact/target/
    SNAPSHOT_FILE=craftbukkit-0.0.1-SNAPSHOT.jar
    BUILD_LINK=$BUILD_PATH_START$BUILD_NUM$BUILD_PATH_END$SNAPSHOT_FILE
    BACKUP_FILE=$BUKKIT_FILE.$BUILD_NUM 
    # Download CraftBukkit --------------------------------
    wget $BUILD_LINK
    
    # Move download to Server Directory -------------------
    mv -f $SNAPSHOT_FILE $BUKKIT_FILE
    
    # Make an archive copy with build number attached -----
    cp $BUKKIT_FILE $BACKUP_FILE
    
    echo "Build $BUILD_NUM has been downloaded and installed!"
    
     
Thread Status:
Not open for further replies.

Share This Page