diff --git a/snmp.plg b/snmp.plg index 69bfb12..0e4a5c9 100644 --- a/snmp.plg +++ b/snmp.plg @@ -4,7 +4,7 @@ - + @@ -12,9 +12,10 @@ - - - + + + + @@ -26,6 +27,12 @@ + + + + + + @@ -40,7 +47,15 @@ > -##&name; +**SNMP** + +###2020.04.01 +- Cache downloaded files on USB to support offline installation +- Add /mnt/disk up to 28 from 20 to provide 30 drive support +- Add MD5 for shell scripts +- Format plugin name in README to be in line with other plugins +- More consistent variable use and naming in .plg file +- Clearer install and uninstall logging ###2019.05.28c - Fix icon file @@ -82,32 +97,27 @@ - Initial unRAID V6 release. - - - + + -###SNMP### +**SNMP** Installs and configures SNMP, the Simple Network Management Protocol. SNMP can be used to expose server information to monitoring tools like Observium. - + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +# exit script early if we encounter an error +set -e + perl_path=$(which perl 2>/dev/null) if [ ! -x "$perl_path" ] ; then - echo "This plugin requires perl. The easiest way to get it is to install NerdPack:" + echo "This plugin requires perl. Installation is recommended via NerdPack:" echo "http://lime-technology.com/forum/index.php?topic=37541.0" echo "" echo "Exiting" @@ -118,48 +128,65 @@ fi - - + + &pkghost;/&libnlpkg; &libnlpkgmd5; - - + + &pkghost;/&snmppkg; &snmppkgmd5; - - + + &rawGitURL;/&iconfile; &iconfilemd5; - - -&rawGitURL;/drive_temps.sh + + +&rawGitURL;/&tempsfile; +&tempsmd5; + + + + +&rawGitURL;/&sharefile; +&sharemd5; - - -&rawGitURL;/share_free_space.sh + + + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +# exit script early if we encounter an error +set -e + +echo "" +echo "+==============================================================================" +echo "| Copy files from &usbcfgdir;" +echo "| into &workingdir; and set permissions" +echo "+==============================================================================" + +chmod o+rx &workingdir; + +cp &usbcfgdir;/&iconfile; &workingdir;/&iconfile; +cp &usbcfgdir;/&tempsfile; &workingdir;/&tempsfile; +cp &usbcfgdir;/&sharefile; &workingdir;/&sharefile; + +chmod a+x &workingdir;/&tempsfile; +chmod a+x &workingdir;/&sharefile; + +echo "Copy complete!" +exit 0 + - - + + rocommunity &community; syslocation &location; @@ -184,46 +211,43 @@ disk /mnt/disk17 disk /mnt/disk18 disk /mnt/disk19 disk /mnt/disk20 +disk /mnt/disk21 +disk /mnt/disk22 +disk /mnt/disk23 +disk /mnt/disk24 +disk /mnt/disk25 +disk /mnt/disk26 +disk /mnt/disk27 +disk /mnt/disk28 disk /mnt/cache -extend disktemp &plugdir;/drive_temps.sh -extend sharefree &plugdir;/share_free_space.sh +extend disktemp &workingdir;/&tempsfile; +extend sharefree &workingdir;/&sharefile; - + -chmod o+rx &plugdir; - - +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +# exit script early if we encounter an error +set -e - - - +echo "" echo "+==============================================================================" echo "| Updating /etc/rc.d/rc.snmpd to use our config file, and to reduce logging" echo "+==============================================================================" bash /etc/rc.d/rc.snmpd stop -sed -i.old -e 's#/etc/snmp/snmpd.conf#&plugdir;/snmpd.conf#g' /etc/rc.d/rc.snmpd +sed -i.old -e 's#/etc/snmp/snmpd.conf#&workingdir;/snmpd.conf#g' /etc/rc.d/rc.snmpd sed -i.old -e 's#OPTIONS="#OPTIONS="-LF w /var/log/snmpd.log #g' /etc/rc.d/rc.snmpd -chmod a+x &plugdir;/drive_temps.sh -chmod a+x &plugdir;/share_free_space.sh - bash /etc/rc.d/rc.snmpd start echo "" -echo "" - echo "+==============================================================================" -echo "| Testing SNMP by listing mounts" +echo "| Testing SNMP by listing mounts, /boot should be present" echo "+==============================================================================" RESULTS=$(snmpwalk -v 1 localhost -c public hrFSMountPoint 2>&1) @@ -240,12 +264,12 @@ else fi echo "" -echo "Here's what drive temperatures look like:" +echo "Here are how drive temperatures look:" echo snmpwalk -v 2c localhost -c public 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp"' snmpwalk -v 2c localhost -c public 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."disktemp"' echo "" -echo "Here's what share free space looks like:" +echo "Here is how share free space looks:" echo snmpwalk -v 2c localhost -c public 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree"' snmpwalk -v 2c localhost -c public 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."sharefree"' @@ -256,9 +280,7 @@ exit 0 - + echo "" @@ -270,37 +292,43 @@ echo "" - + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +# exit script early if we encounter an error +set -e + +echo "" echo "+==============================================================================" echo "| Uninstalling packages" echo "+==============================================================================" -# Delete the package, and any old package files too -rm -f $(ls &pkgdir;/&name;*.txz 2>/dev/null) - # Uninstall the package removepkg $(basename &snmppkg; .txz) | grep -v -e ' --> Deleting' -# Don't uninstall the prerequisites, in case some other plug is using them. On reboot, they'll get "removed" if no plugin -# needs them, or will be re-downloaded and reinstalled by some plugin that does need them. -#removepkg $(basename &libnlpkg; .txz) | grep -v -e ' --> Deleting' +# Uninstall prerequisites in the reverse order of their installation +# NOTE: Skipping package removal of prereqs in case other plugins depend on them -echo "" -echo "" +echo "" echo "+==============================================================================" -echo "| Deleting &plugdir;" +echo "| Deleting &workingdir;" +echo "| Deleting &usbcfgdir;" echo "+==============================================================================" +# Delete the USB plugin folder storing cached files +rm -rf &usbcfgdir; + # Remove plugin. -rm -rf &plugdir; +rm -rf &workingdir; echo "" +echo "-----------------------------------------------------------" +echo " &name; has been uninstalled." +echo "-----------------------------------------------------------" echo "" +