diff --git a/utils/lib_utils.sh b/utils/lib_utils.sh index 6667798..9f7d1fc 100644 --- a/utils/lib_utils.sh +++ b/utils/lib_utils.sh @@ -79,7 +79,37 @@ function clean_working_dir { # PARAMETERS: # RETURNS: #------------------------------------------------------------------------------- -function download_hpr_sql { echo; } +function download_hpr_sql { + + if [[ ! -d $1 ]] || ! expr $1 : '.*/tmp.*' ; + then + echo "Please provide the temporary directory when calling this function" + return 1 + fi + + local CURL=`which curl` + local WGET=`which wget` + local HPR_URL=https://www.hackerpublicradio.org/hpr.sql + + if [ -f $1/hpr.sql ]; + then + echo "Removing temporary hpr.sql" + rm $1/hpr.sql + else + echo "No temporary hpr.sql found" + fi + + if [ "$CURL" != "" ]; + then + curl $HPR_URL --output $1/hpr.sql + elif [ "$WGET" != "" ]; + then + wget --directory-prefix=$1 $HPR_URL + else + echo "Could not download file. Please install either curl or wget." + return 1 + fi +} #--- FUNCTION ---------------------------------------------------------------- # NAME: make_hpr_sqlite_db