$OpenBSD: patch-modules_setup_application_views_scripts_form_setup-welcome_phtml,v 1.5 2019/02/01 11:32:02 sthen Exp $

Minimal patches to avoid showing confusing path to users in the welcome
screen (PHP is normally run chroot'ed on OpenBSD), and use group "_icingaweb2"
as per OpenBSD standard naming for groups from packages.

We don't have head -c / base64, use an alternative.

Index: modules/setup/application/views/scripts/form/setup-welcome.phtml
--- modules/setup/application/views/scripts/form/setup-welcome.phtml.orig
+++ modules/setup/application/views/scripts/form/setup-welcome.phtml
@@ -8,7 +8,7 @@ use Icinga\Web\Wizard;
 $phpUser = Platform::getPhpUser();
 $configDir = Icinga::app()->getConfigDir();
 $setupTokenPath = rtrim($configDir, '/') . '/setup.token';
-$cliPath = realpath(Icinga::app()->getApplicationDir() . '/../bin/icingacli');
+$cliPath = '/var/www/icinga-web2/bin/icingacli';
 
 $groupadd = null;
 if (! (false === ($distro = Platform::getLinuxDistro(1)) || $distro === 'linux')) {
@@ -81,11 +81,11 @@ if (! (false === ($distro = Platform::getLinuxDistro(1
       ); ?></p>
       <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>
+        <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>
+        <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>
+        <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)) { ?>
@@ -96,12 +96,12 @@ if (! (false === ($distro = Platform::getLinuxDistro(1
       <?php } ?>
       <p><?= $this->translate('If you\'ve got the IcingaCLI installed you can do the following:'); ?></p>
       <div class="code">
-        <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup config directory --group icingaweb2<?= $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : ''; ?>;</span>
+        <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup config directory --group _icingaweb2<?= $configDir !== '/etc/icingaweb2' ? ' --config ' . $configDir : ''; ?>;</span>
         <span><?= $cliPath ? $cliPath : 'icingacli'; ?> setup token create;</span>
       </div>
       <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>
+        <span>su <?= $phpUser ?: $this->translate('<your-webserver-user>'); ?> -s /bin/sh -c "mkdir -m 2770 <?= dirname($setupTokenPath); ?>; chgrp _icingaweb2 <?= dirname($setupTokenPath); ?>; openssl rand -base64 12 | tee <?= $setupTokenPath; ?>; chmod 0660 <?= $setupTokenPath; ?>;";</span>
       </div>
       <p><?= sprintf(
         $this->translate('Please see the %s for an extensive description on how to access and use this wizard.'),
