adding message formatting

This commit is contained in:
2025-06-30 11:18:12 -05:00
parent 7a5b90ae84
commit db6643c825

View File

@@ -9,9 +9,28 @@ set -o functrace
export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ ' export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ '
function print_info()
{
tput bold
tput setaf 1
echo "$1"
tpug sgr0
}
function print_error()
{
tput bold
tput setaf 1
echo "$1"
tpug sgr0
}
function error_out() function error_out()
{ {
echo "Bailing out. See above for reason...." print_error "$1"
print_error "Bailing out. See above for reason...."
exit 1 exit 1
} }
@@ -39,11 +58,11 @@ user_check="$(echo "$curr_user" | grep -c root)"
if [ $user_check -ne 1 ]; then if [ $user_check -ne 1 ]; then
echo "Must run as root." print_error "Must run as root."
error_out error_out
fi fi
echo "All checks passed...." print_info "All checks passed...."
} }
@@ -72,7 +91,7 @@ DL_ROOT="https://dl.knownelement.com/KNEL/FetchApply/"
function pi-detect() function pi-detect()
{ {
echo Now running "$FUNCNAME".... print_info Now running "$FUNCNAME"....
if [ -f /sys/firmware/devicetree/base/model ] ; then if [ -f /sys/firmware/devicetree/base/model ] ; then
export IS_RASPI="1" export IS_RASPI="1"
fi fi
@@ -80,17 +99,17 @@ fi
if [ ! -f /sys/firmware/devicetree/base/model ] ; then if [ ! -f /sys/firmware/devicetree/base/model ] ; then
export IS_RASPI="0" export IS_RASPI="0"
fi fi
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function global-oam() function global-oam()
{ {
echo Now running "$FUNCNAME".... print_info Now running "$FUNCNAME"....
curl --silent ${DL_ROOT}/scripts/distro > /usr/local/bin/distro && chmod +x /usr/local/bin/distro curl --silent ${DL_ROOT}/scripts/distro > /usr/local/bin/distro && chmod +x /usr/local/bin/distro
curl --silent ${DL_ROOT}/scripts/up2date.sh > /usr/local/bin/up2date.sh && chmod +x /usr/local/bin/up2date.sh curl --silent ${DL_ROOT}/scripts/up2date.sh > /usr/local/bin/up2date.sh && chmod +x /usr/local/bin/up2date.sh
echo "Setting up librenms agent..." print_info "Setting up librenms agent..."
if [ ! -d /usr/local/librenms-agent ]; then if [ ! -d /usr/local/librenms-agent ]; then
mkdir -p /usr/local/librenms-agent mkdir -p /usr/local/librenms-agent
@@ -104,13 +123,13 @@ curl --silent ${DL_ROOT}/Agents/librenms/postfix-queues.sh > /usr/local/librenms
curl --silent ${DL_ROOT}/Agents/librenms/smart > /usr/local/librenms-agent/smart curl --silent ${DL_ROOT}/Agents/librenms/smart > /usr/local/librenms-agent/smart
curl --silent ${DL_ROOT}/Agents/librenms/smart.config > /usr/local/librenms-agent/smart.config curl --silent ${DL_ROOT}/Agents/librenms/smart.config > /usr/local/librenms-agent/smart.config
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function global-systemServiceConfigurationFiles() function global-systemServiceConfigurationFiles()
{ {
echo Now running "$FUNCNAME".... print_info Now running "$FUNCNAME"....
curl --silent ${DL_ROOT}/ConfigFiles/ZSH/tsys-zshrc > /etc/zshrc curl --silent ${DL_ROOT}/ConfigFiles/ZSH/tsys-zshrc > /etc/zshrc
@@ -153,12 +172,12 @@ fi
newaliases newaliases
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function global-installPackages() function global-installPackages()
{ {
echo Now running "$FUNCNAME".... print_info Now running "$FUNCNAME"....
# Setup webmin repo, used for RBAC/2fa PAM # Setup webmin repo, used for RBAC/2fa PAM
@@ -194,7 +213,7 @@ apt-get --yes --purge remove systemd-timesyncd chrony telnet inetutils-telnet
# add stuff we want # add stuff we want
echo "Now installing all the packages..." print_info "Now installing all the packages..."
DEBIAN_FRONTEND="noninteractive" apt-get -qq --yes -o Dpkg::Options::="--force-confold" install \ DEBIAN_FRONTEND="noninteractive" apt-get -qq --yes -o Dpkg::Options::="--force-confold" install \
virt-what \ virt-what \
@@ -291,13 +310,13 @@ export DEBIAN_FRONTEND="noninteractive" && apt-get -qq --yes -o Dpkg::Options::=
# power-profiles-daemon # power-profiles-daemon
fi fi
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function global-postPackageConfiguration() function global-postPackageConfiguration()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
systemctl --now enable auditd systemctl --now enable auditd
@@ -388,7 +407,7 @@ if [ "$IS_VIRT_GUEST" = 1 ]; then
tuned-adm profile virtual-guest tuned-adm profile virtual-guest
fi fi
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
@@ -404,47 +423,47 @@ echo Completed running "$FUNCNAME"
function secharden-ssh() function secharden-ssh()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
curl --silent ${DL_ROOT}/Modules/Security/secharden-ssh.sh|$(which bash) curl --silent ${DL_ROOT}/Modules/Security/secharden-ssh.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function secharden-wazuh() function secharden-wazuh()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
curl --silent ${DL_ROOT}/Modules/Security/secharden-wazuh.sh|$(which bash) curl --silent ${DL_ROOT}/Modules/Security/secharden-wazuh.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function secharden-auto-upgrades() function secharden-auto-upgrades()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
#curl --silent ${DL_ROOT}/Modules/Security/secharden-ssh.sh|$(which bash) #curl --silent ${DL_ROOT}/Modules/Security/secharden-ssh.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function secharden-2fa() function secharden-2fa()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
#curl --silent ${DL_ROOT}/Modules/Security/secharden-2fa.sh|$(which bash) #curl --silent ${DL_ROOT}/Modules/Security/secharden-2fa.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function secharden-agents() function secharden-agents()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
#curl --silent ${DL_ROOT}/Modules/Security/secharden-audit-agents.sh|$(which bash) #curl --silent ${DL_ROOT}/Modules/Security/secharden-audit-agents.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
function secharden-scap-stig() function secharden-scap-stig()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
curl --silent ${DL_ROOT}/Modules/Security/secharden-scap-stig.sh|$(which bash) curl --silent ${DL_ROOT}/Modules/Security/secharden-scap-stig.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }
@@ -454,9 +473,9 @@ echo Completed running "$FUNCNAME"
function auth-cloudron-ldap() function auth-cloudron-ldap()
{ {
echo Now running "$FUNCNAME" print_info Now running "$FUNCNAME"
#curl --silent ${DL_ROOT}/Modules/Auth/auth-cloudron-ldap.sh|$(which bash) #curl --silent ${DL_ROOT}/Modules/Auth/auth-cloudron-ldap.sh|$(which bash)
echo Completed running "$FUNCNAME" print_info Completed running "$FUNCNAME"
} }