diff --git a/seqs/snmp.sh b/seqs/snmp.sh index d8a2c9b..e6a96cc 100755 --- a/seqs/snmp.sh +++ b/seqs/snmp.sh @@ -6,6 +6,14 @@ toolConfigLoc="/etc/snmp" toolConfig="${toolConfigLoc}/snmpd.conf" toolSysUser="Debian-snmp" +step_config() { + ## Apt cmdline option to suppress user interaction + [ $QUIET -ne 0 ] && APTOPT="-y" + + ## Return of non zero value will abort the sequence + return 0 +} + step_1_info() { echo "Install packages for $toolName"; } step_1_alias() { ALIAS="install"; } @@ -471,6 +479,42 @@ step_45() { unboundSudoerLoc="/etc/sudoers.d/snmpunbound" unboundSudoer="Debian-snmp ALL=(ALL) NOPASSWD: /usr/sbin/unbound-control, ${toolConfigLoc}/unbound" +step_46_info() { echo "Extend pi-hole stats"; } +step_46_alias() { ALIAS="pihole"; } +step_46() { + local locExtName="pi-hole" + local locExtUrl="https://github.com/librenms/librenms-agent/raw/master/snmp/pi-hole" + local locExtLoc="${toolConfigLoc}/pi-hole" + + checkExtend $locExtName + [ $? -ne 0 ] && return 0 + + exe apt install $piHoleDeps $APTOPT + + exe wget $locExtUrl -O "${locExtLoc}" + endReturn -o $? "Download $locExtName script failed" + exe chmod +x "$locExtLoc" + + echoseq " [I] Create extend for $locExtName" + addConf -a "extend $locExtName ${locExtLoc}" "$toolConfig" + + if [ $QUIET -ne 0 ]; then + outColor red + echo -e " [W] Check the following in the extend script and restart snmpd:\n" + else + echo " [I] Check the follwing in the extend script:" + fi + echo "(API_AUTH_KEY) Add your pi-hole API key" + echo " (API_URL) and check the API URL" + outColor + if [ $QUIET -eq 0 ]; then + exe read -p "Hit Enter to continue..." + exe vi "$locExtLoc" + exe systemctl restart snmpd.service + fi +} +piholeDeps="jq" + step_100_info() { echo "Notes"; } step_100_alias() { ALIAS="notes"; } step_100() { @@ -534,5 +578,5 @@ checkExtend() { return 0 } -VERSION_SEQREV=14 +VERSION_SEQREV=15 . /usr/local/bin/sequencer.sh