diff --git a/Framework-ConfigFiles/Framework-ConfigFiles/FrameworkVars b/Framework-ConfigFiles/Framework-ConfigFiles/FrameworkVars new file mode 100644 index 0000000..9e52a7d --- /dev/null +++ b/Framework-ConfigFiles/Framework-ConfigFiles/FrameworkVars @@ -0,0 +1,4 @@ +#Global Variables used by the framework + +export ProjectIncludes="0" +export PreflightCheck="0" diff --git a/Framework-ConfigFiles/Framework-ConfigFiles/kv_map b/Framework-ConfigFiles/Framework-ConfigFiles/kv_map new file mode 100644 index 0000000..510a7e0 --- /dev/null +++ b/Framework-ConfigFiles/Framework-ConfigFiles/kv_map @@ -0,0 +1,19 @@ +#Place (primary/unique) key as very first argument on each record below + +#Value Fields are (in order), (reference KEY_(VARIABLE) names in the code): +#1)valuex (description) +#2)valuey (description) +#3)valuez (description) + +#An example: +#unique key of serverfqdn +#key of: subnet , value of: 10.10.10.0/24 +#key of: gateway, value of: 10.10.10.1 + +#serverfqdn,10.10.10.0/24,10.10.10.1 + +#Place your records below: + +#primary/uniquekey,#value +primarykey1,valuex,valuey,valuez +primarykey2,valuex,valuey,valuez diff --git a/Framework-Includes/DebugMe.sh b/Framework-Includes/DebugMe.sh new file mode 100644 index 0000000..d4414f1 --- /dev/null +++ b/Framework-Includes/DebugMe.sh @@ -0,0 +1,33 @@ +function DebugMe() { + [[ $script_debug = 1 ]] && "$@" || : + +#to turn debugging on, set script_debug=1 +#to turn debugging off, set script_debug=0 + +# be sure to append || : or || true here or use return 0, since the return code +# of this function should always be 0 to not influence anything else with an unwanted +# "false" return code (for example the script's exit code if this function is used +# as the very last command in the script) + +#This function does nothing when script_debug is unset or empty, but it executes the +#given parameters as commands when script_debug is set. Use it like this: + +#debugme logger "Sorting the database" +#database_sort +#debugme logger "Finished sorting the database, exit code $?" + + +# * print commands to be executed to stderr as if they were read from input +# (script file or keyboard) +# * print everything before any ( substitution and expansion, …) is applied +set -v + +# * print everything as if it were executed, after substitution and expansion is applied +# * indicate the depth-level of the subshell (by default by prefixing a + (plus) sign to +# the displayed command) +# * indicate the recognized words after word splitting by marking them like 'x y' +# * in shell version 4.1, this debug output can be printed to a configurable file +#descriptor, rather than sdtout by setting the BASH_XTRACEFD variable. +set -x + +} diff --git a/Framework-Includes/ErrorHandling.sh b/Framework-Includes/ErrorHandling.sh new file mode 100644 index 0000000..2d41042 --- /dev/null +++ b/Framework-Includes/ErrorHandling.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Standard strict mode and error handling/tracing boilderplate.. + +# This is a function I include and execute in every shell script that I write. +# It sets up a bunch of error handling odds and ends + +# Bits and pieces Sourced from (as best I recall): +# * https://news.ycombinator.com/item?id=24727495 +# * many other hacker news / slashdot etc posts over the years +# * https://www.tothenew.com/blog/foolproof-your-bash-script-some-best-practices/ +# * https://translucentcomputing.com/2020/05/unofficial-bash-strict-mode-errexit/ +# * http://redsymbol.net/articles/unofficial-bash-strict-mode/ +# * the school of hard knocks... (aka my code failures...) + +#Here's the beef (as the commercial says..) + +export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ ' + +function error_out() +{ + echo "Bailing out. See above for reason...." + exit 1 +} + +function handle_failure() { + local lineno=$1 + local fn=$2 + local exitstatus=$3 + local msg=$4 + local lineno_fns=${0% 0} + if [[ "$lineno_fns" != "-1" ]] ; then + lineno="${lineno} ${lineno_fns}" + fi + echo "${BASH_SOURCE[0]}: Function: ${fn} Line Number : [${lineno}] Failed with status ${exitstatus}: $msg" +} + +trap 'handle_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR + +#use errexit (a.k.a. set -e) to make your script exit when a command fails. +#add || true to commands that you allow to fail. +set -o errexit + +# Use set -o nounset (a.k.a. set -u) to exit when your script tries to use undeclared +# variables. +set -o nounset + +#Use set -o pipefail in scripts to catch (for example) mysqldump fails +#in e.g. mysqldump |gzip. +#The exit status of the last command that threw a non-zero exit code is returned +set -o pipefail + +#Function tracing... +set -o functrace \ No newline at end of file diff --git a/Framework-Includes/LocalHelp.sh b/Framework-Includes/LocalHelp.sh new file mode 100644 index 0000000..de3918f --- /dev/null +++ b/Framework-Includes/LocalHelp.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +function LocalHelp() +{ + echo "$0 is " + echo "$0 takes arguments: " + echo "1) " + echo "2) " + echo ":" + echo "" + echo "" + echo "" +} diff --git a/Framework-Includes/Logging.sh b/Framework-Includes/Logging.sh new file mode 100755 index 0000000..b168817 --- /dev/null +++ b/Framework-Includes/Logging.sh @@ -0,0 +1,5 @@ +export CURRENT_TIMESTAMP +CURRENT_TIMESTAMP="$(date +%A-%Y-%m-%d-%T)" + +export LOGFILENAME +LOGFILENAME="$0.${CURRENT_TIMESTAMP}.$$" \ No newline at end of file diff --git a/Framework-Includes/LookupKv.sh b/Framework-Includes/LookupKv.sh new file mode 100644 index 0000000..7baf9c3 --- /dev/null +++ b/Framework-Includes/LookupKv.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +function LookupKV() +{ + +echo "KV lookup..." + +#Arguments: +#$1 +#$2 unique record identifier + +#Returns: +#Variable/array containing all the values in the record + +} diff --git a/Framework-Includes/PreflightCheck.sh b/Framework-Includes/PreflightCheck.sh new file mode 100644 index 0000000..282a798 --- /dev/null +++ b/Framework-Includes/PreflightCheck.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +function PreflightCheck() +{ + +#Common things I check for in the scripts I write. + +#export curr_host="$(hostname)" +#export curr_user="$USER" +#export host_check="$(echo $curr_host | grep -c )" +#export user_check="$(echo $curr_user | grep -c )" + +#if [ $host_check -ne 1 ]; then +# echo "Must run on ." +# error_out +#fi + +#if [ $user_check -ne 1 ]; then +# echo "Must run as ." +# error_out +#fi + +#if [ "$ARG_COUNT" -ne ]; then +# help +# error_out +#fi + +#Your additional stuff here... +echo "All checks passed...." + +} diff --git a/Framework-Includes/PrettyPrint.sh b/Framework-Includes/PrettyPrint.sh new file mode 100644 index 0000000..86220a9 --- /dev/null +++ b/Framework-Includes/PrettyPrint.sh @@ -0,0 +1,20 @@ +function print_info() +{ + GREEN='\033[0;32m' + NC='\033[0m' + tput bold + echo -e "$GREEN $1${NC}" + echo -e "$GREEN $1${NC}" >> "$LOGFILENAME" + tput sgr0 +} + +function print_error() +{ + RED='\033[0;31m' + NC='\033[0m' + tput bold + echo -e "$RED $1${NC}" + echo -e "$RED $1${NC}" >> "$LOGFILENAME" + echo "$1" + tput sgr0 +} \ No newline at end of file diff --git a/Agents/librenms/ntp-client.sh b/ProjectCode/Agents/librenms/ntp-client.sh similarity index 100% rename from Agents/librenms/ntp-client.sh rename to ProjectCode/Agents/librenms/ntp-client.sh diff --git a/Agents/librenms/ntp-server.sh b/ProjectCode/Agents/librenms/ntp-server.sh similarity index 100% rename from Agents/librenms/ntp-server.sh rename to ProjectCode/Agents/librenms/ntp-server.sh diff --git a/Agents/librenms/os-updates.sh b/ProjectCode/Agents/librenms/os-updates.sh similarity index 100% rename from Agents/librenms/os-updates.sh rename to ProjectCode/Agents/librenms/os-updates.sh diff --git a/Agents/librenms/postfix-queues,sh b/ProjectCode/Agents/librenms/postfix-queues,sh similarity index 100% rename from Agents/librenms/postfix-queues,sh rename to ProjectCode/Agents/librenms/postfix-queues,sh diff --git a/Agents/librenms/postfixdetailed.sh b/ProjectCode/Agents/librenms/postfixdetailed.sh similarity index 100% rename from Agents/librenms/postfixdetailed.sh rename to ProjectCode/Agents/librenms/postfixdetailed.sh diff --git a/Agents/librenms/smart b/ProjectCode/Agents/librenms/smart similarity index 100% rename from Agents/librenms/smart rename to ProjectCode/Agents/librenms/smart diff --git a/Agents/librenms/smart.config b/ProjectCode/Agents/librenms/smart.config similarity index 100% rename from Agents/librenms/smart.config rename to ProjectCode/Agents/librenms/smart.config diff --git a/ConfigFiles/AuditD/auditd.conf b/ProjectCode/ConfigFiles/AuditD/auditd.conf similarity index 100% rename from ConfigFiles/AuditD/auditd.conf rename to ProjectCode/ConfigFiles/AuditD/auditd.conf diff --git a/ConfigFiles/AuditD/rules.d/time-change.rules b/ProjectCode/ConfigFiles/AuditD/rules.d/time-change.rules similarity index 100% rename from ConfigFiles/AuditD/rules.d/time-change.rules rename to ProjectCode/ConfigFiles/AuditD/rules.d/time-change.rules diff --git a/ConfigFiles/BANNERS/issue b/ProjectCode/ConfigFiles/BANNERS/issue similarity index 100% rename from ConfigFiles/BANNERS/issue rename to ProjectCode/ConfigFiles/BANNERS/issue diff --git a/ConfigFiles/BANNERS/issue.net b/ProjectCode/ConfigFiles/BANNERS/issue.net similarity index 100% rename from ConfigFiles/BANNERS/issue.net rename to ProjectCode/ConfigFiles/BANNERS/issue.net diff --git a/ConfigFiles/BANNERS/motd b/ProjectCode/ConfigFiles/BANNERS/motd similarity index 100% rename from ConfigFiles/BANNERS/motd rename to ProjectCode/ConfigFiles/BANNERS/motd diff --git a/ConfigFiles/DHCP/dhclient.conf b/ProjectCode/ConfigFiles/DHCP/dhclient.conf similarity index 100% rename from ConfigFiles/DHCP/dhclient.conf rename to ProjectCode/ConfigFiles/DHCP/dhclient.conf diff --git a/ConfigFiles/Logrotate/logrotate.conf b/ProjectCode/ConfigFiles/Logrotate/logrotate.conf similarity index 100% rename from ConfigFiles/Logrotate/logrotate.conf rename to ProjectCode/ConfigFiles/Logrotate/logrotate.conf diff --git a/ConfigFiles/ModProbe/cramfs.conf b/ProjectCode/ConfigFiles/ModProbe/cramfs.conf similarity index 100% rename from ConfigFiles/ModProbe/cramfs.conf rename to ProjectCode/ConfigFiles/ModProbe/cramfs.conf diff --git a/ConfigFiles/ModProbe/dccp.conf b/ProjectCode/ConfigFiles/ModProbe/dccp.conf similarity index 100% rename from ConfigFiles/ModProbe/dccp.conf rename to ProjectCode/ConfigFiles/ModProbe/dccp.conf diff --git a/ConfigFiles/ModProbe/freevxfs.conf b/ProjectCode/ConfigFiles/ModProbe/freevxfs.conf similarity index 100% rename from ConfigFiles/ModProbe/freevxfs.conf rename to ProjectCode/ConfigFiles/ModProbe/freevxfs.conf diff --git a/ConfigFiles/ModProbe/hfs.conf b/ProjectCode/ConfigFiles/ModProbe/hfs.conf similarity index 100% rename from ConfigFiles/ModProbe/hfs.conf rename to ProjectCode/ConfigFiles/ModProbe/hfs.conf diff --git a/ConfigFiles/ModProbe/hfsplus.conf b/ProjectCode/ConfigFiles/ModProbe/hfsplus.conf similarity index 100% rename from ConfigFiles/ModProbe/hfsplus.conf rename to ProjectCode/ConfigFiles/ModProbe/hfsplus.conf diff --git a/ConfigFiles/ModProbe/jffs2.conf b/ProjectCode/ConfigFiles/ModProbe/jffs2.conf similarity index 100% rename from ConfigFiles/ModProbe/jffs2.conf rename to ProjectCode/ConfigFiles/ModProbe/jffs2.conf diff --git a/ConfigFiles/ModProbe/rds.conf b/ProjectCode/ConfigFiles/ModProbe/rds.conf similarity index 100% rename from ConfigFiles/ModProbe/rds.conf rename to ProjectCode/ConfigFiles/ModProbe/rds.conf diff --git a/ConfigFiles/ModProbe/sctp.conf b/ProjectCode/ConfigFiles/ModProbe/sctp.conf similarity index 100% rename from ConfigFiles/ModProbe/sctp.conf rename to ProjectCode/ConfigFiles/ModProbe/sctp.conf diff --git a/ConfigFiles/ModProbe/squashfs.conf b/ProjectCode/ConfigFiles/ModProbe/squashfs.conf similarity index 100% rename from ConfigFiles/ModProbe/squashfs.conf rename to ProjectCode/ConfigFiles/ModProbe/squashfs.conf diff --git a/ConfigFiles/ModProbe/tipc.conf b/ProjectCode/ConfigFiles/ModProbe/tipc.conf similarity index 100% rename from ConfigFiles/ModProbe/tipc.conf rename to ProjectCode/ConfigFiles/ModProbe/tipc.conf diff --git a/ConfigFiles/ModProbe/udf.conf b/ProjectCode/ConfigFiles/ModProbe/udf.conf similarity index 100% rename from ConfigFiles/ModProbe/udf.conf rename to ProjectCode/ConfigFiles/ModProbe/udf.conf diff --git a/ConfigFiles/ModProbe/usb_storage.conf b/ProjectCode/ConfigFiles/ModProbe/usb_storage.conf similarity index 100% rename from ConfigFiles/ModProbe/usb_storage.conf rename to ProjectCode/ConfigFiles/ModProbe/usb_storage.conf diff --git a/ConfigFiles/NTP/ntp.conf b/ProjectCode/ConfigFiles/NTP/ntp.conf similarity index 100% rename from ConfigFiles/NTP/ntp.conf rename to ProjectCode/ConfigFiles/NTP/ntp.conf diff --git a/ConfigFiles/SMTP/aliases b/ProjectCode/ConfigFiles/SMTP/aliases similarity index 100% rename from ConfigFiles/SMTP/aliases rename to ProjectCode/ConfigFiles/SMTP/aliases diff --git a/ConfigFiles/SMTP/postfix_generic b/ProjectCode/ConfigFiles/SMTP/postfix_generic similarity index 100% rename from ConfigFiles/SMTP/postfix_generic rename to ProjectCode/ConfigFiles/SMTP/postfix_generic diff --git a/ConfigFiles/SNMP/snmp-sudo.conf b/ProjectCode/ConfigFiles/SNMP/snmp-sudo.conf similarity index 100% rename from ConfigFiles/SNMP/snmp-sudo.conf rename to ProjectCode/ConfigFiles/SNMP/snmp-sudo.conf diff --git a/ConfigFiles/SNMP/snmpd-physicalhost.conf b/ProjectCode/ConfigFiles/SNMP/snmpd-physicalhost.conf similarity index 100% rename from ConfigFiles/SNMP/snmpd-physicalhost.conf rename to ProjectCode/ConfigFiles/SNMP/snmpd-physicalhost.conf diff --git a/ConfigFiles/SNMP/snmpd-rpi.conf b/ProjectCode/ConfigFiles/SNMP/snmpd-rpi.conf similarity index 100% rename from ConfigFiles/SNMP/snmpd-rpi.conf rename to ProjectCode/ConfigFiles/SNMP/snmpd-rpi.conf diff --git a/ConfigFiles/SNMP/snmpd.conf b/ProjectCode/ConfigFiles/SNMP/snmpd.conf similarity index 100% rename from ConfigFiles/SNMP/snmpd.conf rename to ProjectCode/ConfigFiles/SNMP/snmpd.conf diff --git a/ConfigFiles/SSH/AuthorizedKeys/localuser-ssh-authorized-keys b/ProjectCode/ConfigFiles/SSH/AuthorizedKeys/localuser-ssh-authorized-keys similarity index 100% rename from ConfigFiles/SSH/AuthorizedKeys/localuser-ssh-authorized-keys rename to ProjectCode/ConfigFiles/SSH/AuthorizedKeys/localuser-ssh-authorized-keys diff --git a/ConfigFiles/SSH/AuthorizedKeys/root-ssh-authorized-keys b/ProjectCode/ConfigFiles/SSH/AuthorizedKeys/root-ssh-authorized-keys similarity index 100% rename from ConfigFiles/SSH/AuthorizedKeys/root-ssh-authorized-keys rename to ProjectCode/ConfigFiles/SSH/AuthorizedKeys/root-ssh-authorized-keys diff --git a/ConfigFiles/SSH/Configs/ssh-audit_hardening.conf b/ProjectCode/ConfigFiles/SSH/Configs/ssh-audit_hardening.conf similarity index 100% rename from ConfigFiles/SSH/Configs/ssh-audit_hardening.conf rename to ProjectCode/ConfigFiles/SSH/Configs/ssh-audit_hardening.conf diff --git a/ConfigFiles/SSH/Configs/tsys-sshd-config b/ProjectCode/ConfigFiles/SSH/Configs/tsys-sshd-config similarity index 100% rename from ConfigFiles/SSH/Configs/tsys-sshd-config rename to ProjectCode/ConfigFiles/SSH/Configs/tsys-sshd-config diff --git a/ConfigFiles/Syslog/rsyslog.conf b/ProjectCode/ConfigFiles/Syslog/rsyslog.conf similarity index 100% rename from ConfigFiles/Syslog/rsyslog.conf rename to ProjectCode/ConfigFiles/Syslog/rsyslog.conf diff --git a/ConfigFiles/Systemd/journald.conf b/ProjectCode/ConfigFiles/Systemd/journald.conf similarity index 100% rename from ConfigFiles/Systemd/journald.conf rename to ProjectCode/ConfigFiles/Systemd/journald.conf diff --git a/ConfigFiles/ZSH/tsys-zshrc b/ProjectCode/ConfigFiles/ZSH/tsys-zshrc similarity index 100% rename from ConfigFiles/ZSH/tsys-zshrc rename to ProjectCode/ConfigFiles/ZSH/tsys-zshrc diff --git a/Dell/Server/fixeth.sh b/ProjectCode/Dell/Server/fixeth.sh similarity index 100% rename from Dell/Server/fixeth.sh rename to ProjectCode/Dell/Server/fixeth.sh diff --git a/Dell/Server/omsa.sh b/ProjectCode/Dell/Server/omsa.sh similarity index 100% rename from Dell/Server/omsa.sh rename to ProjectCode/Dell/Server/omsa.sh diff --git a/Dell/fixcpuperf.sh b/ProjectCode/Dell/fixcpuperf.sh similarity index 100% rename from Dell/fixcpuperf.sh rename to ProjectCode/Dell/fixcpuperf.sh diff --git a/Modules/Auth/auth-cloudron-ldap.sh b/ProjectCode/Modules/Auth/auth-cloudron-ldap.sh similarity index 100% rename from Modules/Auth/auth-cloudron-ldap.sh rename to ProjectCode/Modules/Auth/auth-cloudron-ldap.sh diff --git a/RandD/sslStackFromSource.sh b/ProjectCode/Modules/RandD/sslStackFromSource.sh similarity index 100% rename from RandD/sslStackFromSource.sh rename to ProjectCode/Modules/RandD/sslStackFromSource.sh diff --git a/Modules/Security/secharden-2fa.sh b/ProjectCode/Modules/Security/secharden-2fa.sh similarity index 100% rename from Modules/Security/secharden-2fa.sh rename to ProjectCode/Modules/Security/secharden-2fa.sh diff --git a/Modules/Security/secharden-audit-agents.sh b/ProjectCode/Modules/Security/secharden-audit-agents.sh similarity index 100% rename from Modules/Security/secharden-audit-agents.sh rename to ProjectCode/Modules/Security/secharden-audit-agents.sh diff --git a/Modules/Security/secharden-auto-upgrade.sh b/ProjectCode/Modules/Security/secharden-auto-upgrade.sh similarity index 100% rename from Modules/Security/secharden-auto-upgrade.sh rename to ProjectCode/Modules/Security/secharden-auto-upgrade.sh diff --git a/Modules/Security/secharden-scap-stig.sh b/ProjectCode/Modules/Security/secharden-scap-stig.sh similarity index 100% rename from Modules/Security/secharden-scap-stig.sh rename to ProjectCode/Modules/Security/secharden-scap-stig.sh diff --git a/Modules/Security/secharden-ssh.sh b/ProjectCode/Modules/Security/secharden-ssh.sh similarity index 100% rename from Modules/Security/secharden-ssh.sh rename to ProjectCode/Modules/Security/secharden-ssh.sh diff --git a/Modules/Security/secharden-wazuh.sh b/ProjectCode/Modules/Security/secharden-wazuh.sh similarity index 100% rename from Modules/Security/secharden-wazuh.sh rename to ProjectCode/Modules/Security/secharden-wazuh.sh diff --git a/SetupNewSystem.sh b/ProjectCode/SetupNewSystem.sh similarity index 100% rename from SetupNewSystem.sh rename to ProjectCode/SetupNewSystem.sh diff --git a/legacy/profiled-tmux.sh b/ProjectCode/legacy/profiled-tmux.sh similarity index 100% rename from legacy/profiled-tmux.sh rename to ProjectCode/legacy/profiled-tmux.sh diff --git a/legacy/profiled-tsys-shell.sh b/ProjectCode/legacy/profiled-tsys-shell.sh similarity index 100% rename from legacy/profiled-tsys-shell.sh rename to ProjectCode/legacy/profiled-tsys-shell.sh diff --git a/legacy/prox7.sh b/ProjectCode/legacy/prox7.sh similarity index 100% rename from legacy/prox7.sh rename to ProjectCode/legacy/prox7.sh diff --git a/scripts/distro b/ProjectCode/scripts/distro similarity index 100% rename from scripts/distro rename to ProjectCode/scripts/distro diff --git a/scripts/up2date.sh b/ProjectCode/scripts/up2date.sh similarity index 100% rename from scripts/up2date.sh rename to ProjectCode/scripts/up2date.sh