From 5185ad0c51f1df15c6e96f055629a425143d6841 Mon Sep 17 00:00:00 2001 From: WickedYoda <68271168+wickedyoda@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:31:40 -0600 Subject: [PATCH] Updates scripts --- .idea/.gitignore | 8 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/public-setupfiles.iml | 12 +++ .idea/vcs.xml | 6 ++ openwrt_scripts/openwrt_full-upgrade.sh | 42 ++++++++++ snmp/setup_snmp_openwrt_publicv2.sh | 76 +++++++++++++++++++ 8 files changed, 162 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/public-setupfiles.iml create mode 100644 .idea/vcs.xml create mode 100644 openwrt_scripts/openwrt_full-upgrade.sh create mode 100644 snmp/setup_snmp_openwrt_publicv2.sh diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8e026d9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/public-setupfiles.iml b/.idea/public-setupfiles.iml new file mode 100644 index 0000000..5ed0139 --- /dev/null +++ b/.idea/public-setupfiles.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/openwrt_scripts/openwrt_full-upgrade.sh b/openwrt_scripts/openwrt_full-upgrade.sh new file mode 100644 index 0000000..3c32f06 --- /dev/null +++ b/openwrt_scripts/openwrt_full-upgrade.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Ensure the script is run as root +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root. Use sudo or run as root." + exit 1 +fi + +echo "Starting full OpenWRT upgrade using opkg..." + +# Step 1: Update package lists +echo "Updating package lists..." +opkg update + +# Step 2: List upgradable packages +echo "Listing upgradable packages..." +opkg list-upgradable + +# Step 3: Upgrade all installed packages +echo "Upgrading installed packages..." +opkg list-upgradable | cut -f1 -d ' ' | xargs -r opkg upgrade + +# Step 4: Remove unnecessary packages +echo "Removing unnecessary packages..." +opkg remove --autoremove + +# Step 5: Clean package cache +echo "Cleaning up package cache..." +opkg clean + +# Step 6: Restart the device (optional) +echo "Upgrade complete. A reboot is recommended." +read -p "Do you want to reboot now? (y/N): " REBOOT +if [ "$REBOOT" = "y" ] || [ "$REBOOT" = "Y" ]; then + echo "Rebooting..." + reboot +else + echo "Reboot skipped. You may need to restart manually." +fi + +echo "OpenWRT full upgrade completed!" + diff --git a/snmp/setup_snmp_openwrt_publicv2.sh b/snmp/setup_snmp_openwrt_publicv2.sh new file mode 100644 index 0000000..8ab43fd --- /dev/null +++ b/snmp/setup_snmp_openwrt_publicv2.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +# Ensure the script is run as root +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root. Use sudo or run as root." + exit 1 +fi + +echo "Starting SNMPv2 configuration on OpenWRT..." + +# Install SNMP if not installed +opkg update +opkg install snmpd + +# Define SNMP configuration file location +SNMP_CONFIG="/etc/config/snmpd" + +# Backup existing SNMP configuration +if [ -f "$SNMP_CONFIG" ]; then + echo "Backing up existing SNMP configuration..." + cp "$SNMP_CONFIG" "$SNMP_CONFIG.bak" +fi + +# Create SNMPv2 configuration with public community +echo "Configuring SNMPv2 with public community..." + +cat < "$SNMP_CONFIG" +config system + option enable '1' + +config agent + option agentaddress 'udp:161' + +config com2sec + option secname 'public' + option source 'default' + option community 'public' + +config group + option groupname 'publicGroup' + option securitymodel 'v2c' + option secname 'public' + +config view + option viewname 'all' + option type 'included' + option oid '.1' + +config access + option groupname 'publicGroup' + option securitymodel 'v2c' + option context 'none' + option level 'noAuthNoPriv' + option prefix 'exact' + option read 'all' + option write 'none' + option notify 'none' +EOL + +# Restart the SNMP service to apply changes +echo "Restarting SNMP service..." +/etc/init.d/snmpd restart + +# Verify if SNMP is running +if pgrep snmpd > /dev/null; then + echo "SNMP service is running." +else + echo "Failed to start SNMP service." + exit 1 +fi + +# Test SNMPv2 configuration +echo "Testing SNMPv2 configuration with snmpwalk..." +snmpwalk -v2c -c public localhost system + +echo "SNMPv2 configuration on OpenWRT completed successfully!" \ No newline at end of file