From 83fd3cf03aa1f7dc07393daf5a0ab38219b82dc1 Mon Sep 17 00:00:00 2001 From: WickedYoda <68271168+wickedyoda@users.noreply.github.com> Date: Thu, 23 Jan 2025 18:46:16 -0600 Subject: [PATCH] d d --- snmp/Setup_snmp_macos.sh | 66 +++++++++++++++++++++++++++++ snmp/setup_snmp_openwrt.sh | 85 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 snmp/Setup_snmp_macos.sh create mode 100644 snmp/setup_snmp_openwrt.sh diff --git a/snmp/Setup_snmp_macos.sh b/snmp/Setup_snmp_macos.sh new file mode 100644 index 0000000..0e5d1e7 --- /dev/null +++ b/snmp/Setup_snmp_macos.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Check if the script is running on macOS +if [[ "$(uname)" != "Darwin" ]]; then + echo "This script is designed to run on macOS." + exit 1 +fi + +# Check if Homebrew is installed +if ! command -v brew &> /dev/null; then + echo "Homebrew is not installed. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +# Install SNMP tools +echo "Installing SNMP tools via Homebrew..." +brew install net-snmp + +# Prompt for user input +echo "Enter the SNMPv3 username (e.g., admin):" +read SNMP_USER +echo "Enter the SNMPv3 password:" +read -s SNMP_PASSWORD +echo "Re-enter the SNMPv3 password:" +read -s SNMP_PASSWORD_CONFIRM + +# Verify password confirmation +if [ "$SNMP_PASSWORD" != "$SNMP_PASSWORD_CONFIRM" ]; then + echo "Passwords do not match. Exiting." + exit 1 +fi + +echo "Enter the system location (e.g., Office):" +read SYS_LOCATION +echo "Enter the system contact (e.g., admin@example.com):" +read SYS_CONTACT + +# Configure SNMPv3 +echo "Configuring SNMPv3..." +SNMP_CONF="/usr/local/etc/snmp/snmpd.conf" +sudo mkdir -p /usr/local/etc/snmp + +cat < /etc/config/snmpd +config agent + option agentaddress 161 + option agentxsocket /var/agentx/master + +config view + option name all + option type included + option subtree .1 + +config access + option groupname notConfigGroup + option context "" + option version v3 + option level authPriv + option readview all + option writeview none + option notifyview none + +config user + option name $SNMP_USER + option authproto MD5 + option authpass $SNMP_PASSWORD + option privproto AES + option privpass $SNMP_PASSWORD + +config system + option location "$SYS_LOCATION" + option contact "$SYS_CONTACT" +EOT + +# Restart and enable SNMP service +echo "Starting and enabling SNMP service..." +/etc/init.d/snmpd enable +/etc/init.d/snmpd start + +# Verify SNMP configuration +echo "Verifying SNMP service..." +snmpwalk -v3 -u $SNMP_USER -a MD5 -A $SNMP_PASSWORD -x AES -X $SNMP_PASSWORD -l authPriv localhost + +echo "SNMPv3 installation and configuration complete on OpenWrt." \ No newline at end of file