1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00
Jellyfrog 61064dc9fe Cleanup some code (#355)
* Format with isort

* Format with Black

* Fix CRLF

* Format with shellcheck

* Fix some warning

* Fix PHP style

* Dont modifiy check_mk files

* Fixes
2021-03-18 12:24:30 +01:00

63 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (C) 2015 Mark Schouten <mark@tuxis.nl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See http://www.gnu.org/licenses/gpl.txt for the full license
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