Update-checker optimized for bandwith

Discussion in 'Bukkit Tools' started by Terry Tibbs, Jul 25, 2011.

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

    Terry Tibbs

    Quickly created this tonight; I may come back and explain in more detail, but basically, it parses the Bukkit 'Recommended' RSS-feed for new a new version-number. Keep in mind that this was made with the intention of being implemented into your main server-management script, and as such, you have to add the backup mechanics yourself.

    YOU NEED RSSTAIL!
    sudo apt-get install rsstail

    Code:
    echo "Extracting latest version-number from Bukkit's 'Recommended' feed..."
    LATEST=`rsstail -1 -n 1 -N -u http://ci.bukkit.org/other/latest_recommended.rss | awk '{print $3}'`
    
    if [ ! -f currentversion ];
    then
      # File does not exist - create file and populate with latest version-number
      echo "File not found, creating file..."
      cat > currentversion --keyboardcat &>/dev/null
      echo "File created, populating file..."
      echo $LATEST > currentversion
      # Load contents into CURRENT
      echo "Done."
      exit 1
    else
      # File exists - proceed with business as usual
      echo "Found file, proceeding."
      CURRENT=`cat currentversion`
    fi
    
    if [ "$LATEST" -gt "$CURRENT" ]
    then
      echo "Current version: $CURRENT"
      echo "Latest version: $LATEST"
      echo "Updating..."
      ########################################
      ### REPLACE WITH UPDATER THINGAMAJOB ###
      ########################################
      echo $LATEST > currentversion
    else
      echo "Current version: $CURRENT"
      echo "Latest version: $LATEST"
      echo "Not updating."
    fi
    Oh! Before I forget; yes I suck at commenting code, and yes I'm half-retarded.
     
Thread Status:
Not open for further replies.

Share This Page