Files
init.sh/modules/patch_snmp.sh
2022-12-17 20:19:03 +01:00

50 lines
1.6 KiB
Bash

# ------------------------------------------------------------------------------
# SNMP monitoring conf
# This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
export VER_patch_snmp="0.1.2"
export DEP_patch_snmp="install_pkg"
patch_snmp()
{
pkginst snmpd
prnt I "Configuring SNMP daemon..."
backup_dist /etc/snmp/snmpd.conf /etc/default/snmpd \
/lib/systemd/system/snmpd.service /etc/init.d/snmpd
install_file snmpd/snmpd.conf /etc/snmp/snmpd.conf
tag_file /etc/snmp/snmpd.conf
# No longer required with Debian >= 11 or Devuan >= 4
if [[ ($SYS_DIST == 'debian' && $SYS_VER -lt 11) ||
($SYS_DIST == 'devuan' && $SYS_VER -lt 4) ]]; then
install_file snmpd/snmpd.init /etc/init.d/snmpd
fi
install_file snmpd/snmpd.default /etc/default/snmpd
tag_file /etc/default/snmpd
if [[ -e /lib/systemd/system/snmpd.service ]]; then
install_file snmpd/snmpd.service /lib/systemd/system/snmpd.service
if command -v systemctl &> /dev/null; then
systemctl daemon-reload
fi
fi
svc_restart snmpd
}
precheck_patch_snmp()
{
file_must_exists snmpd/snmpd.{conf,default}
if [[ -e /lib/systemd/system/snmpd.service ]]; then
file_must_exists snmpd/snmpd.service
fi
}
export -f patch_snmp
export -f precheck_patch_snmp
# EOF