]> granicus.if.org Git - icinga2/commitdiff
Add missing file.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 27 Sep 2013 08:47:46 +0000 (10:47 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 27 Sep 2013 08:47:46 +0000 (10:47 +0200)
tools/i2modconf.in [new file with mode: 0644]

diff --git a/tools/i2modconf.in b/tools/i2modconf.in
new file mode 100644 (file)
index 0000000..48edba1
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+sbindir=@sbindir@
+bindir=@bindir@
+sysconfdir=@sysconfdir@
+localstatedir=@localstatedir@
+
+ICINGA2CONFDIR=@sysconfdir@/icinga2
+
+TOOL=$(basename -- $0)
+
+if [ "$TOOL" != "i2enmod" -a "$TOOL" != "i2dismod" ]; then
+       echo "Invalid tool name ($TOOL). Should be 'i2enmod' or 'i2dismod'."
+       exit 1
+fi
+
+if [ -z "$1" ]; then
+       echo "Syntax: $0 <module>"
+
+       if [ "$TOOL" = "i2enmod" ]; then
+               echo "Enables the specified module."
+       else
+               echo "Disables the specified module."
+       fi
+
+       echo
+       echo -n "Available modules: "
+
+       for file in $ICINGA2CONFDIR/mods-available/*.conf; do
+               echo -n $(basename -- $file .conf)
+       done
+
+       echo
+
+       exit 1
+fi
+
+MOD=$1
+
+if [ ! -e $ICINGA2CONFDIR/mods-available/$MOD.conf ]; then
+       echo "The module '$MOD' does not exist."
+       exit 1
+fi
+
+if [ "$TOOL" = "i2enmod" ]; then
+       if [ -e $ICINGA2CONFDIR/mods-enabled/$MOD.conf ]; then
+               echo "The module '$MOD' is already enabled."
+               exit 0
+       fi
+
+       ln -s ../mods-available/$MOD.conf $ICINGA2CONFDIR/mods-enabled/
+
+       echo "Module '$MOD' was enabled."
+elif [ "$TOOL" = "i2dismod" ]; then
+       if [ ! -e $ICINGA2CONFDIR/mods-enabled/$MOD.conf ]; then
+               echo "The module '$MOD' is already disabled."
+               exit 0
+       fi
+
+       rm -f $ICINGA2CONFDIR/mods-enabled/$MOD.conf
+
+       echo "Module '$MOD' was disabled."
+fi
+
+echo "Make sure to restart Icinga 2 for these changes to take effect."
+exit 0