mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
net-snmp: make addon configurable through gui settings
This commit is contained in:
parent
94cffa28cd
commit
e82bde9920
@ -1,3 +1,6 @@
|
||||
101
|
||||
- make addon configurable
|
||||
|
||||
100
|
||||
- Initial addon
|
||||
- net-snmp 5.7.3
|
||||
|
@ -18,12 +18,12 @@
|
||||
|
||||
PKG_NAME="net-snmp"
|
||||
PKG_VERSION="5.7.3"
|
||||
PKG_REV="100"
|
||||
PKG_REV="101"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="BSD"
|
||||
PKG_SITE="http://www.net-snmp.org"
|
||||
PKG_URL="http://sourceforge.net/projects/net-snmp/files/$PKG_NAME/$PKG_VERSION/$PKG_NAME-$PKG_VERSION.tar.gz"
|
||||
PKG_DEPENDS_TARGET="toolchain"
|
||||
PKG_DEPENDS_TARGET="toolchain libnl"
|
||||
PKG_SECTION="service"
|
||||
PKG_SHORTDESC="Simple Network Management Protocol utilities."
|
||||
PKG_LONGDESC="Simple Network Management Protocol (SNMP) is a widely used protocol for monitoring the health and welfare of network equipment."
|
||||
@ -39,14 +39,22 @@ PKG_CONFIGURE_OPTS_TARGET="--with-defaults \
|
||||
--disable-debugging \
|
||||
--disable-deprecated \
|
||||
--disable-snmptrapd-subagent \
|
||||
--disable-perl-cc-checks \
|
||||
--with-perl-modules=no \
|
||||
--enable-mini-agent \
|
||||
--disable-scripts \
|
||||
--enable-static=no \
|
||||
--enable-shared=yes \
|
||||
--with-logfile=/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID}/ \
|
||||
--with-persistent-directory=/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID}/ \
|
||||
--disable-embedded-perl"
|
||||
--enable-mini-agent \
|
||||
--with-nl \
|
||||
--with-logfile=/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID} \
|
||||
--with-persistent-directory=/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID} \
|
||||
--sysconfdir=/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID} \
|
||||
--prefix=/storage/.kodi/addons/${PKG_ADDON_ID} \
|
||||
--exec-prefix=/storage/.kodi/addons/${PKG_ADDON_ID} \
|
||||
--datarootdir=/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID}/share \
|
||||
--bindir=/storage/.kodi/addons/${PKG_ADDON_ID}/bin \
|
||||
--sbindir=/storage/.kodi/addons/${PKG_ADDON_ID}/bin \
|
||||
--libdir=/storage/.kodi/addons/${PKG_ADDON_ID}/lib \
|
||||
--disable-embedded-perl \
|
||||
--with-sysroot=$SYSROOT_PREFIX"
|
||||
|
||||
make_target() {
|
||||
make
|
||||
@ -57,8 +65,11 @@ makeinstall_target() {
|
||||
}
|
||||
|
||||
addon() {
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID
|
||||
cp -r $PKG_BUILD/.$TARGET_NAME/usr/bin $PKG_BUILD/.$TARGET_NAME/usr/lib $PKG_BUILD/.$TARGET_NAME/usr/share $ADDON_BUILD/$PKG_ADDON_ID/
|
||||
cp $PKG_BUILD/.$TARGET_NAME/usr/sbin/snmpd $ADDON_BUILD/$PKG_ADDON_ID/bin/snmpd
|
||||
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/lib
|
||||
cp -r $PKG_BUILD/.$TARGET_NAME/storage/.kodi/addons/${PKG_ADDON_ID}/bin $PKG_BUILD/.$TARGET_NAME/storage/.kodi/userdata/addon_data/${PKG_ADDON_ID}/share $ADDON_BUILD/$PKG_ADDON_ID/
|
||||
#Do not copy symlinks
|
||||
find $PKG_BUILD/.$TARGET_NAME/storage/.kodi/addons/${PKG_ADDON_ID}/lib/ -type f -name '*.so.*' -exec cp '{}' $ADDON_BUILD/$PKG_ADDON_ID/lib/ \;
|
||||
#remove all but major version from so file
|
||||
for f in $ADDON_BUILD/$PKG_ADDON_ID/lib/*.so.* ; do mv "$f" "${f%.*.*}" ; done
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
--- a/snmplib/read_config.c 2014-12-08 14:23:22.000000000 -0600
|
||||
+++ b/snmplib/read_config.c 2017-03-30 12:21:16.351042803 -0500
|
||||
@@ -1618,7 +1618,7 @@
|
||||
* save a warning header to the top of the new file
|
||||
*/
|
||||
snprintf(fileold, sizeof(fileold),
|
||||
- "%s%s# Please save normal configuration tokens for %s in SNMPCONFPATH/%s.conf.\n# Only \"createUser\" tokens should be placed here by %s administrators.\n%s",
|
||||
+ "%s%s# Please save normal configuration tokens for %s in /storage/.kodi/userdata/addon_data/service.net-snmp/share/snmp/%s.conf.\n# Only \"createUser\" tokens should be placed here by %s administrators.\n%s",
|
||||
"#\n# net-snmp (or ucd-snmp) persistent data file.\n#\n############################################################################\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n",
|
||||
"#\n# **** DO NOT EDIT THIS FILE ****\n#\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n############################################################################\n#\n# DO NOT STORE CONFIGURATION ENTRIES HERE.\n",
|
||||
type, type, type,
|
@ -0,0 +1,15 @@
|
||||
--- a/net-snmp-create-v3-user.in 2014-12-08 14:23:22.000000000 -0600
|
||||
+++ b/net-snmp-create-v3-user.in 2017-03-30 13:20:56.336794994 -0500
|
||||
@@ -28,10 +28,8 @@
|
||||
NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
|
||||
fi
|
||||
|
||||
-if @PSCMD@ | egrep ' snmpd *$' > /dev/null 2>&1 ; then
|
||||
- echo "Apparently at least one snmpd demon is already running."
|
||||
- echo "You must stop them in order to use this command."
|
||||
- exit 1
|
||||
+if @PSCMD@ | egrep 'snmpd'> /dev/null 2>&1 ; then
|
||||
+ systemctl stop service.net-snmp.service
|
||||
fi
|
||||
|
||||
Aalgorithm="MD5"
|
@ -24,4 +24,4 @@ ADDON_ID=service.net-snmp
|
||||
ADDON_DIR="$HOME/.kodi/addons/$ADDON_ID"
|
||||
ADDON_HOME="$HOME/.kodi/userdata/addon_data/$ADDON_ID"
|
||||
|
||||
$ADDON_DIR/bin/snmpd -LS0-6d -c $ADDON_DIR/snmpd.conf -M /storage/.kodi/addons/service.net-snmp/share/snmp/mibs -p /var/run/snmpd.pid
|
||||
$ADDON_DIR/bin/snmpd -f -LS0-6d -c $ADDON_HOME/share/snmp/snmpd.conf -M $ADDON_DIR/share/snmp/mibs -p /var/run/snmpd.pid
|
||||
|
@ -15,3 +15,63 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
import xbmc
|
||||
import xbmcvfs
|
||||
import xbmcaddon
|
||||
from os import system
|
||||
|
||||
|
||||
class MyMonitor(xbmc.Monitor):
|
||||
def __init__(self, *args, **kwargs):
|
||||
xbmc.Monitor.__init__(self)
|
||||
|
||||
def onSettingsChanged(self):
|
||||
writeconfig()
|
||||
|
||||
|
||||
# addon
|
||||
__addon__ = xbmcaddon.Addon(id='service.net-snmp')
|
||||
__addonpath__ = xbmc.translatePath(__addon__.getAddonInfo('path'))
|
||||
__addonhome__ = xbmc.translatePath(__addon__.getAddonInfo('profile'))
|
||||
if not xbmcvfs.exists(xbmc.translatePath(__addonhome__ + 'share/snmp/')):
|
||||
xbmcvfs.mkdirs(xbmc.translatePath(__addonhome__ + 'share/snmp/'))
|
||||
config = xbmc.translatePath(__addonhome__ + 'share/snmp/snmpd.conf')
|
||||
persistent = xbmc.translatePath(__addonhome__ + 'snmpd.conf')
|
||||
|
||||
|
||||
def writeconfig():
|
||||
system("systemctl stop service.net-snmp.service")
|
||||
community = __addon__.getSetting("COMMUNITY")
|
||||
location = __addon__.getSetting("LOCATION")
|
||||
contact = __addon__.getSetting("CONTACT")
|
||||
snmpversion = __addon__.getSetting("SNMPVERSION")
|
||||
|
||||
if xbmcvfs.exists(persistent):
|
||||
xbmcvfs.delete(persistent)
|
||||
|
||||
file = xbmcvfs.File(config, 'w')
|
||||
file.write('com2sec local default {}\n'.format(community))
|
||||
file.write('group localgroup {} local\n'.format(snmpversion))
|
||||
file.write('access localgroup "" any noauth exact all all none\n')
|
||||
file.write('view all included .1 80\n')
|
||||
file.write('syslocation {}\n'.format(location))
|
||||
file.write('syscontact {}\n'.format(contact))
|
||||
file.write('dontLogTCPWrappersConnects yes\n')
|
||||
file.close()
|
||||
|
||||
if snmpversion == "v3":
|
||||
snmppassword = __addon__.getSetting("SNMPPASSWORD")
|
||||
snmpuser = __addon__.getSetting("SNMPUSER")
|
||||
system("net-snmp-config --create-snmpv3-user -a {0} {1}".format(snmppassword,snmpuser))
|
||||
|
||||
system("systemctl start service.net-snmp.service")
|
||||
|
||||
|
||||
if not xbmcvfs.exists(config):
|
||||
writeconfig()
|
||||
|
||||
monitor = MyMonitor()
|
||||
while not monitor.abortRequested():
|
||||
if monitor.waitForAbort():
|
||||
break
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<strings>
|
||||
<!-- net-snmp -->
|
||||
<string id="32000">General</string>
|
||||
<string id="32001">Community</string>
|
||||
<string id="32002">Location</string>
|
||||
<string id="32003">Contact</string>
|
||||
<string id="32004">SNMP Version</string>
|
||||
<string id="32005">SNMP User</string>
|
||||
<string id="32006">SNMP Password</string>
|
||||
</strings>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<settings>
|
||||
<!-- net-snmp -->
|
||||
<category label="32000">
|
||||
<setting label="32001" id="COMMUNITY" type="text" default="libreelec"/>
|
||||
<setting label="32002" id="LOCATION" type="text" default="HOME"/>
|
||||
<setting label="32003" id="CONTACT" type="text" default="root@localhost"/>
|
||||
<setting label="32004" id="SNMPVERSION" type="labelenum" values="v1|v2c|v3" default="v2c"/>
|
||||
<setting label="32005" id="SNMPUSER" type="text" default="user"/>
|
||||
<setting label="32006" id="SNMPPASSWORD" type="text" default="password"/>
|
||||
</category>
|
||||
</settings>
|
@ -1,10 +0,0 @@
|
||||
com2sec local default libreelec
|
||||
group localgroup v2c local
|
||||
access localgroup "" any noauth exact all all none
|
||||
|
||||
view all included .1 80
|
||||
|
||||
syslocation HOME
|
||||
syscontact root@libreelec
|
||||
|
||||
dontLogTCPWrappersConnects yes
|
@ -4,9 +4,11 @@ After=network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
Type=notification
|
||||
ExecStart=/bin/sh -c "exec sh /storage/.kodi/addons/service.net-snmp/bin/snmpd.start"
|
||||
ExecStop=/bin/sh -c "exec sh /storage/.kodi/addons/service.net-snmp/bin/snmpd.stop"
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
PIDFile=/var/run/snmpd.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=kodi.target
|
||||
|
Loading…
x
Reference in New Issue
Block a user