chore: enforce shellcheck across the repo
Establish shellcheck as a mandatory pre-commit quality gate and bring all 93
shell scripts to a clean state.
- tests/shellcheck.sh: wrapper that runs koalaman/shellcheck:stable via Docker
(no native binary needed), skips vendored + upstream librenms-agent scripts.
- .shellcheckrc: documents intentional codebase-wide disables (dynamic source
paths SC1090/SC1091, client-side ssh expansion SC2029).
- AGENTS.md: new Git Policy rule mandating clean shellcheck for every shell
script before commit.
Fixes applied (real bugs + quality): missing quote in netinfra/gather-configs.sh
(caused cascading parse errors), unquoted expansions, declare-and-assign masking,
egrep -> grep -E, $FUNCNAME array indexing, unused variable removal, cd || exit.
Intentional patterns (sourced config, sysfs/ps diagnostics, ssh heredocs that
expand local config) get justified targeted disables.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
@@ -60,18 +60,18 @@ LOCALUSER_CHECK="$(getent passwd | grep -c localuser || true)"
|
||||
#######################
|
||||
|
||||
function global-oam() {
|
||||
print_info "Now running $FUNCNAME...."
|
||||
print_info "Now running ${FUNCNAME[0]}...."
|
||||
|
||||
cat "$SCRIPTS_PATH/up2date.sh" >/usr/local/bin/up2date.sh && chmod +x /usr/local/bin/up2date.sh
|
||||
|
||||
bash "$MODULES_PATH/OAM/oam-librenms.sh"
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
|
||||
}
|
||||
|
||||
function global-systemServiceConfigurationFiles() {
|
||||
print_info "Now running $FUNCNAME...."
|
||||
print_info "Now running ${FUNCNAME[0]}...."
|
||||
|
||||
cat "$CONFIGFILES_PATH/ZSH/tsys-zshrc" >/etc/zshrc
|
||||
cat "$CONFIGFILES_PATH/SMTP/aliases" >/etc/aliases
|
||||
@@ -79,11 +79,11 @@ function global-systemServiceConfigurationFiles() {
|
||||
|
||||
newaliases
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function global-installPackages() {
|
||||
print_info "Now running $FUNCNAME...."
|
||||
print_info "Now running ${FUNCNAME[0]}...."
|
||||
|
||||
# Setup webmin repo, used for RBAC/2fa PAM
|
||||
|
||||
@@ -195,7 +195,7 @@ function global-installPackages() {
|
||||
VIRT_TYPE="$(virt-what)"
|
||||
|
||||
export IS_VIRT_GUEST
|
||||
IS_VIRT_GUEST="$(echo "$VIRT_TYPE" | egrep -c 'hyperv|kvm' || true)"
|
||||
IS_VIRT_GUEST="$(echo "$VIRT_TYPE" | grep -Ec 'hyperv|kvm' || true)"
|
||||
|
||||
export IS_KVM_GUEST
|
||||
IS_KVM_GUEST="$(echo "$VIRT_TYPE" | grep -c 'kvm' || true)"
|
||||
@@ -227,12 +227,12 @@ function global-installPackages() {
|
||||
|
||||
# vault cli
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function global-postPackageConfiguration() {
|
||||
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
|
||||
systemctl --now enable auditd
|
||||
|
||||
@@ -253,7 +253,7 @@ function global-postPackageConfiguration() {
|
||||
#This is under test/dev and may fail
|
||||
echo "hi from root to root" | mail -s "hi directly to root from $(hostname)" root
|
||||
|
||||
chsh -s $(which zsh) root
|
||||
chsh -s "$(which zsh)" root
|
||||
|
||||
if [ "$LOCALUSER_CHECK" -gt 0 ]; then
|
||||
chsh -s "$(which zsh)" localuser
|
||||
@@ -312,7 +312,7 @@ function global-postPackageConfiguration() {
|
||||
fi
|
||||
|
||||
export NTP_SERVER_CHECK
|
||||
NTP_SERVER_CHECK="$(hostname | egrep -c 'pfv-netboot|pfvsvrpi|pfv-netinfra' || true)"
|
||||
NTP_SERVER_CHECK="$(hostname | grep -Ec 'pfv-netboot|pfvsvrpi|pfv-netinfra' || true)"
|
||||
|
||||
if [ "$NTP_SERVER_CHECK" -eq 0 ]; then
|
||||
|
||||
@@ -341,7 +341,7 @@ function global-postPackageConfiguration() {
|
||||
tuned-adm profile virtual-guest
|
||||
fi
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
@@ -355,41 +355,41 @@ function global-postPackageConfiguration() {
|
||||
# SSH
|
||||
|
||||
function secharden-ssh() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
|
||||
bash "$MODULES_PATH/Security/secharden-ssh.sh"
|
||||
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-wazuh() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-wazuh.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-2fa() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-2fa.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-scap-stig() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-scap-stig.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-agents() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
bash "$MODULES_PATH/Security/secharden-audit-agents.sh"
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
function secharden-auto-upgrades() {
|
||||
print_info "Now running $FUNCNAME"
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
#curl --silent ${DL_ROOT}/Modules/Security/secharden-ssh.sh|$(which bash)
|
||||
print_info "Completed running $FUNCNAME"
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
|
||||
@@ -400,16 +400,16 @@ function secharden-auto-upgrades() {
|
||||
####################################################################################################
|
||||
|
||||
function auth-cloudron-ldap() {
|
||||
print_info "Now running "$FUNCNAME""
|
||||
print_info "Now running ${FUNCNAME[0]}"
|
||||
#curl --silent ${DL_ROOT}/Modules/Auth/auth-cloudron-ldap.sh|$(which bash)
|
||||
print_info "Completed running "$FUNCNAME""
|
||||
print_info "Completed running ${FUNCNAME[0]}"
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
# RUn the various functions in the correct order
|
||||
####################################################################################################
|
||||
|
||||
echo >$LOGFILENAME
|
||||
echo >"$LOGFILENAME"
|
||||
|
||||
print_info "Execution starting at $CURRENT_TIMESTAMP..."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user