10.x smeserver-roundcube

By telleropnul, March 12, 2022

First let’s get a burner web server.
1VCPU
2GB RAM
50GB HDD
2000GB transfer / month
$8.50 / month
Custom ISO: https://mirror.pialasse.com/releases/10/iso/x86_64/smeserver-10.0-x86_64.iso

[OKAY] 110.232.112.179 online.
[OKAY] A record.   http://aleph.coeleveld.com is online.
[OKAY] SSH secure shell online – note: configured very basic for now in case I need to share credentials with devs.
[OKAY] yum update
[OKAY] let’s encrypt    https://aleph.coeleveld.com is online
[OKAY] tunnel 443 over SSH to remotely access https://localhost/server-manager
[OKAY] enable webmail   https://aleph.coeleveld.com/webmail

hmm….not too shabby…

okay, so where to next….need a contrib that uses php-fpm and mysql…one moment…

looks like php-fpm is installed out-of-the-box.

[root@f0003 ~]# yum list php-fpm
Installed Packages
php-fpm.x86_64 5.4.16-48.el7 @anaconda/10.0

note to self…php-fpm is probably something like php-scl; it allows you to select which version of php you want for each iBay.

looks like out-of-the-box our prime candidate is horde.

[root@f0003 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| horde |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)

Let’s have a closer look at smeserver-horde

[root@f0003 ~]# rpm -ql smeserver-horde

10.x smeserver-horde.txt

of particular interest are:

[root@f0003 ~]# rpm -ql smeserver-horde | grep fpm

/etc/e-smith/events/email-update/services2adjust/php-fpm
/etc/e-smith/events/email-update/services2adjust/php55-php-fpm
/etc/e-smith/events/email-update/services2adjust/php56-php-fpm
/etc/e-smith/events/email-update/services2adjust/php70-php-fpm
/etc/e-smith/events/email-update/services2adjust/php71-php-fpm
/etc/e-smith/events/email-update/services2adjust/php72-php-fpm
/etc/e-smith/events/email-update/services2adjust/php73-php-fpm
/etc/e-smith/events/email-update/services2adjust/php74-php-fpm
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php70/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php70/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php71/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php71/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php72/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php72/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php73/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php73/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php74/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/etc/opt/remi/php74/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/etc/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/etc/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/opt/remi/php55/root/etc/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/opt/remi/php55/root/etc/php-fpm.d/www.conf
/etc/e-smith/events/email-update/templates2expand/opt/remi/php56/root/etc/php-fpm.d
/etc/e-smith/events/email-update/templates2expand/opt/remi/php56/root/etc/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php70/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php70/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php71/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php71/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php72/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php72/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php73/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php73/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php74/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/opt/remi/php74/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/etc/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/opt/remi/php55/root/etc/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/opt/remi/php55/root/etc/php-fpm.d/www.conf
/etc/e-smith/events/smeserver-horde-update/templates2expand/opt/remi/php56/root/etc/php-fpm.d
/etc/e-smith/events/smeserver-horde-update/templates2expand/opt/remi/php56/root/etc/php-fpm.d/www.conf
/etc/e-smith/templates/etc/php-fpm.d
/etc/e-smith/templates/etc/php-fpm.d/www.conf
/etc/e-smith/templates/etc/php-fpm.d/www.conf/20Horde

brb…reading files contents…

“services2expand”

makes sense…just symlinks to expose peer signal-event hooks when you  run “signal-event email-update’:

“templates2expand”

hmmm…these are all empty files…probably hooks into templates to expand.

Note the actual php-fpm templates that are being manipulated live here:

This appears to be the main template Horde adds to php-fpm.   Interesting, this is basically the php.ini stuff suitable for all versions of PHP.

[root@f0003 ~]# cat /etc/e-smith/templates/etc/php-fpm.d/www.conf/20Horde
{
use esmith::ConfigDB;
use esmith::php;
my $c = esmith::ConfigDB->open_ro || die "Couldn't opeen the configuration database\n";
my $horde = $c->get( "horde" );
 
my $version = PhpFpmVersionToUse($horde,"72"); #$horde->prop('PHPVersion') || '72';
my $status = $horde->prop('status') || 'disabled';
return unless ($status eq 'enabled' && $version eq $PHP_VERSION);
my $key = $horde->key;
my $pool_name = lc $key;
my $memory_limit = $horde->prop('PHPMemoryLimit') || '128M';
my $max_execution_time = $horde->prop('PHPMaxExecutionTime') || '30';
my $max_input_time = $horde->prop('PHPMaxInputTime') || '60';
my $allow_url_fopen = $horde->prop('PHPAllowUrlFopen') || 'disabled';
my $post_max_size = $horde->prop('PHPPostMaxSize') || '10M';
my $upload_max_filesize = $horde->prop('PHPUploadMaxFilesize') || '10M';
my $file_upload = $horde->prop('PHPFileUpload') || 'enabled';
my $include_path = ".:/usr/share/pear-addons:/usr/share/pear:/usr/share/pear-data/:/usr/share/php".
":/opt/remi/php55/root/usr/share/pear-data/:/opt/remi/php56/root/usr/share/pear-data/".
":/opt/remi/php70/root/usr/share/pear-data/:/opt/remi/php71/root/usr/share/pear-data/:/opt/remi/php72/root/usr/share/pear-data/: /opt/remi/php73/root/usr/share/pear-data/: /opt/remi/php74/root/usr/share/pear-data/". 
":/opt/remi/php55/root/usr/share/pear/:/opt/remi/php56/root/usr/share/pear/".
":/opt/remi/php70/root/usr/share/pear/:/opt/remi/php71/root/usr/share/pear/:/opt/remi/php72/root/usr/share/pear/: /opt/remi/php73/root/usr/share/pear/: /opt/remi/php74/root/usr/share/pear/" ;
my $open_basedir = $horde->prop('PHPBaseDir') || '/usr/share/horde' .
':/etc/horde/' .
':/var/lib/php/' . $key .
":$include_path" .
":/etc/resolv.conf".
":/usr/bin/gpg:/usr/bin/gpg2:/usr/bin/hunspell:/usr/bin/openssl:/home/e-smith/ssl.crt/:/usr/bin/convert:/usr/bin/identify:/usr/bin/misc/magic".
":/usr/bin/quota:/bin/grep:/etc/mtab";
# needed for php-fpm 5.4, does not seem to handle the sys_temp_dir
# not that a security concern as systemd use a rooted /tmp
$open_basedir .= ":/tmp/" if $version eq "";
my $disabled_functions = $horde->prop('PHPDisabledFunctions') || 'system,show_source,' .
'symlink,exec,dl,shell_exec,' .
'passthru,phpinfo,' .
'escapeshellarg,escapeshellcmd';
my $MailForceSender = $horde->prop('MailForceSender') || "$name\@$DomainName";
# Format vars
$file_upload = ($file_upload =~ m/^1|yes|on|enabled$/) ? 'on' : 'off';
$allow_url_fopen = "off" ; # ($allow_url_fopen =~ m/^1|yes|on|enabled$/) ? 'on' : 'off';
$disabled_functions = join(', ', split /[,;:]/, $disabled_functions);
$open_basedir = join(':', split(/[,;:]/, $open_basedir . ",/usr/share/php"));
 
$OUT .=<<"_EOF" if ($version eq $PHP_VERSION);
 
[$pool_name]
user = www
group = www
listen.owner = root
listen.group = www
listen.mode = 0660
listen = /var/run/php-fpm/php$version-$pool_name.sock
pm = dynamic
pm.max_children = 15
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 4
pm.max_requests = 1000
slowlog = /var/log/$key/slow.log
php_admin_value[session.save_path] = /var/lib/php/$key/session
php_admin_value[opcache.file_cache] = /var/lib/php/$key/opcache
php_admin_value[upload_tmp_dir] = /var/lib/php/$key/tmp
php_admin_value[sys_temp_dir] = /var/lib/php/$key/tmp
php_admin_value[mail.force_extra_parameters] = '-f $MailForceSender'
php_admin_flag[display_errors] = off
php_admin_value[error_reporting] =E_ERROR | E_WARNING | E_PARSE
php_admin_value[error_log] = /var/log/$key/error.log
php_admin_value[memory_limit] = $memory_limit
php_admin_value[max_execution_time] = $max_execution_time
php_admin_value[post_max_size] = $post_max_size
php_admin_value[upload_max_filesize] = $upload_max_filesize
php_admin_value[max_input_time] = $max_input_time
php_admin_value[disable_functions] = $disabled_functions
php_admin_flag[allow_url_fopen] = $allow_url_fopen
php_admin_flag[file_upload] = $file_upload
php_admin_flag[session.cookie_httponly] = on
php_admin_flag[allow_url_include] = off
php_admin_value[session.save_handler] = files
php_admin_value[open_basedir] = $open_basedir
 
php_admin_value[auto_prepend_file] = /usr/share/php/auth_translation.php
php_value[include_path] = $include_path
php_flag[magic_quotes_gpc] = off
php_flag[track_vars] = on
php_flag[session.use_trans_sid] = off
 
 
_EOF
 
 
}

I feel I want to take the 9.x smeserver-roundcube package and start modifying it to work with php-fpm on 10.x

https://wiki.koozali.org/SME_Server:Documentation:Developers_Manual

https://wiki.koozali.org/SME_Server:Documentation:Developers_Manual#III._How_to_create_an_SME_Server_package_-_step_by_step

https://blog.packagecloud.io/inspect-extract-contents-rpm-packages/

[root@f0003 ~]# yum repolist -v
[root@f0003 ~]# config show sysconfig
sysconfig=configuration
  ....
  ReleaseVersion=10.0
  ....
[root@f0003 ~]# chsh -s /bin/bash joe
[root@f0003 ~]# db accounts setprop joe Shell /bin/bash
[root@f0003 ~]# su joe
bash-4.2$ mkdir -p ~/home/rpm/roundcube
bash-4.2$ cd ~/home/rpm/roundcube
bash-4.2$ pwd
  /home/e-smith/files/users/joe/home/roundcube
bash-4.2$ wget http://mirror.canada.pialasse.com/releases/obsolete/9/smecontribs/x86_64/RPMS/smeserver-roundcube-1.2-9.el6.sme.noarch.rpm
bash-4.2$ rpm2cpio smeserver-roundcube-1.2-9.el6.sme.noarch.rpm | cpio -idmv

might as well grab 10.x horde and do the same.

bash-4.2$ mkdir ~/home/rpm/horde
bash-4.2$ cd ~/home/rpm/horde
bash-4.2$ wget http://mirror.pialasse.com/releases/10/smeos/x86_64/Packages/smeserver-horde-1.0.0-27.el7.sme.noarch.rpm
bash-4.2$ rpm2cpio smeserver-horde-1.0.0-27.el7.sme.noarch.rpm | cpio -idmv

[joined RocketChat dev chat]

[root@f0003 ~]# yum install smeserver-extrarepositories-centos-sclo -y

[root@f0003 ~]# /sbin/e-smith/db yum_repositories set epel repository \ 
Name 'Epel - EL7' \ 
BaseURL 'http://download.fedoraproject.org/pub/epel/7/$basearch' \ 
MirrorList 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&amp;arch=$basearch' \ 
EnableGroups no \ 
GPGCheck yes \ 
GPGKey http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL \ 
Exclude perl-Razor-Agent,pwauth \ 
Visible no \ 
status disabled 
[root@f0003 ~]# signal-event yum-modify 
[root@f0003 ~]# yum install smeserver-mock --enablerepo smedev,epel

[root@f0003 ~]# yum install cvs
[root@f0003 ~]# signal-event post-upgrade

[root@f0003 ~]# useradd builder
[root@f0003 ~]# passwd builder
[root@f0003 ~]# chsh -s /bin/bash builder
[root@f0003 ~]# db accounts setprop builder Shell /bin/bash
[root@f0003 ~]# /usr/sbin/usermod -G mock builder
[root@f0003 ~]# su builder
bash-4.2$ mkdir ~/smeserver
bash-4.2$ mkdir ~/smecontribs
bash-4.2$ cd ~/smecontribs
bash-4.2$ cvs -z3 -d:pserver:anonymous@shell.koozali.org:/cvs/smecontribs co -P rpms

[not yet] https://wiki.koozali.org/Setting_up_RPM_Building_for_SME_Server#Install_and_config_CVS
[yes] https://wiki.koozali.org/Simple_Package_Modification
[cvs vault web view only…ooh shiny] https://viewvc.koozali.org

bash-4.2$ su builder
bash-4.2$ /home/e-smith/files/users/builder/smecontribs/rpms/smeserver-roundcube/contribs9
bash-4.2$ cvs update -dPA
bash-4.2$ make clean
bash-4.2$ make prep

notice how tarball in [sources] file is fetched and extracted.
notice how patch diffs are applied.

bash-4.2$ pwd
/home/e-smith/files/users/builder/smecontribs/rpms/smeserver-roundcube/contribs9/smeserver-roundcube-1.2/root
bash-4.2$ find . -type f
./etc/e-smith/templates.metadata/etc/roundcubemail/config.inc.php
./etc/e-smith/templates.metadata/etc/e-smith/sql/init/80roundcube
./etc/e-smith/db/configuration/migrate/80ROUNDCUBE_IMAPS_ACCESS
./etc/e-smith/db/configuration/migrate/80roundcube
./etc/e-smith/db/configuration/migrate/80roundcube_Plugins_Migration
./etc/e-smith/db/configuration/defaults/roundcube/status
./etc/e-smith/db/configuration/defaults/roundcube/Name
./etc/e-smith/db/configuration/defaults/roundcube/PublicAccess
./etc/e-smith/db/configuration/defaults/roundcube/DbName
./etc/e-smith/db/configuration/defaults/roundcube/PluginsList
./etc/e-smith/db/configuration/defaults/roundcube/DbUser
<snip>
[root@f0003 ~]# yum install --enablerepo=smecontribs smeserver-phpmyadmin
[root@f0003 ~]# signal-event post-upgrade
bash-4.2$ grep -i require /home/e-smith/files/users/builder/smecontribs/rpms/smeserver-roundcube/contribs9/smeserver-roundcube-1.2/smeserver-roundcube.spec
BuildRequires: e-smith-devtools
Requires: e-smith-release >= 9.0
Requires: roundcubemail >= 1.1
Requires: git
Requires: smeserver-dovecot-extras
Requires: roundcubemail_plugins
- requires sme8 0.9-8
./home/e-smith/files/users/builder/smecontribs/rpms/roundcubemail/contribs10
make prep
...
/home/e-smith/files/users/builder/smecontribs/rpms/roundcubemail/contribs10/roundcubemail-1.1.3.tar.gz
...

The only changes between the wget roundcubemail-1.1.3.tar.gz and the rpm packaged one are a few patches listed in the spec file that can be played back later if need be.

> ./.htaccess
18a20
> ./config/.htaccess
20d21
< ./config/mimetypes.php
21a23
> ./config/mimetypes.php
38a41
> ./logs/.htaccess
283a287
> ./plugins/enigma/home/.htaccess
1474a1479
> ./program/js/tinymce/plugins/bbcode/plugin.min.js
1506a1512
> ./program/js/tinymce/plugins/media/moxieplayer.swf
2130a2137
> ./temp/.htaccess
2132,2133c2139
< ./vendor/autoload.php

For starters I can create a plain roundcubemail RPM based on https://github.com/roundcube/roundcubemail/releases/download/1.4.13/roundcubemail-1.4.13.tar.gz