* Fri Apr 05 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-4.sme

- tidy spec and sources for mariadb10.5 support [SME: 12524]
- try to make compatible with higher version from mariadb repo [SME: 11856]
- fix logrotate duplicate entry [SME: 12554]

* Thu Apr 04 2024 Brian Read <brianr@koozali.org> 11.0.0-3.sme
- Set license file to GPL2.0  [SME: 12577]
master 11_0_0-4_el8_sme
parent 7e830858f7
commit fbc84843d3

@ -1,3 +0,0 @@
#! /bin/sh
cd /var/opt/rh/rh-mariadb!!!VER!!!/lib/mysql && find . -type f | xargs rm -f

@ -1,3 +0,0 @@
#!/bin/sh
exec /bin/rm -f /home/e-smith/db/mariadb!!!VER!!!/*.dump

@ -1,58 +0,0 @@
#!/bin/sh
# We have to re-enable SCL environment, because /sbin/service
# clears almost all environment variables.
# Since X_SCLS is cleared as well, we lose information about other
# collections enabled.
. /opt/rh/rh-mariadb!!!VER!!!/service-environment
for sclname in $RH_MARIADB!!!VER!!!_SCLS_ENABLED ; do
. /opt/rh/$sclname/enable
export X_SCLS="$X_SCLS $sclname"
done
# we want start daemon only inside "scl enable" invocation
if ! scl_enabled $sclname ; then
echo "Collection $sclname has to be listed in /opt/rh/rh-mariadb!!!VER!!!/service-environment"
exit 1
fi
status=$(/sbin/e-smith/config getprop mariadb status)
fixtables=$(/sbin/e-smith/config getprop mariadb autofixtables || echo "disabled")
if [ "$fixtables" = "enabled" ]; then
/sbin/e-smith/config delprop mariadb failsbackup
fi
failsbackup=$(/sbin/e-smith/config getprop mariadb failsbackup || echo "disabled")
onfailure () {
db=$1
message=""
if [ "$failsbackup" = "enabled" ]; then
exit 1;
message="There was an error trying to dump database $db, please fix this db. We stop there without backups."
echo $message
echo $message | /usr/bin/mail -s "error on backup of $db MariaDB !!!VER!!! database" admin
fi
message="$message \nThere was an error trying to dump database $db, please check for table errors in this db. Forcing a backup of the corrupted DB."
/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --socket=!!!SOCKET!!! --force --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db"-failed.dump || message="$message \nFailed to force backup of corrupted db $db as $db-failed.dump" >&2
if [ "$fixtables" = "enabled" ]; then
repair="failure"
message="$message \nTrying to auto-repair the db and do a backup after..."
/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqlcheck --socket=!!!SOCKET!!! -s --auto-repair -c "$db" && \
/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --socket=!!!SOCKET!!! --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db".dump && repair="success"
message="$message \n => $repair"
fi
echo $message
echo $message | /usr/bin/mail -s "error on backup of $db MariaDB database" admin
}
if [ "$status" = "disabled" ]
then
echo "mysqld is disabled - no tables dumped" >&2
exit 0
fi
for db in $(/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql --socket=!!!SOCKET!!! -BNre "show databases;"|egrep -vi "^information_schema$|^performance_schema$")
do
/opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqldump --socket=!!!SOCKET!!! --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mariadb!!!VER!!!/"$db".dump || onfailure $db
done

@ -1,17 +0,0 @@
#!/bin/sh
status=$(/sbin/e-smith/config getprop mariadb!!!VER!!!-mariadb status)
if [ "$status" = "disabled" ]
then
echo "mysqld is disabled - no tables restored" >&2
exit 0
fi
/bin/rm -f /home/e-smith/db/mariadb!!!VER!!!/information_schema.dump
/bin/rm -f /home/e-smith/db/mariadb!!!VER!!!/performance_schema.dump
if [ ! -f /var/opt/rh/rh-mariadb!!!VER!!!/lib/mysql/mysql/user.frm ]
then
for db in $(ls /home/e-smith/db/mariadb!!!VER!!!/*.dump 2> /dev/null | grep -v '/mysql.dump')
do
mv $db /etc/e-smith/sql/init!!!VER!!!/01_$(basename $db .dump).sql
done
fi

@ -1,5 +0,0 @@
socket=/var/lib/mysql/mariadb!!!VER!!!.sock
{
my $localonly = ${'mariadb!!!VER!!!-mariadb'}{'LocalNetworkingOnly'} || "no";
$OUT = ($localonly eq 'yes') ? "skip-networking" : "skip-networking=0\n# networking is enabled";
}

@ -1,7 +0,0 @@
{
$OUT = "";
my $localonly = ${'mariadb!!!VER!!!-mariadb'}{'LocalNetworkingOnly'} || "no";
# define port
my $port = ${'mariadb!!!VER!!!-mariadb'}{'port'} || "!!!PORT!!!";
$OUT .= ($localonly eq 'yes') ? "#no port as skip-networking\n" : "port=$port\n";
}

@ -1,84 +0,0 @@
/* Server Mariadb !!!VER!!! localhost (config:root) [1] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['socket'] = '!!!SOCKET!!!';
$cfg['Servers'][$i]['compress'] = false;
# standalone or login mode
$scriptname=end(explode('/',$_SERVER['PHP_SELF']));
$scriptpath=str_replace($scriptname,"",$_SERVER['PHP_SELF']);
# standalone login part
{
my $adminaccess = ($phpmyadmin{'adminaccess'} || 'enabled');
my $multiaccess = ($phpmyadmin{'multiaccess'} || 'disabled');
if (("$adminaccess" eq "enabled"))
{
$OUT .="if (\$scriptpath==\"/phpmyadmin/\" && \$_SERVER['PHP_AUTH_USER']=='admin')\n";
$OUT .="{\n";
$OUT .="\$cfg['Servers'][\$i]['auth_type'] = 'config';\n";
$OUT .="\$cfg['Servers'][\$i]['user'] = 'root';\n";
open (PW, "/etc/openldap/ldap.pw")
|| die "Could not read LDAP password.\n";
my $pw = <PW>;
chomp ($pw);
close PW;
$OUT .="\$cfg['Servers'][\$i]['password'] = '$pw';\n";
$OUT .="}";
}
else
{
$OUT .="# standelaone admin configuration disabled";
}
}
# end of standalone login part
# multiuser login part
{
my $adminaccess = ($phpmyadmin{'adminaccess'} || 'enabled');
my $multiaccess = ($phpmyadmin{'multiaccess'} || 'disabled');
$OUT .="\n";
if (("$multiaccess" eq "enabled") && ("$adminaccess" eq "enabled"))
{
$OUT .="if (\$scriptpath==\"/phpmyadmin-multi/\")\n";
$OUT .="{\n";
}
if (("$multiaccess" eq "enabled"))
{
$OUT .="\$cfg['Servers'][\$i]['auth_type'] = 'cookie';\n";
my $secret = ${'httpd-admin'}{TKTAuthSecret} || "34322500-7330-4400-423A-3A00434F5245";
$OUT .="\$cfg['blowfish_secret'] = '$secret';\n";
}
else
{
$OUT .="# multiuser disabled\n";
}
if (("$multiaccess" eq "enabled") && ("$adminaccess" eq "enabled"))
{
$OUT .="}\n";
}
}
# end of multiuser login part
$cfg['Servers'][$i]['controluser'] = "";
$cfg['Servers'][$i]['controlpass'] = "";
$cfg['Servers'][$i]['only_db'] = "";
$cfg['Servers'][$i]['hide_db'] = "";
$cfg['Servers'][$i]['verbose'] = 'Mariadb!!!VER!!!';// here is the name as it appears in phpmyadmin
$cfg['Servers'][$i]['pmadb'] = "";
$cfg['Servers'][$i]['bookmarktable'] = "";
$cfg['Servers'][$i]['relation'] = "";
$cfg['Servers'][$i]['table_info'] = "";
$cfg['Servers'][$i]['table_coords'] = "";
$cfg['Servers'][$i]['pdf_pages'] = "";
$cfg['Servers'][$i]['column_info'] = "";
$cfg['Servers'][$i]['history'] = "";
$cfg['Servers'][$i]['verbose_check'] = TRUE;
$cfg['Servers'][$i]['AllowRoot'] = TRUE;
$cfg['Servers'][$i]['AllowDeny']['order']="";
$cfg['Servers'][$i]['AllowDeny']['rules']= array();
$cfg['Servers'][$i]['AllowNoPassword']= FALSE;
$cfg['Servers'][$i]['designer_coords']= "";
$cfg['Servers'][$i]['bs_garbage_threshold']= 50;
$cfg['Servers'][$i]['bs_repository_threshold']= '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout']= 600;
$cfg['Servers'][$i]['bs_temp_log_threshold']= '32M';

@ -1,17 +0,0 @@
/var/log/mariadb!!!VER!!!/*.log {
create 640 mysql mysql
notifempty
daily
rotate 7
missingok
compress
postrotate
# just if mysqld is really running
if test -x /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqladmin && \
/usr/bin/scl enable rh-mariadb!!!VER!!! -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqladmin --socket=!!!SOCKET!!! ping &>/dev/null
then
/usr/bin/scl enable rh-mariadb!!!VER!!! -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysqladmin --socket=!!!SOCKET!!! --local flush-error-log \
flush-engine-log flush-general-log flush-slow-log
fi
endscript
}

@ -1,61 +0,0 @@
#!/usr/bin/perl -w
use strict;
use esmith::config;
use esmith::db;
use esmith::util;
my %conf;
tie %conf, 'esmith::config';
my $event = $ARGV[0];
my $file = $ARGV[1];
#---------------------------------------------------------------------------
# Check the runlevel, if we're in runlevel 7, and we're being called from
# bootstrap-console-save, then MySQL can't be running, so use bootstrap mode.
# Otherwise, just use mysql to do a straight import.
#---------------------------------------------------------------------------
my $runlevel;
open (RUNLEVEL, "-|", "/usr/bin/systemctl get-default");
(undef, $runlevel) = split(' ',<RUNLEVEL>);
close RUNLEVEL;
if ( ($runlevel ne 'multi-user.target' && $runlevel ne "sme-server.target") || $event eq 'bootstrap-console-save')
{
my $pid = open(KID, "|-");
if (defined $pid)
{
if ($pid)
{
open(SQL, "<$file");
print KID foreach (<SQL>);
close SQL;
close(KID);
waitpid $pid,0;
}
else
{
# Find our mysqld binary
my $mysqld = "/opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld";
if (-f "/opt/rh/rh-mariadb!!!VER!!!/root/usr/sbin/mysqld") {
$mysqld = "/opt/rh/rh-mariadb!!!VER!!!/root/usr/sbin/mysqld";
}
# Hard-code user, since it is set in mysqld_safe currently.
# See http://bugs.mysql.com/2163
exec("/usr/bin/scl enable rh-mariadb!!!VER!!! -- $mysqld", qw(--bootstrap --user=mysql --skip-grant-tables));
}
}
else
{
warn "Couldn't fork: $!";
}
}
else
{
system("/usr/bin/scl enable rh-mariadb!!!VER!!! -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql < $file");
}
exit(0);

@ -1,58 +0,0 @@
#!/bin/bash
datadir="/var/opt/rh/rh-mariadb!!!VER!!!/lib/mysql"
# We have to re-enable SCL environment, because /sbin/service
# clears almost all environment variables.
# Since X_SCLS is cleared as well, we lose information about other
# collections enabled.
. /opt/rh/rh-mariadb!!!VER!!!/service-environment
for sclname in $RH_MARIADB!!!VER!!!_SCLS_ENABLED ; do
. /opt/rh/$sclname/enable
export X_SCLS="$X_SCLS $sclname"
done
# we want start daemon only inside "scl enable" invocation
if ! scl_enabled $sclname ; then
echo "Collection $sclname has to be listed in /opt/rh/rh-mariadb!!!VER!!!/service-environment"
exit 1
fi
if [ ! -f $datadir/mysql/user.frm ]
then
touch /var/log/mariadb!!!VER!!!/mariadb.log
chown mysql:mysql /var/log/mariadb!!!VER!!!/mariadb.log
chmod 0640 /var/log/mariadb!!!VER!!!/mariadb.log
echo "Initializing mariadb!!!VER!!! database"
/opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysql-prepare-db-dir
ret=$?
if [ $ret -ne 0 ] ; then
echo "Initialization of MySQL database failed." >&2
echo "Perhaps /etc/opt/rh/rh-mariadb!!!VER!!!/my.cnf is misconfigured." >&2
# Clean up any partially-created database files
if [ ! -e "$datadir/mysql/user.frm" ] ; then
rm -rf "$datadir"/*
fi
exit $ret
fi
# set root password , 104 and above have a different syntax and allow root passwordless access
if [ !!!VER!!! -le 103 ]
then
/opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld --bootstrap --datadir="$datadir" --user="mysql" < /var/lib/mysql/set.password2
fi
# upgrade does not need to be run on a fresh datadir
#echo "5.7.24" >"$datadir/mysql_upgrade_info"
# In case we're running as root, make sure files are owned properly
chown -R "mysql:mysql" "$datadir"
if [ -f /home/e-smith/db/mariadb!!!VER!!!/mysql.dump ]
then
/sbin/e-smith/expand-template /etc/e-smith/sql/init!!!VER!!!/00_restore_dumped_dbs
fi
else
# else we set root password anyway ! just to be sure ! 104 and above have a different syntax and allow root passwordless access
if [ !!!VER!!! -le 103 ]
then
/opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld --bootstrap --datadir="$datadir" --user="mysql" < /var/lib/mysql/set.password2
fi
exit 0
fi

@ -1,82 +0,0 @@
#!/bin/sh
#----------------------------------------------------------------------
# copyright (C) 2022 Koozali Foundation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
# We have to re-enable SCL environment, because /sbin/service
# clears almost all environment variables.
# Since X_SCLS is cleared as well, we lose information about other
# collections enabled.
. /opt/rh/rh-mariadb!!!VER!!!/service-environment
for sclname in $RH_MARIADB!!!VER!!!_SCLS_ENABLED ; do
. /opt/rh/$sclname/enable
export X_SCLS="$X_SCLS $sclname"
done
# we want start daemon only inside "scl enable" invocation
if ! scl_enabled $sclname ; then
echo "Collection $sclname has to be listed in /opt/rh/rh-mariadb!!!VER!!!/service-environment"
exit 1
fi
# Source function library.
. /etc/rc.d/init.d/functions
if [ $# -lt 1 ]; then
echo "Usage: $0 <start|restart>" 1>&2
exit 1
fi
# We should only do something if $1 is 'start'.
if [ $1 != "start" ] && [ $1 != "restart" ]; then
exit 0
fi
for i in $(seq 1 10)
do
if test -e !!!SOCKET!!!
then
exit_value=0
HOME=/root
export HOME
for link in $(find /etc/e-smith/sql/init!!!VER!!! -type f -o -type l | sort)
do
F=$(basename $link | sed s/S[0-9][0-9]//)
case $F in
*.sql)
action "Loading $F into mariadb !!!VER!!!" /opt/rh/rh-mariadb!!!VER!!!/root/usr/bin/mysql --socket=!!!SOCKET!!! < $link && /bin/rm $link
;;
*)
action "Loading $F into mariadb !!!VER!!!" $link && /bin/rm $link
;;
esac
# Record any failure for the final return value.
if [ $? -ne 0 ]; then
exit_value=1
fi
done
exit $exit_value
fi
echo "Waiting for mysql to startup" >&2
sleep 2
done
exit 1

@ -1,53 +0,0 @@
[Unit]
Description=Mariadb !!!VER!!! database server
After=syslog.target
After=network.target
[Service]
Type=simple
User=root
Group=root
PIDFile=/var/run/rh-mariadb!!!VER!!!-mariadb/mariadb.pid
# Load collections set to enabled for this service
EnvironmentFile=/opt/rh/rh-mariadb!!!VER!!!/service-environment
#ours : we need root user as + and ! are not yet supported
ExecStartPre=-/sbin/e-smith/service-status mariadb!!!VER!!!-mariadb
ExecStartPre=-/sbin/e-smith/expand-template /var/lib/mysql/set.password
ExecStartPre=-/sbin/e-smith/expand-template /root/.my.cnf
ExecStartPre=-/sbin/e-smith/expand-template /etc/my.cnf
ExecStartPre=-/sbin/e-smith/expand-template /etc/opt/rh/rh-mariadb!!!VER!!!/my.cnf
ExecStartPre=/sbin/e-smith/systemd/mariadb!!!VER!!!-initialize
# We want to start server only inside "scl enable" invocation
ExecStartPre=/usr/bin/scl enable $RH_MARIADB!!!VER!!!_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mariadb!!!VER!!!
ExecStartPre=/usr/bin/scl enable $RH_MARIADB!!!VER!!!_SCLS_ENABLED -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysql-check-socket
ExecStartPre=/usr/bin/scl enable $RH_MARIADB!!!VER!!!_SCLS_ENABLED -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysql-prepare-db-dir %n
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=/opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld_safe-scl-helper enable $RH_MARIADB!!!VER!!!_SCLS_ENABLED -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysqld \
--defaults-file=/etc/my.cnf \
--datadir=/var/opt/rh/rh-mariadb!!!VER!!!/lib/mysql \
--user=mysql \
--basedir=/opt/rh/rh-mariadb!!!VER!!!/root/usr \
--pid-file=/var/run/rh-mariadb!!!VER!!!-mariadb/mariadb.pid
ExecStartPost=/usr/bin/scl enable $RH_MARIADB!!!VER!!!_SCLS_ENABLED -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysql-check-upgrade
ExecStopPost=/usr/bin/scl enable $RH_MARIADB!!!VER!!!_SCLS_ENABLED -- /opt/rh/rh-mariadb!!!VER!!!/root/usr/libexec/mysql-wait-stop
#ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
# Place temp files in a secure directory, not /tmp
PrivateTmp=true
Restart=on-failure
RestartPreventExitStatus=1
[Install]
WantedBy=sme-server.target

@ -1,20 +0,0 @@
[Unit]
SourcePath=/sbin/e-smith/systemd/mariadb!!!VER!!!-mysql.init
Description=Koozali SME Server mysql DB injector for mariadb!!!VER!!!
After=mariadb!!!VER!!!-mariadb.service
Requires=mariadb!!!VER!!!-mariadb.service
[Service]
Type=oneshot
Restart=no
TimeoutSec=10min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/sbin/e-smith/systemd/mariadb!!!VER!!!-mysql.init start
ExecStop=/sbin/e-smith/systemd/mariadb!!!VER!!!-mysql.init stop
[Install]
WantedBy=sme-server.target

@ -1,6 +1,6 @@
{
# InnoDB is mandatory with mariadb
my $a = $DB->get("mariadb") or return;
return unless (exists $mariadb{'InnoDB'});
$DB->get_prop_and_delete('mariadb', 'InnoDB');
$DB->get_prop_and_delete('mariadb', 'InnoDB') if (exists $mariadb{'InnoDB'});
$DB->get_prop_and_delete('mariadb', 'innodb_file_format') if (exists $mariadb{'innodb_file_format'});
}

@ -1,7 +1,7 @@
#! /bin/sh
( cat /home/e-smith/db/mysql/mysql.dump ;
cat /var/lib/mysql/set.password ) | mysql || exit 1
cat /var/lib/mysql.private/set.password ) | mysql || exit 1
/usr/bin/mysql_upgrade
/bin/rm /var/run/mariadb/mariadb.pid
/usr/bin/systemctl restart mariadb.service

@ -1,14 +1,5 @@
#innodb
{# https://mariadb.com/kb/en/innodb-system-variables/#innodb_large_prefix
#default Off up to 10.2.1
# removed in 10.3.1 and 10.6.0
# keep it there up to 10.2.2
}innodb_large_prefix=1
{#https://mariadb.com/kb/en/innodb-system-variables/#innodb_file_format
# default is antelope up to 10.2.1
# keep it up to 10.2.2
}innodb_file_format={ $mariadb{'innodb_file_format'}||'barracuda' }
{# enabled is already the default
}innodb_file_per_table={ $mariadb{'innodb_file_per_table'}||'1' }

@ -1,4 +1,2 @@
{ # allow backwards-compatibility with safe_mysqld (mysql < 4.0)
-f "/usr/bin/mysqld_safe" ? "[mysqld_safe]" : "[safe_mysqld]";
}
[mysqld_safe]

@ -1,14 +1,4 @@
# *-mysql.init
:programname, isequal, "mysql.init" /var/log/mysql.init/mysql.init.log
& stop
:programname, isequal, "mariadb105-mysql.init" /var/log/mysql.init/mariadb105-mysql.init.log
& stop
:programname, isequal, "mariadb103-mysql.init" /var/log/mysql.init/mariadb103-mysql.init.log
& stop
:programname, isequal, "mariadb102-mysql.init" /var/log/mysql.init/mariadb102-mysql.init.log
& stop
:programname, isequal, "mariadb101-mysql.init" /var/log/mysql.init/mariadb101-mysql.init.log
& stop
:programname, isequal, "mysql57-mysql.init" /var/log/mysql.init/mysql57-mysql.init.log
& stop

@ -1,12 +0,0 @@
{
use esmith::util;
my $pw = esmith::util::LdapPassword();
$OUT .= "use mysql;\n";
$OUT .= "ALTER TABLE user MODIFY Password char(41) NOT NULL default '';\n";
$OUT .= "UPDATE user SET password=password('$pw') WHERE user='root';\n";
$OUT .= "DELETE FROM db WHERE user='';\n";
$OUT .= "DELETE FROM user WHERE user='';\n";
$OUT .= "FLUSH PRIVILEGES;\n";
}

@ -1,17 +0,0 @@
/var/log/mariadb/*.log {
create 640 mysql mysql
notifempty
daily
rotate 3
missingok
compress
postrotate
# just if mysqld is really running
if test -x /usr/bin/mysqladmin && \
/usr/bin/mysqladmin ping &>/dev/null
then
/usr/bin/mysqladmin flush-logs
fi
endscript
}

@ -3,12 +3,9 @@
exec 2>&1
if [ ! -f /var/lib/mysql/mysql/user.frm ]
then
setuidgid mysql sh /usr/bin/mysql_install_db
/usr/libexec/mysqld --bootstrap --user=mysql --skip-grant-tables < /var/lib/mysql/set.password
setuidgid mysql sh /usr/bin/mysql_install_db --rpm --skip-test-db --user=mysql --group=mysql
if [ -f /home/e-smith/db/mysql/mysql.dump ]
then
/sbin/e-smith/expand-template /etc/e-smith/sql/init/00_restore_dumped_dbs
fi
else
/usr/libexec/mysqld --bootstrap --user=mysql --skip-grant-tables < /var/lib/mysql/set.password
fi

@ -2,13 +2,13 @@
for i in $(seq 1 20);
do
if [ -S !!!SOCKET!!! ]
if [ -S /var/lib/mysql/mysql.sock ]
then
/usr/bin/mysql!!!VER!!! < /var/lib/mysql/set.password2
/usr/bin/mysql < /var/lib/mysql.private/set.password
echo "root password set"
exit 0
fi
echo waiting for rh-mariadb105-mariadb to start to set root password
echo waiting for mariadb to start to set root password
sleep 1
done
echo failed to set root password

@ -65,7 +65,7 @@ do
done
exit $exit_value
fi
echo "Waiting for mysql to startup" >&2
echo "Waiting for mariadb to startup" >&2
sleep 2
done

@ -4,15 +4,15 @@ After=syslog.target
After=network.target
[Service]
Type=simple
User=root
Group=root
#allow our expand-templates
PermissionsStartOnly=true
#reset
ExecStartPre=
#ours : we need root user as + and ! are not yet supported
ExecStartPre=/usr/libexec/mysql-check-socket
ExecStartPre=-/sbin/e-smith/service-status mariadb
ExecStartPre=-/sbin/e-smith/expand-template /var/lib/mysql/set.password
ExecStartPre=-/sbin/e-smith/expand-template /var/lib/mysql.private/set.password
ExecStartPre=-/sbin/e-smith/expand-template /root/.my.cnf
ExecStartPre=-/sbin/e-smith/expand-template /etc/my.cnf
ExecStartPre=/sbin/e-smith/systemd/mariadb-initialize
@ -27,16 +27,7 @@ ExecStart=/usr/libexec/mysqld \
--user=mysql \
--pid-file=/var/run/mariadb/mariadb.pid
#reset
ExecStartPost=
#ours
ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
# Place temp files in a secure directory, not /tmp
PrivateTmp=true
ExecStartPost=-/sbin/e-smith/systemd/mariadb-post
[Install]
WantedBy=sme-server.target

@ -2,7 +2,7 @@ Summary: Koozali SME Server specific mysql configuration and templates.
%define name smeserver-mysql
Name: %{name}
%define version 11.0.0
%define release 3
%define release 4
Version: %{version}
Release: %{release}%{?dist}
License: GPL
@ -13,8 +13,8 @@ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
BuildArchitectures: noarch
Requires: mariadb-server
# mariadb after 5.5 /in Centos 8 will package mysql_upgrade in mariadb-server-utils
# Requires: /usr/bin/mysql_upgrade
Requires: mariadb
Requires: /usr/bin/mysql_upgrade
Requires: mariadb > 10.5.0
Requires: smeserver-base
Requires: smeserver-lib >= 1.15.1-19
Provides: e-smith-mysql = 2.7.0
@ -31,233 +31,22 @@ mysql.
%setup
%build
for ver in 101 102 103 105
do
mkdir root$ver
done
perl createlinks
#########################################
# full job to create all needed version
#########################################
declare -A versions=([101]="10.1" [102]="10.2" [103]="10.3" [105]="10.5")
declare -A ports=([101]="3310" [102]="3311" [103]="3312" [105]="3313")
for ver in 101 102 103 105
do
##TODO seen those
# default values from /etc/opt/rh/rh-mariadb101/my.cnf.d/mariadb-server.cnf
basedir="/opt/rh/rh-mariadb$ver/root/usr"
datadir="/var/opt/rh/rh-mariadb$ver/lib/mysql"
socket="/var/lib/mysql/mariadb$ver.sock"
logerror="/var//log/mariadb$ver/mariadb.log"
#"/var/opt/rh/rh-mariadb$ver/log/mariadb/mariadb.log"
pidfile="/var/run/rh-mariadb$ver-mariadb/mariadb.pid"
vers="${versions[$ver]}"
port="${ports[$ver]}"
# we could choose to override /etc/opt/rh/rh-mariadb101/my.cnf or to force to share /etc/mariadb.log
##Folders
mkdir -p root$ver/etc/e-smith/sql/init$ver
mkdir -p root$ver/home/e-smith/db/mariadb$ver
mkdir -p root$ver/var/log/mariadb$ver
#mkdir -p root$ver/home/e-smith/db/mysql/mariadb$ver
mkdir -p root$ver/etc/e-smith/events/actions
# create configuration db default
#rm -rf etc/e-smith/db/configuration
mkdir -p root$ver/etc/e-smith/db/configuration/{defaults/mariadb$ver-mariadb,defaults/mariadb$ver-mysql.init,migrate}
echo "yes" > root$ver/etc/e-smith/db/configuration/defaults/mariadb$ver-mariadb/LocalNetworkingOnly
echo "enabled" > root$ver/etc/e-smith/db/configuration/defaults/mariadb$ver-mariadb/status
echo "service" > root$ver/etc/e-smith/db/configuration/defaults/mariadb$ver-mariadb/type
echo "enabled" > root$ver/etc/e-smith/db/configuration/defaults/mariadb$ver-mysql.init/status
echo "service" > root$ver/etc/e-smith/db/configuration/defaults/mariadb$ver-mysql.init/type
# create templates.metadata
## for /etc/e-smith/templates/etc/my.cnf/ => /etc/opt/rh/rh-mariadb$ver/my.cnf
mkdir -p root$ver/etc/e-smith/templates.metadata/etc/opt/rh/rh-mariadb$ver
echo 'TEMPLATE_PATH="/etc/my.cnf"' > root$ver/etc/e-smith/templates.metadata/etc/opt/rh/rh-mariadb$ver/my.cnf
# rename/move files
#TODO /etc/e-smith/events
mv root/etc/e-smith/events/smeserver-mariadb$ver-update root$ver/etc/e-smith/events/
#bootstrap-console-save templates + actions
mkdir -p root$ver/etc/e-smith/events/bootstrap-console-save/templates2expand/etc/e-smith/sql/
mkdir -p root$ver/etc/e-smith/events/bootstrap-console-save/templates2expand/etc/opt/rh
mv root/etc/e-smith/events/bootstrap-console-save/S40mariadb$ver-load-tables root$ver/etc/e-smith/events/bootstrap-console-save/
mv root/etc/e-smith/events/bootstrap-console-save/templates2expand/etc/e-smith/sql/init$ver root$ver/etc/e-smith/events/bootstrap-console-save//templates2expand/etc/e-smith/sql/
mv root/etc/e-smith/events/bootstrap-console-save/templates2expand/etc/opt/rh/rh-mariadb$ver root$ver/etc/e-smith/events/bootstrap-console-save//templates2expand/etc/opt/rh/
#pre-backup actions
mkdir -p root$ver/etc/e-smith/events/pre-backup
mv root/etc/e-smith/events/pre-backup/S*mariadb$ver-* root$ver/etc/e-smith/events/pre-backup/
#post-backup actions
mkdir -p root$ver/etc/e-smith/events/post-backup
mv root/etc/e-smith/events/post-backup/S*mariadb$ver-* root$ver/etc/e-smith/events/post-backup/
#pre-restore actions + service
mkdir -p root$ver/etc/e-smith/events/pre-restore
mv root/etc/e-smith/events/pre-restore/S*mariadb$ver-* root$ver/etc/e-smith/events/pre-restore/
#timezone-update service
#/etc/e-smith/events/actions
#TODO
cp rootscl/etc/e-smith/events/actions/mariadb_VER_-delete-db-files root$ver/etc/e-smith/events/actions/mariadb${ver}-delete-db-files
cp rootscl/etc/e-smith/events/actions/mariadb_VER_-delete-dumped-tables root$ver/etc/e-smith/events/actions/mariadb${ver}-delete-dumped-tables
cp rootscl/etc/e-smith/events/actions/mariadb_VER_-dump-tables root$ver/etc/e-smith/events/actions/mariadb${ver}-dump-tables
cp rootscl/etc/e-smith/events/actions/mariadb_VER_-load-tables root$ver/etc/e-smith/events/actions/mariadb${ver}-load-tables
sed -i root$ver/etc/e-smith/events/actions/mariadb${ver}-delete-db-files \
-i root$ver/etc/e-smith/events/actions/mariadb${ver}-delete-dumped-tables \
-i root$ver/etc/e-smith/events/actions/mariadb${ver}-dump-tables \
-i root$ver/etc/e-smith/events/actions/mariadb${ver}-load-tables \
-e "s_!!!VER!!!_${ver}_g" \
-e "s_!!!SOCKET!!!_${socket}_g"
##metadata
mkdir -p root$ver/etc/e-smith/templates.metadata/etc/e-smith/sql
cp -a root/etc/e-smith/templates.metadata/etc/e-smith/sql/init root$ver/etc/e-smith/templates.metadata/etc/e-smith/sql/init$ver
##templates
mkdir -p root$ver/etc/e-smith/templates/etc/e-smith/sql/init$ver
cp root/etc/e-smith/templates/etc/e-smith/sql/init/* root$ver/etc/e-smith/templates/etc/e-smith/sql/init$ver
sed -i root$ver/etc/e-smith/templates/etc/e-smith/sql/init$ver/00_restore_dumped_dbs -i root$ver/etc/e-smith/templates/etc/e-smith/sql/init$ver/10mysql_upgrade \
-e "s_e-smith/db/mysql_e-smith/db/mariadb${ver}_g" \
-e "s_/usr/bin/mysql_/opt/rh/rh-mariadb${ver}/root/usr/bin/mysql_g" \
-e "s_mariadb.service_mariadb$ver-mariadb.service_" \
-e "s_/var/run/mariadb/mariadb.pid_${pidfile}_g" \
-e "s_mysqld_mariadb$ver-mariadb_g" \
-e "s_| mysql |_| /opt/rh/rh-mariadb${ver}/root/usr/bin/mysql --socket=$socket |_g" \
-e "s_mysql\_upgrade_mysql\_upgrade --socket=$socket _g"
mkdir -p root$ver/etc/e-smith/templates/etc/my.cnf
echo "
[mariadb-$vers]" > root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-05mariadb
echo "basedir=$basedir" > root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-07basedir
echo "datadir=$datadir" > root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-08datadir
#cp -a root/etc/e-smith/templates/etc/my.cnf/009socket root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-09socket
#sed -i root$ver/etc/e-smith/templates/etc/my.cnf/$ver-09socket \
# -e "s_mariadb_{'mariadb${ver}\-mariadb'}_" \
# -e "s_^socket.*_socket=${socket}_"
cp rootscl/etc/e-smith/templates/etc/my.conf/_VER_-09socket root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-09socket
sed -i root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-09socket \
-e "s_!!!VER!!!_${ver}_g" \
-e "s_!!!PORT!!!_${port}_g"
cp rootscl/etc/e-smith/templates/etc/my.conf/_VER_-10port root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-10port
sed -i root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-10port \
-e "s_!!!VER!!!_${ver}_g" \
-e "s_!!!PORT!!!_${port}_g"
cp -a root/etc/e-smith/templates/etc/my.cnf/014server_system_variables root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-14server_system_variables
sed -i root$ver/etc/e-smith/templates/etc/my.cnf/$ver-14server_system_variables \
-e "s_mariadb_mariadb${ver}\-mariadb_"
cp -a root/etc/e-smith/templates/etc/my.cnf/015logerror root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-15logerror
sed -i root$ver/etc/e-smith/templates/etc/my.cnf/${ver}-15logerror \
-e "s_^log\_error.*_log\_error=${logerror}_"
## /sbin/e-smith
mkdir -p root$ver/sbin/e-smith/systemd
#!!!VER!!!
cp rootscl/sbin/e-smith/systemd/mariadb_VER_-initialize root$ver/sbin/e-smith/systemd/mariadb${ver}-initialize
cp rootscl/sbin/e-smith/systemd/mariadb_VER_-mysql.init root$ver/sbin/e-smith/systemd/mariadb${ver}-mysql.init
cp rootscl/sbin/e-smith/mariadb_VER_-preload root$ver/sbin/e-smith/mariadb${ver}-preload
sed -i root$ver/sbin/e-smith/systemd/mariadb${ver}-initialize -i root$ver/sbin/e-smith/systemd/mariadb${ver}-mysql.init \
-i root$ver/sbin/e-smith/mariadb${ver}-preload \
-e "s_!!!VER!!!_${ver}_g" \
-e "s_!!!SOCKET!!!_${socket}_g"
if [ $ver -ge 104 ]
then
cp rootscl/sbin/e-smith/systemd/mariadb_VER_-post root$ver/sbin/e-smith/systemd/mariadb${ver}-post
sed -i root$ver/sbin/e-smith/systemd/mariadb${ver}-post -e "s_!!!VER!!!_${ver}_g" -e "s_!!!SOCKET!!!_${socket}_g"
fi
## logrotate
mkdir -p root$ver/etc/logrotate.d/
sed rootscl/etc/logrotate.d/mariadb_VER_ -e "s_!!!VER!!!_${ver}_g" \
-e "s_!!!SOCKET!!!_${socket}_g" > root$ver/etc/logrotate.d/mariadb${ver}
#systemd service
mkdir -p root$ver/usr/lib/systemd/system/
### the upstream service is called rh-mariadb$ver-mariadb.service
# we use our own /usr/lib/systemd/system/mariadb$ver-mariadb
cp rootscl/usr/lib/systemd/system/mariadb_VER_-mariadb.service root$ver/usr/lib/systemd/system/mariadb${ver}-mariadb.service
cp rootscl/usr/lib/systemd/system/mariadb_VER_-mysql.init.service root$ver/usr/lib/systemd/system/mariadb${ver}-mysql.init.service
sed -i root$ver/usr/lib/systemd/system/mariadb${ver}-mariadb.service -i root$ver/usr/lib/systemd/system/mariadb${ver}-mysql.init.service \
-e "s_!!!VER!!!_${ver}_g"
if [ $ver -ge 102 ]
then
sed -i root$ver/usr/lib/systemd/system/mariadb${ver}-mariadb.service \
-e "s/_safe//" \
-e "s/^ExecStopPost.*//";
fi
if [ $ver -ge 104 ]
then
sed -i root$ver/usr/lib/systemd/system/mariadb${ver}-mariadb.service \
-e 's_set.password$_set.password2_'
sed -i root$ver/usr/lib/systemd/system/mariadb${ver}-mariadb.service \
-e "/^#ExecStartPost=/ i ExecStartPost=\/sbin\/e-smith\/systemd\/mariadb${ver}-post"
fi
#### TODO check it is similar to rh one and functional !
#/usr/bin to ease user
mkdir root$ver/usr/bin
for i in mysql mysqlshow mysqladmin mysqldump mysqlimport mysqlbinlog
do
echo "/opt/rh/rh-mariadb${ver}/root/usr/bin/$i --socket=/var/lib/mysql/mariadb${ver}.sock \"\$@\"" >root$ver/usr/bin/$i${ver}
done
#phpMyAdmin template
mkdir -p root$ver/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/
sed rootscl/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/11configMysql_VER_ \
-e "s_!!!SOCKET!!!_${socket}_g" \
-e "s_!!!VER!!!_${ver}_g" > root$ver/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/11configMysql${ver}
done
###################################################
# end of per version generation
##################################################
%install
rm -rf $RPM_BUILD_ROOT
(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT)
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
--file "/sbin/e-smith/systemd/mariadb-initialize" 'attr(0554,root,root)' \
--file "/sbin/e-smith/systemd/mariadb-post" 'attr(0554,root,root)' \
--file "/sbin/e-smith/systemd/mysql.init" 'attr(0554,root,root)' \
--dir '/home/e-smith/db/mysql' 'attr(0750,root,root)' \
--dir "/var/log/mariadb" 'attr(0750,mysql,mysql)' \
--dir "/var/log/mysql.init" 'attr(0750,root,root)' \
--dir "/var/lib/mysql.private" 'attr(0751,mysql,mysql)' \
> %{name}-%{version}-filelist
echo "%doc COPYING" >> %{name}-%{version}-filelist
for ver in 101 102 103 105
do
#rm -rf $RPM_BUILD_ROOT
(cd root$ver ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT)
/sbin/e-smith/genfilelist root$ver/ \
--file "/sbin/e-smith/systemd/mariadb$ver-initialize" 'attr(0554,root,root)' \
--file "/sbin/e-smith/systemd/mariadb$ver-mysql.init" 'attr(0554,root,root)' \
--file "/sbin/e-smith/systemd/mariadb$ver-post" 'attr(0554,root,root)' \
--dir "/home/e-smith/db/mariadb$ver" 'attr(0750,root,root)' \
--dir "/var/log/mariadb$ver" 'attr(0750,mysql,mysql)' \
--file "/usr/bin/mysql$ver" 'attr(0554,root,root)' \
--file "/usr/bin/mysqladmin$ver" 'attr(0554,root,root)' \
--file "/usr/bin/mysqlbinlog$ver" 'attr(0554,root,root)' \
--file "/usr/bin/mysqldump$ver" 'attr(0554,root,root)' \
--file "/usr/bin/mysqlimport$ver" 'attr(0554,root,root)' \
--file "/usr/bin/mysqlshow$ver" 'attr(0554,root,root)' \
| grep -vE '/home/e-smith/db/mysql$' \
> %{name}-%{version}-filelist-mariadb$ver
echo "%doc COPYING" >> %{name}-%{version}-filelist-mariadb$ver
done
%clean
rm -rf $RPM_BUILD_ROOT
@ -276,73 +65,12 @@ fi
%files -f %{name}-%{version}-filelist
%defattr(-,root,root)
#----------------------------------------------------
%package -n smeserver-mariadb101
Summary: Koozali SME Server mariadb 10.1
Group: Database
Requires: rh-mariadb101
Requires: rh-mariadb101-mariadb
Requires: rh-mariadb101-mariadb-server
BuildRequires: e-smith-devtools >= 1.13.1-03
%description -n smeserver-mariadb101
Koozali SME Server configuration package for mariadb101 RH SCLo
%files -n smeserver-mariadb101 -f %{name}-%{version}-filelist-mariadb101
%defattr(-,root,root)
#----------------------------------------------------
%package -n smeserver-mariadb102
Summary: Koozali SME Server mariadb 10.2
Group: Database
Requires: rh-mariadb102
Requires: rh-mariadb102-mariadb
Requires: rh-mariadb102-mariadb-server
BuildRequires: e-smith-devtools >= 1.13.1-03
%description -n smeserver-mariadb102
Koozali SME Server configuration package for mariadb102 RH SCLo
%files -n smeserver-mariadb102 -f %{name}-%{version}-filelist-mariadb102
%defattr(-,root,root)
#----------------------------------------------------
%package -n smeserver-mariadb103
Summary: Koozali SME Server mariadb 10.3
Group: Database
Requires: rh-mariadb103
Requires: rh-mariadb103-mariadb
Requires: rh-mariadb103-mariadb-server
Requires: rh-mariadb103-mariadb-server-utils
BuildRequires: e-smith-devtools >= 1.13.1-03
%description -n smeserver-mariadb103
Koozali SME Server configuration package for mariadb103 RH SCLo
%files -n smeserver-mariadb103 -f %{name}-%{version}-filelist-mariadb103
%defattr(-,root,root)
#----------------------------------------------------
%package -n smeserver-mariadb105
Summary: Koozali SME Server mariadb 10.5
Group: Database
Requires: rh-mariadb105
Requires: rh-mariadb105-mariadb
Requires: rh-mariadb105-mariadb-server
Requires: rh-mariadb105-mariadb-server-utils
BuildRequires: e-smith-devtools >= 1.13.1-03
Requires: smeserver-mysql >= 2.7.0-5
%description -n smeserver-mariadb105
Koozali SME Server configuration package for mariadb105 RH SCLo
%files -n smeserver-mariadb105 -f %{name}-%{version}-filelist-mariadb105
%defattr(-,root,root)
#----------------------------------------------------
%changelog
* Fri Apr 05 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-4.sme
- tidy spec and sources for mariadb10.5 support [SME: 12524]
- try to make compatible with higher version from mariadb repo [SME: 11856]
- fix logrotate duplicate entry [SME: 12554]
* Thu Apr 04 2024 Brian Read <brianr@koozali.org> 11.0.0-3.sme
- Set license file to GPL2.0 [SME: 12577]

Loading…
Cancel
Save