check_oracle_health: update to 1.9
[omd.git] / packages / check_mk / MULTISITE_COOKIE_AUTH.hook
blobc6b04f8563a66f0fad975e5ec901348829228903
1 #!/bin/bash
3 # Alias: Use multisite cookie auth
4 # Menu: Web GUI
5 # Description:
6 # Multisite provides a cookie based authentication which can be
7 # used as alternative to the default basic authentication.
8 # The cookie authentication is done by multisite. The cookie can
9 # also be used by other addons like NagVis. This is switched
10 # using this option.
12 case "$1" in
13 default)
14 echo "off"
16 choices)
17 echo "on: use cookie authentication"
18 echo "off: use basic authentication"
20 set)
21 APACHE_CFG=${OMD_ROOT}/etc/apache/conf.d/cookie_auth.conf
22 NAGVIS_CFG=${OMD_ROOT}/etc/nagvis/conf.d/cookie_auth.ini.php
23 PNP_CFG=${OMD_ROOT}/etc/pnp4nagios/config.d/cookie_auth.php
24 WIKI_CFG=${OMD_ROOT}/etc/dokuwiki/cookie_auth.php
25 if [ "$2" == "on" ]; then
26 cat > $APACHE_CFG <<EOF
27 <LocationMatch ^/${OMD_SITE}/(omd|wiki|nagvis|check_mk|pnp4nagios)>
28 Order allow,deny
29 Allow from all
30 Satisfy any
31 </LocationMatch>
32 EOF
34 cat > $NAGVIS_CFG <<EOF
35 [global]
36 logonmodule="LogonMultisite"
37 logon_multisite_htpasswd="/omd/sites/$OMD_SITE/etc/htpasswd"
38 logon_multisite_secret="/omd/sites/$OMD_SITE/etc/auth.secret"
39 logon_multisite_serials="/omd/sites/$OMD_SITE/etc/auth.serials"
40 EOF
42 cat > $WIKI_CFG <<EOF
43 <?php
44 // Created by OMD hook MULTISITE_COOKIE_AUTH
46 \$conf['useacl'] = 1;
47 \$conf['authtype'] = 'multisite';
48 \$conf['superuser'] = '@admin';
49 \$conf['multisite']['authfile'] = '/omd/sites/$OMD_SITE/var/check_mk/wato/auth/auth.php';
50 \$conf['multisite']['auth_secret'] = '/omd/sites/$OMD_SITE/etc/auth.secret';
51 \$conf['multisite']['auth_serials'] = '/omd/sites/$OMD_SITE/etc/auth.serials';
52 \$conf['multisite']['htpasswd'] = '/omd/sites/$OMD_SITE/etc/htpasswd';
54 EOF
56 cat > $PNP_CFG <<EOF
57 <?php
58 // Created by OMD hook MULTISITE_COOKIE_AUTH
60 // Using the multisite cookie based authentication when no
61 // REMOTE_USER available.
63 \$conf['auth_multisite_enabled'] = TRUE;
64 \$conf['auth_multisite_htpasswd'] = '/omd/sites/$OMD_SITE/etc/htpasswd';
65 \$conf['auth_multisite_secret'] = '/omd/sites/$OMD_SITE/etc/auth.secret';
66 \$conf['auth_multisite_serials'] = '/omd/sites/$OMD_SITE/etc/auth.serials';
67 \$conf['auth_multisite_login_url'] = '/$OMD_SITE/check_mk/login.py';
69 EOF
70 else
71 [ -f $APACHE_CFG ] && rm $APACHE_CFG
72 [ -f $NAGVIS_CFG ] && rm $NAGVIS_CFG
73 [ -f $PNP_CFG ] && rm $PNP_CFG
74 [ -f $WIKI_CFG ] && rm $WIKI_CFG
77 esac