summaryrefslogtreecommitdiffstats
path: root/modules/setup/application/views/scripts/form/setup-welcome.phtml
blob: 1be68f3f6334cdc77be507344f4fd32500860a37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php

use Icinga\Application\Icinga;
use Icinga\Application\Config;
use Icinga\Application\Platform;
use Icinga\Web\Wizard;

$phpUser = Platform::getPhpUser();
$configDir = Icinga::app()->getConfigDir();
$setupTokenPath = rtrim($configDir, '/') . '/setup.token';
$cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');

$groupadd = null;
$docker = getenv('ICINGAWEB_OFFICIAL_DOCKER_IMAGE');

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;
        }
    }

    switch ($distro) {
        case 'redhat':
        case 'rhel':
        case 'centos':
        case 'fedora':
            $usermod = 'usermod -a -G icingaweb2 %s';
            $webSrvUser = 'apache';
            break;
        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;
    }
}
?>
<div class="welcome-page">
  <h2><?= $this->translate('Welcome to the configuration of Icinga Web 2!') ?></h2>
 <?php if (false === file_exists($setupTokenPath) && file_exists(Config::resolvePath('config.ini'))): ?>
  <p class="restart-warning"><?= $this->translate(
    'You\'ve already completed the configuration of Icinga Web 2. Note that most of your configuration'
      . ' files will be overwritten in case you\'ll re-configure Icinga Web 2 using this wizard!'
  ); ?></p>
 <?php else: ?>
  <p><?= $this->translate(
    '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!'
  ); ?></p>
 <?php endif ?>
  <form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>" action="<?= $form->getAction(); ?>" class="icinga-controls">
    <?= $form->getElement('token'); ?>
    <?= $form->getElement($form->getTokenElementName()); ?>
    <?= $form->getElement($form->getUidElementName()); ?>
    <div class="buttons">
      <?= $form->getElement(Wizard::BTN_NEXT); ?>
    </div>
  </form>
  <div class="note">
    <h3><?= $this->translate('Generating a New Setup Token'); ?></h3>
    <div>
      <p><?=
        $this->translate(
          '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.'
      ); ?></p>
      <?php if (! $docker): ?>
      <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>
      <?php if (! ($groupadd === null || $usermod === null)) { ?>
      <div class="code">
        <span><?= $this->escape($groupadd . ';') ?></span>
        <span><?= $this->escape(sprintf($usermod, $phpUser ?: $webSrvUser) . ';') ?></span>
      </div>
      <?php } ?>
      <p><?= $this->translate('If you\'ve got the IcingaCLI installed you can do the following:'); ?></p>
      <?php endif; ?>
      <div class="code">
        <?php if (! $docker): ?>
        <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup config directory --group icingaweb2<?= $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : ''; ?>;</span>
        <?php endif; ?>
        <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup token create;</span>
      </div>
      <?php if (! $docker): ?>
      <p><?= $this->translate('In case the IcingaCLI is missing you can create the token manually:'); ?></p>
      <div class="code">
        <span>su <?= $phpUser ?: $this->translate('<your-webserver-user>'); ?> -s /bin/sh -c "mkdir -m 2770 <?= dirname($setupTokenPath); ?>; chgrp icingaweb2 <?= dirname($setupTokenPath); ?>; head -c 12 /dev/urandom | base64 | tee <?= $setupTokenPath; ?>; chmod 0660 <?= $setupTokenPath; ?>;";</span>
      </div>
      <?php endif; ?>
      <p><?= sprintf(
        $this->translate('Please see the %s for an extensive description on how to access and use this wizard.'),
        '<a href="http://docs.icinga.com/">' . $this->translate('Icinga Web 2 documentation') . '</a>' // TODO: Add link to iw2 docs which points to the installation topic
      ); ?></p>
    </div>
  </div>
</div>