Files
chawley (tfadmin) 9f3a47b2e1 Shell header template
Automatically populate filename, creation date and modification date in
shell header.  Also add the ability to update header on old scripts
2024-02-27 18:54:25 +00:00

58 lines
1.6 KiB
Plaintext

:insert
#!/usr/bin/env bash
#===============================================================================
#
# FILE: filename
# USAGE:
# DESCRIPTION:
# NOTES:
# AUTHOR: C Hawley
# CREATED:
# UPDATED:
#
#===============================================================================
set -o nounset # Treat unset variables as an error
# set variables
declare -r TRUE=0
declare -r FALSE=1
##################################################################
# Purpose: Check for empty argument
# Arguments: at least one
# Return: Either error message or exit with an error code 1
##################################################################
if [ -z "${1:-}" ]; then
arg="undefined"
echo "Required Argument Missing"
#exit 1
else
arg=$1
fi
##################################################################
# Purpose: Send output to screen and specified file
# Requires: define to `logfile` variable to send out put to logfile
# Usage: logecho "Log Message"
##################################################################
logfile=
logecho() {
echo "${1}"
if [[ ! -z "${logfile}" ]]; then
echo "${1}" >> "${logfile}"
fi
}
##################################################################
# Purpose: Return true if script is executed by the root user
# Arguments: none
# Return: True or False
# Usage: is_root && echo "root" || echo "not root"
##################################################################
function is_root()
{
[ $(id -u) -eq 0 ] && return $TRUE || return $FALSE
}