2013-09-27 11:16:35 +02:00
|
|
|
#!/bin/sh
|
|
|
|
prefix=@prefix@
|
|
|
|
exec_prefix=@exec_prefix@
|
|
|
|
sbindir=@sbindir@
|
|
|
|
bindir=@bindir@
|
|
|
|
sysconfdir=@sysconfdir@
|
|
|
|
localstatedir=@localstatedir@
|
|
|
|
|
|
|
|
ICINGA2CONFDIR=@sysconfdir@/icinga2
|
|
|
|
|
|
|
|
TOOL=$(basename -- $0)
|
|
|
|
|
|
|
|
if [ "$TOOL" != "i2enfeature" -a "$TOOL" != "i2disfeature" ]; then
|
|
|
|
echo "Invalid tool name ($TOOL). Should be 'i2enfeature' or 'i2disfeature'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Syntax: $0 <feature>"
|
|
|
|
|
|
|
|
if [ "$TOOL" = "i2enfeature" ]; then
|
|
|
|
echo "Enables the specified feature."
|
|
|
|
else
|
|
|
|
echo "Disables the specified feature."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2013-09-27 13:56:11 +02:00
|
|
|
echo -n "Available features: "
|
2013-09-27 11:16:35 +02:00
|
|
|
|
2013-09-27 11:22:18 +02:00
|
|
|
for file in $ICINGA2CONFDIR/features-available/*.conf; do
|
2013-09-27 11:16:35 +02:00
|
|
|
echo -n $(basename -- $file .conf)
|
|
|
|
done
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
FEATURE=$1
|
|
|
|
|
2013-09-27 11:22:18 +02:00
|
|
|
if [ ! -e $ICINGA2CONFDIR/features-available/$FEATURE.conf ]; then
|
2013-09-27 11:16:35 +02:00
|
|
|
echo "The feature '$FEATURE' does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$TOOL" = "i2enfeature" ]; then
|
2013-09-27 11:22:18 +02:00
|
|
|
if [ -e $ICINGA2CONFDIR/features-enabled/$FEATURE.conf ]; then
|
2013-09-27 11:16:35 +02:00
|
|
|
echo "The feature '$FEATURE' is already enabled."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2013-09-27 11:22:18 +02:00
|
|
|
ln -s ../features-available/$FEATURE.conf $ICINGA2CONFDIR/features-enabled/
|
2013-09-27 11:16:35 +02:00
|
|
|
|
|
|
|
echo "Module '$FEATURE' was enabled."
|
|
|
|
elif [ "$TOOL" = "i2disfeature" ]; then
|
2013-09-27 11:22:18 +02:00
|
|
|
if [ ! -e $ICINGA2CONFDIR/features-enabled/$FEATURE.conf ]; then
|
2013-09-27 11:16:35 +02:00
|
|
|
echo "The feature '$FEATURE' is already disabled."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2013-09-27 11:22:18 +02:00
|
|
|
rm -f $ICINGA2CONFDIR/features-enabled/$FEATURE.conf
|
2013-09-27 11:16:35 +02:00
|
|
|
|
|
|
|
echo "Module '$FEATURE' was disabled."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Make sure to restart Icinga 2 for these changes to take effect."
|
|
|
|
exit 0
|