#!/bin/bash
FAIL_MESSAGE="This version of Linux is not supported. Please visit http://fewerwords.org/theburrow/en/download and build the The Burrow from source code."

if [ -f /etc/os-release ]
then
    source /etc/os-release
    SHORT_VERSION=${VERSION_ID%%.*}
    
    if ([ "$NAME" == "Debian GNU/Linux" ] && (( ${SHORT_VERSION%%.*} >= 7 )) ) || ([ "$NAME" == "Ubuntu" ] && (( $SHORT_VERSION >= 13 )) );
    then
        if ! grep -q "repo.fewerwords.org/debian/" "/etc/apt/sources.list" ; then
            echo "deb http://repo.fewerwords.org/debian/ wheezy main" | sudo tee -a /etc/apt/sources.list > /dev/null

            if which wget >/dev/null; then
                wget -O- http://repo.fewerwords.org/fewerwords.asc | sudo apt-key add -
            fi
            
        fi
        sudo apt-get update 
        sudo apt-get install the-burrow
    else
        echo ${FAIL_MESSAGE}
    fi
else
    echo ${FAIL_MESSAGE}
fi
