mirror of
https://github.com/librenms/librenms-agent.git
synced 2024-05-09 09:54:52 +00:00
Place all plugins in a repo-dir and add mk_enplug to enable plugins
This commit is contained in:
48
mk_enplug
Executable file
48
mk_enplug
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
plugdir=/usr/lib/check_mk_agent/plugins
|
||||
repodir=/usr/lib/check_mk_agent/repo
|
||||
|
||||
findscripts() {
|
||||
find ${repodir} -type f | sed -e "s#$repodir/##g"
|
||||
}
|
||||
|
||||
script_enabled() {
|
||||
s=$1
|
||||
|
||||
if [ -L ${plugdir}/${s} ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
}
|
||||
|
||||
enable_script() {
|
||||
s=$1
|
||||
|
||||
ln -s ${repodir}/${s} ${plugdir}/${s}
|
||||
echo "Enabled $s"
|
||||
}
|
||||
|
||||
scripts=$(findscripts)
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
s=$1
|
||||
else
|
||||
echo "Which plugin do you want to enable?"
|
||||
echo ${scripts}
|
||||
read s
|
||||
fi
|
||||
|
||||
echo "Enabling $s"
|
||||
|
||||
if [ ! -z "$s" ]; then
|
||||
if [ ! -r ${repodir}/${s} ]; then
|
||||
echo "Plugin $s does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ `script_enabled $s` != "yes" ]; then
|
||||
enable_script $s
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user