From 13aeb647ad50d77e81c2a7d663f51ac32d77e475 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Fri, 3 Mar 2023 20:41:29 -0500 Subject: [PATCH] Make functional stub function download_hpr_sql --- utils/lib_utils.sh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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