Archived
4
2
This repository has been archived on 2024-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
hpr_generator/utils/lib_utils.sh

92 lines
3.6 KiB
Bash

#!/bin/bash -
#===============================================================================
#
# FILE: lib_utils.sh
#
# USAGE: ./lib_utils.sh
#
# DESCRIPTION: functions for scripts used to update local HPR installations
# using the HPR static site generator
#
# OPTIONS: ---
# REQUIREMENTS: mysql2sqlite (https://github.com/dumblob/mysql2sqlite)
# BUGS: ---
# NOTES: ---
# AUTHOR: Roan "Rho`n" Horning <roan.horning@gmail.com>
# CREATED: 02/26/2023 03:27:08 PM -5 UTC
# REVISION: ---
# LICENSE: GNU AGPLv3
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#===============================================================================
set -o nounset # Treat unset variables as an error
#--- FUNCTION ----------------------------------------------------------------
# NAME: make_working_dir
# DESCRIPTION: Creates a local temporary working directory
# SEE: https://stackoverflow.com/questions/4632028/how-to-create-a-temporary-directory#answer-34676160
# PARAMETERS:
# RETURNS: The path to the working directory
#-------------------------------------------------------------------------------
function make_working_dir {
# the directory of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# the temp directory used, within $DIR
# omit the -p parameter to create a temporal directory in the default location
WORK_DIR=`mktemp -d -p "$DIR"`
# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
echo $WORK_DIR
}
#--- FUNCTION ----------------------------------------------------------------
# NAME: clean_working_dir
# DESCRIPTION: Remove local temporary working directory
# PARAMETERS:
# RETURNS:
#-------------------------------------------------------------------------------
function clean_working_dir { echo; }
#--- FUNCTION ----------------------------------------------------------------
# NAME: download_hpr_sql
# DESCRIPTION: Download the HPR SQL dump file into a working directory
# PARAMETERS:
# RETURNS:
#-------------------------------------------------------------------------------
function download_hpr_sql { echo; }
#--- FUNCTION ----------------------------------------------------------------
# NAME: make_hpr_sqlite_db
# DESCRIPTION: Converts the hpr sql file into an sqlite db file
# PARAMETERS:
# RETURNS:
#-------------------------------------------------------------------------------
function make_hpr_sqlite_db { echo; }
#--- FUNCTION ----------------------------------------------------------------
# NAME: copy_to_public_dir
# DESCRIPTION: Move HPR sql and db files to public website folder
# PARAMETERS:
# RETURNS:
#-------------------------------------------------------------------------------
function copy_to_public_dir { echo; }