2014-10-28 17:32:49 +01:00
<?php
2014-10-29 11:36:03 +01:00
use Icinga\Application\Icinga;
2014-10-30 10:37:51 +01:00
use Icinga\Application\Config;
2014-10-29 11:36:03 +01:00
use Icinga\Application\Platform;
use Icinga\Web\Wizard;
2014-10-28 17:32:49 +01:00
2015-03-05 10:30:06 +01:00
$phpUser = Platform::getPhpUser();
2014-11-26 08:52:46 +01:00
$configDir = Icinga::app()->getConfigDir();
$setupTokenPath = rtrim($configDir, '/') . '/setup.token';
2014-11-11 10:19:32 +01:00
$cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');
2014-10-28 17:32:49 +01:00
2015-05-27 11:39:13 +02:00
$groupadd = null;
if (! (false === ($distro = Platform::getLinuxDistro(1)) || $distro === 'linux')) {
foreach (array(
'groupadd -r icingaweb2' => array(
'redhat', 'rhel', 'centos', 'fedora',
'suse', 'sles', 'sled', 'opensuse'
),
'addgroup --system icingaweb2' => array('debian', 'ubuntu')
) as $groupadd_ => $distros) {
if (in_array($distro, $distros)) {
$groupadd = $groupadd_;
break;
}
}
2015-12-14 11:29:03 +01:00
switch ($distro) {
case 'redhat':
case 'rhel':
case 'centos':
case 'fedora':
$usermod = 'usermod -a -G icingaweb2 %s';
$webSrvUser = 'apache';
2015-05-27 11:39:13 +02:00
break;
2015-12-14 11:29:03 +01:00
case 'suse':
case 'sles':
case 'sled':
case 'opensuse':
$usermod = 'usermod -A icingaweb2 %s';
$webSrvUser = 'wwwrun';
break;
case 'debian':
case 'ubuntu':
$usermod = 'usermod -a -G icingaweb2 %s';
$webSrvUser = 'www-data';
break;
default:
$usermod = $webSrvUser = null;
2015-05-27 11:39:13 +02:00
}
}
2014-10-29 11:36:03 +01:00
?>
< div class = "welcome-page" >
2015-01-20 17:39:47 +01:00
< h2 > <? = $this -> translate ( 'Welcome to the configuration of Icinga Web 2!' ) ?> </ h2 >
2014-10-30 10:37:51 +01:00
<?php if ( false === file_exists ( $setupTokenPath ) && file_exists ( Config :: resolvePath ( 'config.ini' ))) : ?>
2015-01-20 17:39:47 +01:00
< p class = "restart-warning" > <? = $this -> translate (
2014-11-10 10:30:52 +01:00
'You\'ve already completed the configuration of Icinga Web 2. Note that most of your configuration'
2014-10-30 10:37:51 +01:00
. ' files will be overwritten in case you\'ll re-configure Icinga Web 2 using this wizard!'
); ?>< / p >
<?php else : ?>
2015-01-20 17:39:47 +01:00
< p > <? = $this -> translate (
2014-11-26 08:57:40 +01:00
'This wizard will guide you through the configuration of Icinga Web 2. Once completed and successfully'
. ' finished you are able to log in and to explore all the new and stunning features!'
2014-10-29 11:36:03 +01:00
); ?>< / p >
2014-10-30 10:37:51 +01:00
<?php endif ?>
2014-10-29 11:36:03 +01:00
< form id = " <? = $form -> getName (); ?> " name = " <? = $form -> getName (); ?> " enctype = " <? = $form -> getEncType (); ?> " method = " <? = $form -> getMethod (); ?> " action = " <? = $form -> getAction (); ?> " >
<? = $form -> getElement ( 'token' ); ?>
<? = $form -> getElement ( $form -> getTokenElementName ()); ?>
<? = $form -> getElement ( $form -> getUidElementName ()); ?>
2014-10-28 17:32:49 +01:00
< div class = "buttons" >
2014-10-29 11:36:03 +01:00
<? = $form -> getElement ( Wizard :: BTN_NEXT ); ?>
2014-10-28 17:32:49 +01:00
< / div >
2014-10-29 11:36:03 +01:00
< / form >
< div class = "note" >
2015-06-19 15:44:43 +02:00
< h3 > Generating a New Setup Token< / h3 >
2014-10-28 17:32:49 +01:00
< div >
2014-10-29 11:36:03 +01:00
< p > <? =
2015-01-20 17:39:47 +01:00
$this->translate(
2014-11-11 09:24:53 +01:00
'To run this wizard a user needs to authenticate using a token which is usually'
. ' provided to him by an administrator who\'d followed the instructions below.'
2014-10-29 11:36:03 +01:00
); ?>< / p >
2015-03-05 10:30:06 +01:00
< p > <? = $this -> translate ( 'In any case, make sure that all of the following applies to your environment:' ); ?> </ p >
< ul >
< li > <? = $this -> translate ( 'A system group called "icingaweb2" exists' ); ?> </ li >
<?php if ( $phpUser ) : ?>
< li > <? = sprintf ( $this -> translate ( 'The user "%s" is a member of the system group "icingaweb2"' ), $phpUser ); ?> </ li >
<?php else : ?>
< li > <? = $this -> translate ( 'Your webserver\'s user is a member of the system group "icingaweb2"' ); ?> </ li >
<?php endif ?>
< / ul >
2015-05-27 11:39:13 +02:00
<?php if ( ! ( $groupadd === null || $usermod === null )) { ?>
< div class = "code" >
< span > <? = $this -> escape ( $groupadd . ';' ) ?> </ span >
2015-12-14 11:29:03 +01:00
< span > <? = $this -> escape ( sprintf ( $usermod , $phpUser ?: $webSrvUser ) . ';' ) ?> </ span >
2015-05-27 11:39:13 +02:00
< / div >
<?php } ?>
2015-01-20 17:39:47 +01:00
< p > <? = $this -> translate ( 'If you\'ve got the IcingaCLI installed you can do the following:' ); ?> </ p >
2014-10-29 11:36:03 +01:00
< div class = "code" >
2015-01-26 14:13:10 +01:00
< span > <? = $cliPath ? $cliPath : 'icingacli' ; ?> setup config directory --group icingaweb2<? = $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : '' ; ?> ;</ span >
2014-11-11 10:19:32 +01:00
< span > <? = $cliPath ? $cliPath : 'icingacli' ; ?> setup token create;</ span >
2014-10-29 11:36:03 +01:00
< / div >
2015-01-20 17:39:47 +01:00
< p > <? = $this -> translate ( 'In case the IcingaCLI is missing you can create the token manually:' ); ?> </ p >
2014-10-29 11:36:03 +01:00
< div class = "code" >
2015-03-05 10:30:06 +01:00
< span > su <? = $phpUser ?: $this -> translate ( '<your-webserver-user>' ); ?> -c "mkdir -m 2770 <? = dirname ( $setupTokenPath ); ?> ; chgrp icingaweb2 <? = dirname ( $setupTokenPath ); ?> ; head -c 12 /dev/urandom | base64 | tee <? = $setupTokenPath ; ?> ; chmod 0660 <? = $setupTokenPath ; ?> ;";</ span >
2014-10-29 11:36:03 +01:00
< / div >
2014-11-13 17:20:06 +01:00
< p > <? = sprintf (
2015-01-20 17:39:47 +01:00
$this->translate('Please see the %s for an extensive description on how to access and use this wizard.'),
'< a href = "http://docs.icinga.org/" > ' . $this->translate('Icinga Web 2 documentation') . '< / a > ' // TODO: Add link to iw2 docs which points to the installation topic
2014-10-29 11:36:03 +01:00
); ?>< / p >
2014-10-28 17:32:49 +01:00
< / div >
2014-10-29 11:36:03 +01:00
< / div >
2014-11-13 17:20:06 +01:00
< / div >