Make functional stub function make_hpr_sqlite_db

This commit is contained in:
Roan Horning 2023-03-03 20:42:42 -05:00
parent 13aeb647ad
commit d45ca0de96
Signed by untrusted user: rho_n
GPG Key ID: 234AEF20B72D5769

View File

@ -117,7 +117,46 @@ function download_hpr_sql {
# PARAMETERS: # PARAMETERS:
# RETURNS: # RETURNS:
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
function make_hpr_sqlite_db { echo; } function make_hpr_sqlite_db {
if [[ ! -d $1 ]] || ! expr $1 : '.*/tmp.*' ;
then
echo "Please provide the temporary directory when calling this function"
return 1
fi
local MYSQL2SQLITE=`which mysql2sqlite`
local BIN_PATH=""
if [ "$MYSQL2SQLITE" = "" ];
then
if [ $# -gt 1 ] && [ -z "$2" ];
then
BIN_PATH=$2
else
BIN_PATH=`find . -type f -name "mysql2sqlite" -print | head -1`
if [ "$BIN_PATH" != "" ];
then
BIN_PATH=${BIN_PATH/mysql2sqlite//}
else
echo "Could not find mysql2sqlite script."
return 1
fi
fi
fi
echo $BIN_PATH
if [ -f $1/hpr.db ];
then
rm $1/hpr.db
fi
# Remove lines from hpr.sql that mysql2sqlite can't handle
sed '/^DELIMITER ;;/,/^DELIMITER ;/d' < $1/hpr.sql > $1/hpr-sqlite.sql
${BIN_PATH}mysql2sqlite $1/hpr-sqlite.sql | sqlite3 $1/hpr.db
echo "Created hpr.db"
}
#--- FUNCTION ---------------------------------------------------------------- #--- FUNCTION ----------------------------------------------------------------
# NAME: copy_to_public_dir # NAME: copy_to_public_dir