snmp.sh - adding pihole extend

This commit is contained in:
2022-03-25 09:02:34 +01:00
parent 471da5f2d4
commit cd19dfcc98

View File

@@ -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