From 6970c282922fa81d7e92a315eefbb4a48d125846 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 27 Sep 2013 10:47:46 +0200 Subject: [PATCH] Add missing file. --- tools/i2modconf.in | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tools/i2modconf.in diff --git a/tools/i2modconf.in b/tools/i2modconf.in new file mode 100644 index 000000000..48edba1c7 --- /dev/null +++ b/tools/i2modconf.in @@ -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 " + + 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 -- 2.40.0