Add Autoconf based installation with most parameters

configure allows to set the authentication backend to internal (or ldap)
and to set connection details for authentication and data retrieval

refs #4175
This commit is contained in:
Jannis Moßhammer 2013-07-01 17:51:18 +02:00
parent edbca73291
commit aefea8486e
10 changed files with 1998 additions and 1341 deletions

View File

@ -15,20 +15,18 @@ install: install-static-files install-runtime-dirs
# Removes files created by ./configure
#
clean:
if [ -f ./public/.htaccess ];then \
rm ./public/.htaccess; \
fi; \
if [ -f ./Makefile ];then \
rm ./Makefile; \
fi; \
if [ -f ./etc/apache/cranberry.conf ];then \
rm ./etc/apache/cranberry.conf; \
if [ -f ./etc/apache/icinga2web.conf ];then \
rm ./etc/apache/icinga2web.conf; \
fi;
#
# Installs/copies all static files (executables, scripts, html, etc)
#
install-static-files: install-application copy-folder-public copy-folder-config
install-static-files: install-application copy-web-files-public copy-web-files-config
$(INSTALL) -m 644 $(INSTALL_OPTS) "./public/.htaccess" $(DESTDIR)$(prefix)/public/.htaccess;
#
@ -46,12 +44,12 @@ install-tests: copy-folder-tests
# Install configurations for apache2
#
install-apache-configs:
$(INSTALL) -m 644 $(INSTALL_OPTS) "./etc/apache/cranberry.conf" $(WWW_CONF_PATH)/cranberry.conf;
$(INSTALL) -m 644 $(INSTALL_OPTS) "./etc/apache/icinga2web.conf" $(WWW_CONF_PATH)/icinga2web.conf;
#
# Installs the php files to the prefix
#
install-application: copy-php-files-application copy-php-files-library
install-application: copy-web-files-application copy-web-files-library
#
# Rule for coying folders and containing files (arbitary types), hidden files are excluded
@ -74,7 +72,7 @@ copy-folder-%:
#
# Rule for copying only php, *html, js and ini files. Hidden files are ignored
#
copy-php-files-%:
copy-web-files-%:
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(prefix)/$*
@dirs=`find ./$* -mindepth 1 -type d `;\

65
aclocal.m4 vendored Executable file
View File

@ -0,0 +1,65 @@
AC_DEFUN([AC_USER_GUESS],[
$2=$3
for x in $1; do
AC_MSG_CHECKING([if user $x exists])
AS_IF([ $GREP -q "^$x:" /etc/passwd ],
[ AC_MSG_RESULT([found]); $2=$x ; break],
[ AC_MSG_RESULT([not found]) ])
done
])
AC_DEFUN([AC_CHECK_PHP_MODULE],[
for x in $1;do
AC_MSG_CHECKING([if php has $x module])
AS_IF([ php -m | $GREP -iq "^$x$" ],
[ AC_MSG_RESULT([found]) ],
[ AC_MSG_ERROR([not found])])
done
])
AC_DEFUN([AC_CHECK_PHP_VERSION],[
AC_MSG_CHECKING([if php has at least version $1.$2.$3])
AS_IF([ test $1 -le `php -r 'echo PHP_MAJOR_VERSION;'` && \
test $2 -le `php -r 'echo PHP_MINOR_VERSION;'` && \
test $3 -le `php -r 'echo PHP_RELEASE_VERSION;'`],
[ AC_MSG_RESULT([PHP version is correct])],
[ AC_MSG_ERROR([You need at least PHP version $1.$2.$3])])
])
AC_DEFUN([AC_CHECK_PHP_INCLUDE],[
AC_MSG_CHECKING([if PHP runtime dependency '$2' is available])
AS_IF([ php -r 'require "$1";' ],
[ AC_MSG_RESULT([PHP runtime dependency fulfilled])],
[ AC_MSG_ERROR([PHP runtime dependency '$2' is missing])])
])
AC_DEFUN([AC_GROUP_GUESS],[
$2=$3
for x in $1; do
AC_MSG_CHECKING([if group $x exists])
AS_IF([ $GREP -q "^$x:" /etc/group ],
[ AC_MSG_RESULT([found]); $2=$x ; break],
[ AC_MSG_RESULT([not found]) ])
done
])
AC_DEFUN([AC_CHECK_BIN], [
AC_PATH_PROG([$1],[$2],[not found])
AS_IF([ test "XX${$1}" == "XXnot found" ],
[ AC_MSG_WARN([binary $2 not found in PATH]) ])
test "XX${$1}" == "XXnot found" && $1=""
])
AC_DEFUN([AC_PATH_GUESS], [
$2=$3
for x in $1; do
AC_MSG_CHECKING([if path $x exists])
AS_IF([test -d $x],
[AC_MSG_RESULT([found]); $2=$x; break],
[AC_MSG_RESULT([not found])]
)
done
])

View File

@ -0,0 +1,24 @@
[ldap-authentication]
backend=ldap
hostname=@ldap_host@
port=@ldap_port@
root_dn='@ldap_rootdn@'
bind_dn='@ldap_binddn@'
bind_pw=@ldap_bindpass@
; Attributes for ldap user lookup
user.ldap_object_class=@ldap_user_objectclass@
user.ldap_name_attribute=@ldap_attribute_username@
user.password_attribute=@ldap_attribute_password@
group.ldap_object_class=@ldap_group_objectclass@
group.ldap_name_attribute=@ldap_attribute_groupname@
[internal-authentication]
backend=db
type=@internal_db_type@
host=@internal_db_host@
port=@internal_db_port@
database=@internal_db_name@
user=@internal_db_user@
password=@internal_db_pass@

25
config/backends.ini.in Normal file
View File

@ -0,0 +1,25 @@
[localdb]
type = ido
host = @ido_host@
port = @ido_port@
user = @ido_user@
pass = @ido_password@
db = @ido_database@
@ido_enabled@
[locallive]
type = livestatus
socket = @livestatus_socket@
@livestatus_enabled@
[localfile]
type = statusdat
status_file = @statusdat_file@
objects_file = @objects_cache_file@
@statusdat_enabled@
;[localfailsafe]
;enabled=false
;type = combo
;backends = localdb, locallive, localfile

2958
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,13 @@ AC_CHECK_PHP_MODULE([sockets json])
# Checks for header files.
#
AC_ARG_WITH([icinga2web_config_path],
AS_HELP_STRING([--with-icinga2web-config-path], [Configuration path for icinga ]),
icinga2web_config_path="'$withval'",
icinga2web_config_path="'$prefix/config/'"
)
# Users for webfiles
#
@ -165,48 +171,170 @@ AC_ARG_WITH([ldap_rootdn],
ldap_rootdn=["ou=people, dc=icinga, dc=org"]
)
AC_ARG_WITH([ldap_user_class],
AS_HELP_STRING([--with-ldap-attribute-username=LDAP_ATTRIBUTE], [user object type to use for the authentication (defaults inetOrgPerson)]),
ldap_user_class=$withval,
ldap_user_class="inetOrgPerson"
AC_ARG_WITH([ldap_user_objectclass],
AS_HELP_STRING([--with-ldap-user-objectclass=LDAP_OBJECT_CLASS], [ldap object class to use for user authentication (default: inetOrgPerson)]),
ldap_user_objectclass=$withval,
ldap_user_objectclass="inetOrgPerson"
)
AC_ARG_WITH([ldap_attribute_username],
AS_HELP_STRING([--with-ldap-attribute-username=LDAP_ATTRIBUTE], [user attribute to use for the username (defaults uid)]),
AS_HELP_STRING([--with-ldap-attribute-username=LDAP_ATTRIBUTE], [user attribute to use for the username (default: uid)]),
ldap_attribute_username=$withval,
ldap_attribute_username="uid"
)
AC_ARG_WITH([ldap_attribute_firstname],
AS_HELP_STRING([--with-ldap-attribute-firstname=LDAP_ATTRIBUTE], [user attribute to use for the firstname (defaults firstname)]),
ldap_attribute_firstname=$withval,
ldap_attribute_firstname="firstname"
)
AC_ARG_WITH([ldap_attribute_lastname],
AS_HELP_STRING([--with-ldap-attribute-lastname=LDAP_ATTRIBUTE], [user attribute to use for the lastname (defaults lastname)]),
ldap_attribute_lastname=$withval,
ldap_attribute_lastname="lastname"
)
AC_ARG_WITH([ldap_attribute_password],
AS_HELP_STRING([--with-ldap-attribute-password=LDAP_ATTRIBUTE], [user attribute to use for the password (defaults password)]),
AS_HELP_STRING([--with-ldap-attribute-password=LDAP_ATTRIBUTE], [user attribute to use for the password (default: password)]),
ldap_attribute_password=$withval,
ldap_attribute_password="password"
)
AC_ARG_WITH([ldap_group_objectclass],
AS_HELP_STRING([--with-ldap-group-objectclass=LDAP_ATTRIBUTE], [ldap object type to use for group authentication (default: inetOrgPerson)]),
ldap_group_objectclass=$withval,
ldap_group_objectclass="group"
)
AC_ARG_WITH([ldap_attribute_groupname],
AS_HELP_STRING([--with-ldap-attribute-groupname=LDAP_OBJECT_CLASS], [user object type to use for the authentication (default: inetOrgPerson)]),
ldap_attribute_groupname=$withval,
ldap_attribute_groupname="guid"
)
#
# Icinga backend selection
#
AC_ARG_WITH([icinga_backend],
AS_HELP_STRING([--with-icinga-backend=(ido, statusdat, livestatus)], [backend to use for rb (default: statusdat)]),
icinga_backend=$withval,
icinga_backend="statusdat"
)
#
# Ido settings
#
AC_ARG_WITH([ido_db_type],
AS_HELP_STRING([--with-ido-db-type=(mysql, pgsql)], [database engine to use for retrieving data from the ido db (default: mysql)]),
ido_db_type=$withval,
ido_db_type="statusdat"
)
AC_ARG_WITH([ido_host],
AS_HELP_STRING([--with-ido-host=HOST], [host to use for retrieving data from the ido db (default: localhost)]),
ido_host=$withval,
ido_host="localhost"
)
AC_ARG_WITH([ido_port],
AS_HELP_STRING([--with-ido-port=PORT], [backend to use for retrieving data from the ido db (default: 3306 for mysql. 5432 for pgsql)]),
ido_port=$withval,
ido_port=db_default_port
)
AC_ARG_WITH([ido_database],
AS_HELP_STRING([--with-ido-database=DATABASE], [database name to use for retrieving data from the ido db (default: icinga)]),
ido_database=$withval,
ido_database="icinga"
)
AC_ARG_WITH([ido_user],
AS_HELP_STRING([--with-ido-host=USER], [user to use for retrieving data from the ido db (default: icinga)]),
ido_user=$withval,
ido_user="icinga"
)
AC_ARG_WITH([ido_password],
AS_HELP_STRING([--with-ido-password=PASSWORD], [password to use for retrieving data from the ido db (default: icinga)]),
ido_password=$withval,
ido_password="icinga"
)
#
# Statusdat file location
#
AC_ARG_WITH([statusdat_file],
AS_HELP_STRING([--with-statusdat-file=FILE], [location of the status.dat file when retrieving data from status.dat (default: /usr/local/icinga/var/status.dat)]),
statusdat_file=$withval,
statusdat_file="/usr/local/icinga/var/status.dat"
)
AC_ARG_WITH([objects_cache_file],
AS_HELP_STRING([--with-objects-file=FILE], [location of the objects.cache file when retrieving data from status.dat (default: /usr/local/icinga/var/objects.cache)]),
objects_cache_file=$withval,
objects_cache_file="/usr/local/icinga/var/objects.cache"
)
#
# Livestatus connection
#
AC_ARG_WITH([livestatus_socket],
AS_HELP_STRING([--with-livestatus-socket=FILE], [location of the livestatus socket (default: /usr/local/icinga/var/rw/live)]),
livestatus_socket=$withval,
livestatus_socket="/usr/local/icinga/var/rw/live"
)
#
# Icinga commandpipe
#
AC_ARG_WITH([icinga_commandpipe],
AS_HELP_STRING([--with-icinga-commandpipe=FILE], [location of the command pipe used for sending commands (default: /usr/local/icinga/var/rw/icinga.cmd)]),
icinga_commandpipe=$withval,
icinga_commandpipe="/usr/local/icinga/var/rw/icinga.cmd"
)
# Installation options
INSTALL_OPTS="-o $bin_user -g $bin_group"
INSTALL_OPTS_WEB="-o $web_user -g $web_group"
AS_IF([test "x$internal_db_type" = xmysql], [
AC_CHECK_PHP_INCLUDE([Zend/Db/Adapter/Pdo/Mysql.php],[Zend Framework - MySQL PDO Adapter])
AC_CHECK_PHP_MODULE([mysql])
AS_IF([test "x$internal_db_port" == xdb_default_port], [internal_db_port=3306])
])
AS_IF([test "x$ido_db_type" = xmysql], [
AC_CHECK_PHP_INCLUDE([Zend/Db/Adapter/Pdo/Mysql.php],[Zend Framework - MySQL PDO Adapter])
AC_CHECK_PHP_MODULE([mysql])
AS_IF([test "x$ido_port" = xdb_default_port], [ido_port=3306])
])
AS_IF([test "x$internal_db_type" = xpgsql], [
AC_CHECK_PHP_INCLUDE([Zend/Db/Adapter/Pdo/Pgsql.php],[Zend Framework - PostgreSQL PDO Adapter])
AC_CHECK_PHP_MODULE([pgsql])
AS_IF([test "x$internal_db_port" = xdb_default_port], [internal_db_port=5432])
])
AS_IF([test "x$ido_db_type" = xpgsql], [
AC_CHECK_PHP_INCLUDE([Zend/Db/Adapter/Pdo/Pgsql.php],[Zend Framework - PostgreSQL PDO Adapter])
AC_CHECK_PHP_MODULE([pgsql])
AS_IF([test "x$ido_port" = xdb_default_port], [ido_port=5432])
])
# comment out the disabled backends per default
ido_enabled="disable=1"
statusdat_enabled="disable=1"
livestatus_enabled="disable=1"
ldap_enabled="disable=1"
AS_CASE([$icinga_backend],
["ido"], [ido_enabled=""],
["statusdat"], [statusdat_enabled=""],
["livestatus"], [livestatus_enabled=""],
[statusdat_enabled=""])
AS_IF([test "x$internal_db_type" == xmysql],
[AC_CHECK_PHP_INCLUDE([Zend/Db/Adapter/Pdo/Mysql.php],[Zend Framework - MySQL PDO Adapter])])
AS_IF([test "x$internal_db_type" == xpgsql],
[AC_CHECK_PHP_INCLUDE([Zend/Db/Adapter/Pdo/Pgsql.php],[Zend Framework - PostgreSQL PDO Adapter])])
AS_IF([test "x$ldap_authentication" != xno],
AC_CHECK_PHP_MODULE([ldap]))
AC_CHECK_PHP_MODULE([ldap])
ldap_enabled=""
)
# Installation directives
AC_SUBST(app_name)
@ -216,6 +344,7 @@ AC_SUBST(web_path)
AC_SUBST(www_conf_path)
AC_SUBST(bin_user)
AC_SUBST(bin_group)
AC_SUBST(icinga2web_config_path)
# Internal db setup
AC_SUBST(internal_db_type)
@ -231,13 +360,42 @@ AC_SUBST(ldap_port)
AC_SUBST(ldap_rootdn)
AC_SUBST(ldap_binddn)
AC_SUBST(ldap_bindpass)
AC_SUBST(ldap_user_class)
AC_SUBST(ldap_user_objectclass)
AC_SUBST(ldap_attribute_basedn)
AC_SUBST(ldap_attribute_username)
AC_SUBST(ldap_attribute_firstname)
AC_SUBST(ldap_attribute_lastname)
AC_SUBST(ldap_attribute_password)
AC_SUBST(ldap_group_objectclass)
AC_SUBST(ldap_attribute_groupname)
# backend setup
AC_SUBST(icinga_backend)
# ido backend variables
AC_SUBST(ido_db_type)
AC_SUBST(ido_host)
AC_SUBST(ido_port)
AC_SUBST(ido_database)
AC_SUBST(ido_user)
AC_SUBST(ido_password)
# status.dat backend
AC_SUBST(statusdat_file)
AC_SUBST(objects_cache_file)
# livestatus backend
AC_SUBST(livestatus_socket)
# command pipe
AC_SUBST(icinga_commandpipe)
#
# Comment placeholders for toggling backends
#
AC_SUBST(livestatus_enabled)
AC_SUBST(statusdat_enabled)
AC_SUBST(ido_enabled)
AC_SUBST(ldap_enabled)
AC_SUBST(PHP)
AC_SUBST(INSTALL_OPTS)
@ -245,8 +403,9 @@ AC_SUBST(INSTALL_OPTS_WEB)
AC_CONFIG_FILES([
Makefile
etc/config/authentication_db.ini
etc/config/authentication_ldap.ini
config/authentication.ini
config/backends.ini
public/index.php
])
AC_OUTPUT

View File

@ -1,9 +0,0 @@
[users]
backend=db
type=@internal_db_type@
host=@internal_db_host@
port=@internal_db_port@
database=@internal_db_name@
user=@internal_db_user@
password=@internal_db_pass@

View File

@ -1,15 +0,0 @@
[users]
backend=ldap
hostname=@ldap_host@
port=@ldap_port@
root_dn='@ldap_rootdn@'
bind_dn='@ldap_binddn@'
bind_pw=@ldap_bindpass@
; Attributes for ldap user lookup
user_class=@ldap_user_class@
user_name_attribute=@ldap_attribute_username@
user_firstname_attribute=@ldap_attribute_firstname@
user_lastname_attribute=@ldap_attribute_lastname@
user_password_attribute=@ldap_attribute_password@

View File

@ -1 +1 @@
/usr/local/Cellar/automake/1.12.4/share/automake-1.12/install-sh
/usr/share/automake-1.11/install-sh

10
public/index.php.in Normal file
View File

@ -0,0 +1,10 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
require_once dirname(__FILE__). '/../library/Icinga/Application/ApplicationBootstrap.php';
require_once dirname(__FILE__). '/../library/Icinga/Application/Web.php';
use Icinga\Application\Web;
Web::start(@icinga2web_config_path@)->dispatch();