]> granicus.if.org Git - icinga2/blob - tools/icinga2-enable-feature.cmake
Add cmake build files.
[icinga2] / tools / icinga2-enable-feature.cmake
1 #!/bin/sh
2 ICINGA2CONFDIR=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2
3
4 TOOL=$(basename -- $0)
5
6 if [ "$TOOL" != "icinga2-enable-feature" -a "$TOOL" != "icinga2-disable-feature" ]; then
7         echo "Invalid tool name ($TOOL). Should be 'icinga2-enable-feature' or 'icinga2-disable-feature'."
8         exit 1
9 fi
10
11 if [ -z "$1" ]; then
12         echo "Syntax: $0 <feature>"
13
14         if [ "$TOOL" = "icinga2-enable-feature" ]; then
15                 echo "Enables the specified feature."
16         else
17                 echo "Disables the specified feature."
18         fi
19
20         echo
21         echo -n "Available features: "
22
23         for file in $ICINGA2CONFDIR/features-available/*.conf; do
24                 echo -n "$(basename -- $file .conf) "
25         done
26
27         echo
28
29         exit 1
30 fi
31
32 FEATURE=$1
33
34 if [ ! -e $ICINGA2CONFDIR/features-available/$FEATURE.conf ]; then
35         echo "The feature '$FEATURE' does not exist."
36         exit 1
37 fi
38
39 if [ "$TOOL" = "icinga2-enable-feature" ]; then
40         if [ -e $ICINGA2CONFDIR/features-enabled/$FEATURE.conf ]; then
41                 echo "The feature '$FEATURE' is already enabled."
42                 exit 0
43         fi
44
45         ln -s ../features-available/$FEATURE.conf $ICINGA2CONFDIR/features-enabled/
46
47         echo "Module '$FEATURE' was enabled."
48 elif [ "$TOOL" = "icinga2-disable-feature" ]; then
49         if [ ! -e $ICINGA2CONFDIR/features-enabled/$FEATURE.conf ]; then
50                 echo "The feature '$FEATURE' is already disabled."
51                 exit 0
52         fi
53
54         rm -f $ICINGA2CONFDIR/features-enabled/$FEATURE.conf
55
56         echo "Module '$FEATURE' was disabled."
57 fi
58
59 echo "Make sure to restart Icinga 2 for these changes to take effect."
60 exit 0