Commit 1e04b46d authored by R. van Elst's avatar R. van Elst
Browse files

Ordering of script functions

parent d9a300bb
......@@ -11,29 +11,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# helper functions
command_exists() {
# check if command exists and fail otherwise
command -v "$1" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "I require '$1' but it's not installed. Please install it. Aborting."
exit 1
fi
}
# environment checks
[ "${BASH_VERSINFO:-0}" -lt 4 ] && { echo "I require at least Bash version 4. Aborting." >&2 ; exit 2; }
command_exists curl
case "$(uname -s)" in
Darwin*)
datecmd="gdate"
command_exists "${datecmd}"
;;
*)
datecmd="date"
esac
# Start of configuration.
#array names must not contain spaces, only a-ZA-Z.
......@@ -82,6 +59,29 @@ set -e
# patterns which match no files expand to a null string, otherwise later on we'd have *.status as a file...
shopt -s nullglob
# helper functions
command_exists() {
# check if command exists and fail otherwise
command -v "$1" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "I require '$1' but it's not installed. Please install it. Aborting."
exit 1
fi
}
# environment checks
[ "${BASH_VERSINFO:-0}" -lt 4 ] && { echo "I require at least Bash version 4. Aborting." >&2 ; exit 2; }
command_exists curl
case "$(uname -s)" in
Darwin*)
datecmd="gdate"
command_exists "${datecmd}"
;;
*)
datecmd="date"
esac
# start of the function definitions
# This function allows the script to execute all the curl calls in parallel.
......@@ -302,9 +302,6 @@ cleanupOKCheckFiles() {
writeHeader() {
if [[ "${cgi}" = true ]]; then
printf "Content-type: text/html\n\n";
fi
echo '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">'
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">'
echo "<title>${title}</title>"
......@@ -332,6 +329,10 @@ writeFooter() {
# script start
if [[ "${cgi}" = true ]]; then
printf "Content-type: text/html\n\n";
fi
# Total script duration timer
start=$(${datecmd} +%s%3N)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment