forked from librenms/librenms-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_enplug
executable file
·62 lines (50 loc) · 1.29 KB
/
mk_enplug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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