17 Commits

Author SHA1 Message Date
7d26d7368d * Sun Apr 20 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-14.sme
- set innodb_page_size=64k [SME: 12982]
  breaking change, needs backup and restore of mariadb databases
- convert mysql* bins call to mariadb-* [SME: 12983]
- revert [SME: 12591]
2025-04-20 00:53:33 -04:00
b3e9d320f3 * Sun Apr 06 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-13.sme
- fix Specified key was too long with older mysql db tables [SME: 12980]
  added back mysql_upgrade in 00_restore_dumped_dbs

* Fri Apr 04 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-12.sme
- restore root user, pasword and socket login [SME: 12978]
2025-04-06 14:45:55 -04:00
e78f90c5e5 * Fri Apr 04 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-12.sme
- restore root user, pasword and socket login [SME: 12978]
2025-04-04 22:36:29 -04:00
2d41a90503 * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-11.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit
  remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
  add a tmp.d for pid file, add post action dnf script
  update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-12 23:12:13 -04:00
93c2c06fff * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-10.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit
  remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
  add a tmp.d for pid file, add post action dnf script
  update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-09 17:43:02 -04:00
3ee120228a * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit
  remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
  add a tmp.d for pid file, add post action dnf script
  update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-09 00:08:27 -05:00
e7a6e31905 * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit
  remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
  add a tmp.d for pid file, add post action dnf script
  update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-09 00:02:08 -05:00
de0996e198 * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit
  remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
  add a tmp.d for pid file, add post action dnf script
  update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-08 23:59:18 -05:00
040ed0e99f * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit, remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade
  add our tmp.d
  add post action dnf script
  update mariadb.service.d/  content
  set default to utfmb4
- TODO mysql.dump filtering [SME: 12592]
- TODO feedback plugin [SME: 12897]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-07 22:58:08 -05:00
afcd41481e * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit, remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade
  add our tmp.d
  add post action dnf script
  update mariadb.service.d/  content
  set default to utfmb4
- TODO mysql.dump filtering [SME: 12592]
- TODO feedback plugin [SME: 12897]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-07 22:32:45 -05:00
34effb2c39 * Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-01-26 16:13:15 -05:00
375ec52f86 Add *.bak to .gitignore 2024-11-12 19:20:39 +00:00
56d3583079 Deleting spurious *.spec.bak files 2024-11-12 19:20:37 +00:00
1b23159978 Update README with specific Bugzilla links with status options 2024-10-27 14:29:02 +00:00
2cea9d23a1 Update readme bugzilla link to show all outstanding bugs 2024-10-27 12:12:36 +00:00
671a8d6e5f * Mon Apr 08 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-7.sme
- add missing mysql.private folder [SME: 11856]
2024-04-08 00:28:37 -04:00
8e8cdfd86f * Sat Apr 06 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-6.sme
- backup users priv, plugins, udfs, servers, stats, timezones [SME: 12591]
2024-04-06 15:30:15 -04:00
27 changed files with 999 additions and 74 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
*.log
*spec-20*
*.tar.xz
*.bak

View File

@@ -11,7 +11,14 @@ SMEServer Koozali developed git repo for smeserver-mysql smeserver
<br />https://wiki.koozali.org/Software_Collections:MySQL
## Bugzilla
Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-mysql&product=SME%20Server%2010.X&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED)
Show list of outstanding bugs:
[All](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=NEEDINFO&bug_status=IN_PROGRESS&bug_status=RESOLVED&bug_status=VERIFIED&cf_package=smeserver-mysql&classification=SME+Server&list_id=105756&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
[Confirmed](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=CONFIRMED&cf_package=smeserver-mysql&classification=SME+Server&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
[Unconfirmed](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=UNCONFIRMED&cf_package=smeserver-mysql&classification=SME+Server&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
[Need info](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=NEEDINFO&cf_package=smeserver-mysql&classification=SME+Server&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
[In progress](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=IN_PROGRESS&cf_package=smeserver-mysql&classification=SME+Server&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
[Resolved](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=RESOLVED&cf_package=smeserver-mysql&classification=SME+Server&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
[Verified](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=VERIFIED&cf_package=smeserver-mysql&classification=SME+Server&order=changeddate+DESC%2Ccomponent%2Cpriority%2Cbug_severity&query_format=advanced)
## Description

View File

@@ -1 +0,0 @@
sme10

View File

@@ -2,6 +2,22 @@
use esmith::Build::CreateLinks qw(:all);
# we add few link fromn old mysql things to mariadb things
safe_symlink("/usr/bin/mariadb-dump","root/usr/bin/mysqldump");
safe_symlink("/usr/bin/mariadb-dumpslow","root/usr/bin/mysqldumpslow");
safe_symlink("/usr/bin/mariadb-check","root/usr/bin/mysqlcheck");
safe_symlink("/usr/bin/mariadb-admin","root/usr/bin/mysqladmin");
safe_symlink("/usr/bin/mariadb-show","root/usr/bin/mysqlshow");
safe_symlink("/usr/bin/mariadb-upgrade","root/usr/bin/mysql_upgrade");
safe_symlink("/usr/bin/mariadb","root/usr/bin/mysql");
safe_symlink("/usr/bin/mariadb-access","root/usr/bin/mysqlaccess");
safe_symlink("/usr/bin/mariadb-binlog","root/usr/bin/mysqlbinlog");
safe_symlink("/usr/bin/mariadb-convert-table-format","root/usr/bin/mysql_convert_table_format");
safe_symlink("/usr/bin/mariadb-find-rows","root/usr/bin/mysql_find_rows");
safe_symlink("/usr/bin/mariadb-fix-extensions","root/usr/bin/mysql_fix_extensions");
safe_symlink("/usr/bin/mariadb-install-db","root/usr/bin/mysql_install_db");
safe_symlink("/usr/bin/mariadb-embedded","root/usr/bin/mysql_embedded");
#--------------------------------------------------
# pre-backup actions
#--------------------------------------------------
@@ -41,7 +57,6 @@ foreach (qw(
# Move all database dumps except for mysql.dump to sql/init
event_link("mysql-load-tables", $event, "40");
templates2events("/etc/e-smith/sql/init/10mysql_upgrade", $event);
#--------------------------------------------------
@@ -70,7 +85,6 @@ safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.in
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/rsyslog");
# Move all database dumps except for mysql.dump to sql/init
event_link("mysql-load-tables", $event, "40");
templates2events("/etc/e-smith/sql/init/10mysql_upgrade", $event);
templates2events("/etc/rsyslog.conf", $event);
# systemd-specific action mandatory for this package-update event

View File

@@ -0,0 +1,2 @@
mariadb*:any:/sbin/e-smith/signal-event smeserver-mysql-update
MariaDB*:any:/sbin/e-smith/signal-event smeserver-mysql-update

View File

@@ -1,3 +1,3 @@
#! /bin/sh
[ "$1" = "pre-restore" ] || exit 0
cd /var/lib/mysql && find . -type f | xargs rm -f

View File

@@ -18,12 +18,12 @@ onfailure () {
echo $message | /usr/bin/mail -s "error on backup of $db MariaDB 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."
mysqldump --force --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db"-failed.dump || message="$message \nFailed to force backup of corrupted db $db as $db-failed.dump" >&2
mariadb-dump --force --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$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..."
mysqlcheck -s --auto-repair -c "$db" && \
mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump && repair="success"
mariadb-check -s --auto-repair -c "$db" && \
mariadb-dump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump && repair="success"
message="$message \n => $repair"
fi
echo $message
@@ -37,5 +37,18 @@ then
fi
for db in $(mysql -BNre "show databases;"|egrep -vi "^information_schema$|^performance_schema$")
do
mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump || onfailure $db
mariadb-dump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump || onfailure $db
done
# double usage as already in mysql.dump
# dump user privileges
#mariadb-dump --system=users --insert-ignore > /home/e-smith/db/mysql/mysql.privileges.dump
# dump plugins
#mariadb-dump --system=plugins --insert-ignore > /home/e-smith/db/mysql/mysql.plugins.dump
# dump udfs
#mariadb-dump --system=udfs --insert-ignore > /home/e-smith/db/mysql/mysql.udfs.dump
# dump servers
#mariadb-dump --system=servers --insert-ignore > /home/e-smith/db/mysql/mysql.servers.dump
# dump stats
#mariadb-dump --system=stats --insert-ignore > /home/e-smith/db/mysql/mysql.stats.dump
# dump timezones
#mariadb-dump --system=timezones --insert-ignore > /home/e-smith/db/mysql/mysql.timezones.dump

View File

@@ -10,7 +10,7 @@ fi
/bin/rm -f /home/e-smith/db/mysql/performance_schema.dump
if [ ! -f /var/lib/mysql/mysql/user.frm ]
then
for db in $(ls /home/e-smith/db/mysql/*.dump 2> /dev/null | grep -v '/mysql.dump')
for db in $(ls /home/e-smith/db/mysql/*.dump 2> /dev/null | grep -v '/mysql.dump'| grep -v '/mysql.privileges.dump')
do
mv $db /etc/e-smith/sql/init/01_$(basename $db .dump).sql
done

View File

@@ -1,19 +1,24 @@
#! /bin/sh
( cat /home/e-smith/db/mysql/mysql.dump ;
cat /var/lib/mysql.private/set.password ) | mysql || exit 1
/usr/bin/mysql_upgrade
/bin/rm /var/run/mariadb/mariadb.pid
# we need to filter out mysql.user table from older mariadb and from mysql
# in SME10 we added for migration creation of mysql.privileges.dump with mariadb 10.5 and newer syntax
# non RH ocmpiled version of mariadb limits MyISAM index to 1000 bytes, newer mysql db use Aria as engine for those tables
( /usr/bin/mysql_filter_user_table /home/e-smith/db/mysql/mysql.dump |sed -e 's/ENGINE=MyISAM/ENGINE=Aria/';
[ -f /home/e-smith/db/mysql/mysql.privileges.dump ] && cat /home/e-smith/db/mysql/mysql.privileges.dump;
cat /var/lib/mysql.private/set.password ) | mariadb || exit 1
/usr/bin/mariadb-upgrade
/bin/rm /run/mariadb/mariadb.pid
/usr/bin/systemctl restart mariadb.service
for i in $(seq 1 20);
do
if [ -f /var/run/mariadb/mariadb.pid ]
if [ -f /run/mariadb/mariadb.pid ]
then
/bin/rm /home/e-smith/db/mysql/mysql.dump
[ -f /home/e-smith/db/mysql/mysql.privileges.dump ] /bin/rm /home/e-smith/db/mysql/mysql.privileges.dump
exit 0
fi
echo waiting for mysqld to restart
echo waiting for mariadb to restart
sleep 1
done
echo mysqld failed to restart
echo mariadb failed to restart
exit 1

View File

@@ -1,16 +0,0 @@
#!/bin/sh
/usr/bin/mysql_upgrade
/bin/rm /var/run/mariadb/mariadb.pid
/usr/bin/systemctl restart mariadb.service
for i in $(seq 1 20);
do
if [ -f /var/run/mariadb/mariadb.pid ]
then
exit 0
fi
echo waiting for mysqld to restart
sleep 1
done
echo mysqld failed to restart
exit 1

View File

@@ -0,0 +1,3 @@
[client]
default-character-set = utf8mb4

View File

@@ -0,0 +1,3 @@
[mysql]
default-character-set = utf8mb4

View File

@@ -0,0 +1,11 @@
{
# starting mariadb 10.6 , utf8 changes to utf8mb3 (as utf8 used to be an alias of utfmb3)
# utf8 will soon be an alias of utf8mb4, and more and mroe db are demanding utf8mb4
# so we are better default to it in 2025.
# old-mode will force utf8mb3 for character-set-system
}
character-set-client-handshake = FALSE
collation-server = utf8mb4_unicode_ci
init-connect = 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'
character-set-server = utf8mb4
old-mode = ''

View File

@@ -1 +1 @@
pid-file=/var/run/mariadb/mariadb.pid
pid-file=/run/mariadb/mariadb.pid

View File

@@ -2,4 +2,9 @@
#innodb
{# enabled is already the default
}innodb_file_per_table={ $mariadb{'innodb_file_per_table'}||'1' }
# innodb_strict_mode = 0
# higher size see SME 12982
innodb_page_size=64k
innodb_log_buffer_size={ $mariadb{'innodb_log_buffer_size='}||'32M' }
innodb_buffer_pool_size={ $mariadb{'innodb_buffer_pool_size'}||'512M' }

View File

@@ -4,6 +4,14 @@
my $pw = esmith::util::LdapPassword();
$OUT .= "use mysql;\n";
$OUT .= "SET PASSWORD FOR 'root'\@localhost = PASSWORD(\"$pw\"); \n";
$OUT .= "FLUSH PRIVILEGES;\n";
$OUT .= "CREATE OR REPLACE USER 'root'\@localhost IDENTIFIED VIA unix_socket OR mysql_native_password USING PASSWORD(\"$pw\"); \n";
$OUT .= "GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION; \n";
$OUT .= "FLUSH PRIVILEGES;\n";
# will not work as requires the With_grant privilege.... but accepts second line to alter the table to give it...
#$OUT .= "GRANT PROXY ON ``@`` TO `root`\@localhost WITH GRANT OPTION;\n";
$OUT .= "REPLACE INTO `proxies_priv` (`Host`, `User`, `Proxied_host`, `Proxied_user`, `With_grant`, `Grantor`, `Timestamp`) VALUES
('localhost', 'root', '', '', 1, '', current_timestamp()),
('$SystemName.$DomainName', 'root', '', '', 1, '', current_timestamp());\n";
$OUT .= "FLUSH PRIVILEGES;\n";
}

View File

@@ -41,8 +41,8 @@ if ( ($runlevel ne 'multi-user.target' && $runlevel ne "sme-server.target") ||
{
# Find our mysqld binary
my $mysqld = "/usr/libexec/mysqld";
if (-f "/usr/sbin/mysqld") {
$mysqld = "/usr/sbin/mysqld";
if (-f "/usr/sbin/mariadbd") {
$mysqld = "/usr/sbin/mariadbd";
}
# Hard-code user, since it is set in mysqld_safe currently.
# See http://bugs.mysql.com/2163

View File

@@ -3,9 +3,13 @@
exec 2>&1
if [ ! -f /var/lib/mysql/mysql/user.frm ]
then
setuidgid mysql sh /usr/bin/mysql_install_db --rpm --skip-test-db --user=mysql --group=mysql
setuidgid mysql sh /usr/bin/mariadb-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
fi
# set root password and access to socket passwordless
/usr/sbin/mariadbd --socket=/var/lib/mysql/mysql.sock --bootstrap --user=mysql < /var/lib/mysql.private/set.password
exit 0

View File

@@ -1,18 +0,0 @@
#!/bin/bash
for i in $(seq 1 20);
do
if [ -S /var/lib/mysql/mysql.sock ]
then
/usr/bin/mysql < /var/lib/mysql.private/set.password
echo "root password set"
exit 0
fi
echo waiting for mariadb to start to set root password
sleep 1
done
echo failed to set root password
# we fail silently, mariadb will still work, only issue is for phpmyadmin
# and non socket access
exit 0

View File

@@ -46,13 +46,13 @@ do
F=$(basename $link | sed 's/S\?[0-9][0-9]_\?//')
case $F in
*.sql)
action "Loading $F into mysql" perl -e '
action "Loading $F into mariadb" perl -e '
open (STDERR, "|/usr/bin/logger -p local1.info -t mysql.init");
open (STDOUT, ">&STDERR");
exec "/usr/bin/mysql";' < $link && /bin/rm $link
exec "/usr/bin/mariadb";' < $link && /bin/rm $link
;;
*)
action "Loading $F into mysql" perl -e '
action "Loading $F into mariadb" perl -e '
open (STDERR, "|/usr/bin/logger -p local1.info -t mysql.init");
open (STDOUT, ">&STDERR");
exec shift; ' $link && /bin/rm $link

View File

@@ -0,0 +1,830 @@
#!/bin/env bash
#
# Filter the given tables out of a MySQL/MariaDB dump file.
#
#
# The MIT License (MIT)
#
# Copyright © 2023 metaworx resonare rüegg, Martin Rüegg, Switzerland. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software. All redistributions must retain an intact copy of this copyright notice and disclaimer.
#
# Distributions of all or part of the Software intended to be used by the recipients as they would use the unmodified
# Software, containing modifications that substantially alter, remove, or disable functionality of the Software, outside
# of the documented configuration mechanisms provided by the Software, shall be modified such that the Original Author's
# bug reporting email addresses and urls are either replaced with the contact information of the parties responsible for
# the changes, or removed entirely.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mysql_filter_tables()
{
local version='mysql_filter_tables v1.4.5' url='https://gist.github.com/martin-rueegg/e247d99cc7402a4f1456c059c5d050ac';
local help_condensed='
Usage:
mysql_filter_tables [option] [exclude ...] # Use % as wildcard (use "%%" for "%")
mysql_filter_tables info-option # Print info and exit
Options:
-s|--show show generated sed command, rather than executing it
-i|--input file read from file, rather than standard input
-o|--output file write result to file, rather than standard output
-f|--force overwrite output file, if exists
-u|-ui|--unzip unzip input stream. Use with -i to read from file
-z|-zo|--zip zip ouput stream. Use with -o to write to file
-g|-gi|--gunzip gunzip input stream. Use with -i to read from file
-G|-go|--gzip gzip ouput stream. Use with -o to write to file
-h show this help
-hh|--help show more help
-V|--version show version
-1|--one-line [-m] show a one-liner that can be easily used in other scripts.
--copyright|--credits|--license|--changelog
Use --help for more information.
Use --credits for copyright, license, and credits.
';
local help='
Filter the given tables out of a MySQL/MariaDB dump file.
Accepts a list of tables to exclude (case-insensitive).
Eg. $ mysql_filter_tables "%session%" "action_log" "%_cache"
removes both one-line inserts, as well as blocks like the following:
# INSERT INTO `log` (`id`, `data`)
# VALUES
# (1,'"'"'The log content'"'"'),
# (2,'"'"'The log content'"'"');
Usage:
mysql_filter_tables [cmd-option] [exclude ...] # Filter stream
mysql_filter_tables info-option # Print info and exit
Arguments:
exclude:
- a plain table name
- a table name pattern, using % as wildcard (use "%%" for "%")
If no argument is given, the stream is simply cat through.
Options:
Command Options:
-s
--show
show generated sed command, rather than executing it.
-i
--input file
read from file, rather than standard input
-o
--output file
write result to file, rather than standard output
-f
--force
overwrite output file, if exists
-u
-ui
--unzip
unzip input stream. Use with -i to read from file
-z
-zo
--zip
zip ouput stream. Use with -o to write to file
-g
-gi
--gunzip
gunzip input stream. Use with -i to read from file
-G
-go
--gzip
gzip ouput stream. Use with -o to write to file
Info Options:
-h show usage help only
-hh|--help show this help
-V|--version show version
-1|--one-line [-m] show a one-liner that can be easily used in other scripts.
(Does not support any info options, except -V;
add -m to get a minimal version, not supporting long options)
--copyright show copyright, license, and credits
--credits show copyright, license, and credits
--license show copyright, license, and credits
--changelog show change log
Examples:
Show what will be filtered:
$ mysql_filter_tables --show log
$ mysql_filter_tables --show "%session%" "action_log" "%_cache"
$ mysql_filter_tables --show -- "-h" # in case your table name is "-h"
Usage with plain SQL file:
$ mysql_filter_tables log <big.sql >clean.sql
$ cat big.sql | mysql_filter_tables log >clean.sql
Import plain SQL dump into mysql:
$ MYSQL_PWD=secret mysql_filter_tables -i big.sql "%_cache" | mysql -u user -D database
If source is compressed:
$ mysql_filter_tables -i big.sql.zip --unzip -o clean.sql "%session%" "%_cache"
$ mysql_filter_tables -i big.sql.gz --gunzip -o clean.sql "%session%" "%_cache"
Installation:
1. Download file from github.com
$ wget '"$url"'/raw/mysql_filter_tables.sh
2.a) Source the file, and then use the function in the shell:
$ source mysql_filter_tables.sh
$ mysql_filter_tables --help
2.b) Mark the file executable und use it as script
$ chmod a+x mysql_filter_tables.sh
$ ./mysql_filter_tables.sh --help
Dependencies:
- `bash`
- `sed`, `cat`
- `zip`, `funzip`
- `gzip`, `zcat`
Note:
This is experiential software. Use at your own risk. Double-check the output
before importing it into a database. Keep the original as backup!
It is recommended to use --ignore-table=tablename with mysqldump, rather than
piping the output of mysqldump into mysql_filter_tables.
Run with --credits for copyright, license, and credits.
Run with -h for condensed usage help
';
local credits='
Copyright © 2023 metaworx resonare rüegg, Martin Rüegg, Switzerland. All Rights Reserved.
Author:
Martin Rüegg https://stackoverflow.com/users/3102305/martin-r%c3%bcegg
'"$url"'
Credits:
feskr https://stackoverflow.com/users/1180123/feskr
https://stackoverflow.com/a/51981034
dgo https://stackoverflow.com/users/508276/dgo
https://stackoverflow.com/a/53008691
duzun https://stackoverflow.com/users/1242333/duzun
https://stackoverflow.com/a/56988251
julesezaar https://stackoverflow.com/users/5418514/julesezaar
https://stackoverflow.com/a/56988251
user5754163 https://stackoverflow.com/users/5754163/user5754163
https://stackoverflow.com/a/34642589/3102305
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software. All redistributions must retain an intact copy of this copyright notice and disclaimer.
Distributions of all or part of the Software intended to be used by the recipients as they would use the unmodified
Software, containing modifications that substantially alter, remove, or disable functionality of the Software, outside
of the documented configuration mechanisms provided by the Software, shall be modified such that the Original Author'"'"'s
bug reporting email addresses and urls are either replaced with the contact information of the parties responsible for
the changes, or removed entirely.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
';
local changelog='
v1.3.7 2023-10-22
Initial public version
v1.4.5 2023-10-23
- Enh: Add options: -s, -hh, --changelog
- Enh: for --one-line, add -m option for [minimal] version, and -d option, for debugging
- Enh: Print command by default. --show will _only_ print, while --quiet will _only_ execute.
- Enh: Show error for _any_ unsupported option. -- is now required, if the first table name starts with a dash
- Fix: script would fail if no table name, but input/output options where provided
- Fix: use funzip, rather than unzip
v1.4.5-1 2025-03-08
- remove create table for the filter
- do not change existing create lines
';
e()
{
echo "$@"
}
main()
{
if (( $# == 0 )); then
# no need for further argument detection. Just cat through ... :-)
e "# $version: \$ cat" >&2
cat
fi
err()
{
e;
e "$version";
e;
printf "ERROR: $@";
e "$help_condensed";
} >&2
not_implemented()
{
err "$@ not implemented"
}
case "$1" in
-h)
e;
e "$version";
e "$help_condensed";
return 1;
;;
-hh | --help)
e;
e "$version";
e "$help";
return 1;
;;
-V | --version)
e "$version";
return 1;
;;
-1)
shift;
create_one_liner "$@";
return;
;;
--license | --copyright | --credits)
e;
e "$version";
e "$credits";
return 1;
;;
--changelog)
e;
e "$version";
e "$changelog";
return 1;
;;
esac
local -a pre p post
local f i o ex="--quiet and --show are mutually exclusive!"
local -i x=0
while [ -n "$1" ];
do
case "$1" in
--)
shift;
break;
;;
# check if the generated command should be printed, rather than executed
-s | --show)
(($x != 0)) && err "$ex" && return 5
# disable execution
x=-1;
# close file descriptors, if they've been opened already
[ -n "$i" ] && exec 4<&-;
[ -n "$o" ] && exec 5>&-;
;;
-q | --quiet)
(($x != 0)) && err "$ex" && return 5
# disable command print
x=1;
;;
-f | --force)
f=f;
;;
# redirect input from a file
-i | --input)
shift;
# check if file exists
[ ! -r "$1" ] \
&& err "File '$1' is not readable!" \
&& return 3;
i="<'$1' ";
# redirect from file
exec 4<"$1";
;;
# redirect output to file
-o | --output)
shift;
# check if file exists
[ -z "$f" -a -e "$1" ] \
&& err " File '$1' already exists! Remove file or use --force." \
&& return 4;
# redirect to file
o=">'$1'";
exec 5>"$1";
;;
# redirect output to file
-u | -ui | --unzip)
exec 0<&0;
pre=(funzip);
;;
# gunzip input
-g | -gi | --gunzip)
exec 0<&0;
pre=(zcat);
;;
# gzip output
-G | -go | --gzip)
post=(gzip --to-stdout);
;;
# zip output
-z | -zo | --zip)
post=(zip --quiet);
;;
-*)
not_implemented "$1";
return 2;
;;
*)
break;
;;
esac;
shift;
done;
if(($#!=0)); then
# T => tables; t => table
local T t;
for t in "$@";
do
T="$T|$(e "$t"| sed -E '
# trim
s/^[[:space:]]*//; s/[[:space:]]*$//;
# replace
# - "%" with "[^`]*", unless preceded by another "%"
s/(^|[^%])%([^%]|$)/\1[^\`]\*\2/g;
# - "%%" with "%", and ...
s/%%/%/g;
# - escape special characters "[", "]", "[", "|", "(", and ")" with "\"
s/([][|()])/\\\1/g
')";
done;
T=${T:1};
# For the given tables (or table patterns), do the following in the input stream:
p=(sed -E '
# 1. Delete all lines between and including
# a) "LOCK TABLES `table` WRITE;" and "UNLOCK TABLES" (which is used if for multi-line inserts
/LOCK TABLES `('"$T"')` WRITE;/,/^UNLOCK TABLES/d;
# b) "INSERT INTO `table`", or
# "REPLACE INTO `table`" that both _do not_ end with a semicolon [;]
# and a line that _does_ end on ");"
/^(INSERT|REPLACE)( (DELAYED|IGNORE))* INTO.*[)][^;]$/,/[)];$/d;
# 2. Delete all lines starting with
# a) "DROP TABLE `table`"
# b) "TRUNCATE TABLE `table`"
# c) "INSERT INTO `table`"
# d) "REPLACE INTO `table`"
# e) "UPDATE `table`"
/^((INSERT|REPLACE)( (DELAYED|IGNORE))* INTO|UPDATE( IGNORE)?|(DROP|TRUNCATE) TABLE( IF EXISTS)?) `('"$T"')`/d;
# 3. dumping "CREATE `table`"
/^-- Table structure for table `'"$T"'`/,/^-- Dumping data for table `'"$T"'`/d;
# 4. Replaces regular "CREATE TABLE" with "CREATE TABLE IF NOT EXISTS"
#REM s/^CREATE TABLE `/CREATE TABLE IF NOT EXISTS `/g
');
# Note:
# - the above 'INSERT INTO' may be followed by one or both DELAYED and IGNORE keywords
# - the above 'DROP TABLE' may be followed by 'IF EXISTS'
# cleanup pattern if it's being printed
p[2]="$(e "${p[2]}"|sed -E '
# remove leading space
s/^[[:space:]]*//;
# remove trailing spaces
s/[[:space:]]*$//;
# remove comments
/^#/d;
# remove empty lines
/^$/d;
'|sed '
# join lines
:a;/$/{N;s/\n//;ba}
')";
elif ((${#pre[@]}>0)); then
p=("${pre[@]}");
pre=()
elif ((${#post[@]}>0)); then
p=("${post[@]}");
post=()
else
p=(cat);
fi;
# redirect input to fd 4, if no input file is used
[ -z "$i" ] && exec 4<&0;
# redirect fd 5 to output, if no output file is used
[ -z "$o" ] && exec 5>&1;
x()
{
(($x <= 0)) && e "# $version: \$ $@" >&2
}
f()
{
# filter out known errors that are irrelevant
grep -v 'funzip error: invalid compressed data--length error' >&2
}
case $(( ((${#pre[@]} != 0)) + (2*((${#post[@]} != 0))))) in
0)
x "${p[@]}" "$i"$o
(($x >= 0)) && "${p[@]}" <&4 >&5 2> >(f);
;;
1)
x "${pre[@]}" '<&4|' "${p[@]} $o"
(($x >= 0)) && "${pre[@]}" <&4 2> >(f) | "${p[@]}" >&5 2> >(f);
;;
2)
x "${p[@]}" "$i"'|' "${post[@]}" $o
(($x >= 0)) && "${p[@]}" <&4 2> >(f) | "${post[@]}" >&5 2> >(f);
;;
3)
x "${pre[@]}" "$i"'|' "${p[@]}" '|' "${post[@]}" $o
(($x >= 0)) && "${pre[@]}" <&4 2> >(f) | "${p[@]}" | "${post[@]}" >&5 2> >(f);
;;
esac
# close file descriptors
exec 4<&-;
exec 5>&-;
} # main
create_one_liner()
{
local regex_cleanup_help_and_credits='
## regex_cleanup_help_and_credits
# remove help, help_condensed, credits variables
/^[[:space:]]*local (help|help_condensed|credits|changelog)=/,/^'"'"';$/d;
# remove "help" from err calls
s/^[[:space:]]*e "[$]help_condensed";?/e;e;e "Usage:";e " See $url";e;/;
# replace "$help_condensed" variable
#/^[[:space:]]*local (help_condensed)=/,/^'"'"';$/c\
#local help_condensed='"'"'\n\nUsage:\n See '"$url"'\n\n'"'"';
'
local regex_remove_condensed='
## regex_remove_condensed
# remove function "create_one_liner"
/^ function (create_one_liner)/,/^ };$/d;
# and it"s corresponding call
s/^([[:space:]]*)create_one_liner[[:space:]]+(.*);?$/\1not_implemented -1 \2/
'
local regex_cleanup_regex='
## regex_cleanup_regex
# for all lines between the beginning of the sed call and the end of its argument ...
/[ ()|]sed[[:space:]]+[^'"'"']*'"'"'/{
:join-line-and-strip-comment
# join with next line
N;
# check if newline is followed by quote, which would mark the last line
# in this case, place the newline _outside_ of the closing quote
s/(\n[[:space:]]*)('"'"')/\2>REGEX<\1/;
# if found, got to :last-line
t last-line;
:strip-comment
# strip leading spaces and comments (note: "#n" is _not_ a comment!)
s/;?\n[[:space:]]*#($|[^n].*|n[ ;])//;
# if found, do it again (from :join-line-and-strip-comment)
t join-line-and-strip-comment;
# strip trailing spaces
s/[[:space:]]+$//;
# strip leading spaces
s/;?\n[[:space:]]*(.*)$/;\1/;
# if found (which should always happen), do it again (from :join-line-and-strip-comment)
t join-line-and-strip-comment;
:last-line
# prepend opening quote with >REGEX< and place it on new line
s/([ ()|]sed[[:space:]]+[^'"'"']*)'"'"';?/\1\n>REGEX<'"'"'/;
# save pattern space to memory
h;
#l; # prints the pattern space for debbugging
# remove last line
s/(.*)\n[^\n]*$/\1/
#l; # prints the pattern space for debbugging
# disable default output to avoid duplicate lines
#n
# print the entire pattern space (including the newlines)
p;
# reload the saved pattern space
g
# this time, remove everythign _but_ the last line
s/.*(\n[^\n]*)$/\1/
#l; # prints the pattern space for debbugging
# start over with the last line, discarding the first, now empty, line
D;
}
'
local regex_remove_main_and_whitespaces='
## regex_remove_main_and_whitespaces
# for all lines, that do not start with the >REGEX< pattern
/^>REGEX</!{
# un-wrap unneccesary main()
/^[[:space:]]*function main [(][)]/,+1d;
/^[[:space:]]*main "[$]@"/,/[}]/d;
# remove "function" keyword
s/^([[:space:]]*)function ([_[:alnum:]]+) [(][)]/\1\2()/g;
# remove regex cleaning
#/^[[:space:]]*p\[2\]=/,/'"'"'\)";/d
# rename version variable
s/([ $])version([^_[:alnum:]])/\1v\2/g;
# rename not_implemented function
s/([^_[:alnum:]])not_implemented([^_[:alnum:]])/\1ni\2/g;
# rename not_implemented function
s/gzip --to-stdout/gzip -c/;
s/zip --quiet/zip -q/;
# remove spaces around case options
s/[[:space:]]*(\|)[[:space:]]*-/\1-/g;
# remove spaces around "&&", "||", and some comparison operators
s/[[:space:]]*(\||&&|\|\||==|!=|<=|>=)[[:space:]]*/\1/g;
# remove options --license, --changelog, -1, -h, and --help
/^[[:space:]]*(--license|--changelog|-1|-h|--help)/,/^[[:space:]]*;;$/d;
# remove spaces following braces
s/([()]) +/\1/g;
# remove spaces following redirections
s/([<>]) +([^<>])/\1\2/g;
# remove before opening brackets
s/[[:space:]]*[(]/(/g;
# remove some other non-essential stuff
s/--quiet and --show are mutually exclusive!/-q or -s ?!/
}
'
local regex_join_lines='
## regex_join_lines
# join lines, except the last one
:a;/$/{$!{N;
# remove the newline where the previous line ends on a single quote or closing bracket
s/(['"'"')])[[:space:]]*\n[[:space:]]*/\1/; ty;
# replace the newline using a space, where the previous line ends on an opening curly bracket
s/[{][[:space:]]*\n[[:space:]]*/{ /; ty;
# replace the newline using a space, where the previous line ends on a continuation-backslash
s/[\]\n[[:space:]]*/ /; ty;
# join all other lines using a ;
s/[;]?\n[[:space:]]*/;/; ba;
:y;ba}};
';
local regex_cleanup_joined_lines='
# regex_cleanup_joined_lines
# cleanup function opening
#s/[{];/{ /g;
# cleanup case ;; esac
s/( |([)]))in ;/\2 in /g
s/;;;?;?/; ;; /g;
s/; ;; esac;/;esac;/g;
# cleanup do|then
s/; ?(while|do|then|else|elif);/;\1 /g;
# remove semicolon after case bracket
s/([*]|--|--?[[:alnum:]]+)[)];/\1)/g;
# remove REGEX escaping
s/;>REGEX<'"'"'|'"'"'>REGEX<;/'"'"'/g
';
local regex_minimal='
# regex_minimal
# remove long options if there is a short one
s/ -([[:alnum:]])(\|-[-[:alnum:]]+)*\)/ -\1)/g;
# remove --show
s/local -i x=0;//
s/\)x [^;]+;/)/g
s/\)\(\(\$x>=0\)\)&&/)/g
s/ ex="-q or -s \?!";/;/
s/ -s\)(([^;]+|;[^;]+)+);;//
s/ -q\)(([^;]+|;[^;]+)+);;/ -q) ;;/
#l;
#s/;/;\n/g
#l;
s/;p\[2\]=".*'"'"'\)";/;/
#l
#s/\n//g
# remove some other non-essential stuff
s/ already exists! Remove file or use --force\./!!/
s/ is not readable!/?!/
';
local regex_version_condensed='
## regex_version_condensed
# rename the function
s/mysql_filter_tables/mysql_filter_tables_condensed/g;
# append "[condensed]" to the version information
s/(local version='"'"'[^'"'"']+)/\1 [condensed]/
'
local regex_version_oneliner='
## regex_version_oneliner
# rename the function
s/mysql_filter_tables/mysql_filter_tables_one/g;
/^[[:space:]]*local version=/{
# append "[one-liner]" to the version information
s/(local version='"'"'[^'"'"']+)/\1 [one-liner]/
ta
b
:a;
n
ba
}
'
# applied to one-liner
local regex_version_minimal='
## regex_version_minimal
# rename the function
s/mysql_filter_tables_one/mysql_filter_tables_minimal/g;
# append "[minimal]" to the version information
s/(local v='"'"'[^[]+)([^'"'"']+)?/\1[minimal]/
'
local -a R=(
"$regex_remove_condensed"
"$regex_cleanup_help_and_credits"
"$regex_cleanup_regex"
"$regex_version_oneliner"
"$regex_remove_main_and_whitespaces"
"$regex_join_lines"
"$regex_cleanup_joined_lines"
);
if [ "$1" = '-c' ]; then
shift
R=(
"$regex_remove_condensed"
"$regex_cleanup_regex"
"$regex_version_condensed"
);
elif [ "$1" = '-m' ]; then
shift
R=(
"${R[@]}"
"$regex_version_minimal"
"$regex_minimal"
)
fi
local r d="$( declare -f mysql_filter_tables )";
for r in "${R[@]}"; do
d="$(e "$d" | sed -E "$r")";
[ "$1" = '-d' ] && ( e "regex:"; e "$r"; e "$d"; e;) >&2
done;
e "$d";
}; # create_one_liner
main "$@"
}; # mysql_filter_tables
# check if the file is sourced
(return 2>/dev/null)
if [ "$?" -eq "0" ]
then
echo "mysql_filter_tables installed."
else
#otherwise, just run the function!
mysql_filter_tables "$@"
fi

View File

@@ -0,0 +1,2 @@
#!/bin/env bash
sed -E '/LOCK TABLES `(user)` WRITE;/,/^UNLOCK TABLES/d;/^(INSERT|REPLACE)( (DELAYED|IGNORE))* INTO.*[)][^;]$/,/[)];$/d;/^((INSERT|REPLACE)( (DELAYED|IGNORE))* INTO|UPDATE( IGNORE)?|(DROP|TRUNCATE) TABLE( IF EXISTS)?) `(user)`/d;/^-- Table structure for table `user`/,/^-- Dumping data for table `user`/d;' $1

View File

@@ -4,30 +4,36 @@ After=syslog.target
After=network.target
[Service]
#allow our expand-templates
#allow to run as root pre and post
PermissionsStartOnly=true
#reset
ExecStartPre=
ExecStartPre=/usr/bin/install -d /run/mariadb -o mysql -g mysql -m 0755
# add mariadb >=10.6 specifics
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \
VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] \
&& systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1"
#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.private/set.password
ExecStartPre=-/sbin/e-smith/expand-template /root/.my.cnf
ExecStartPre=-/sbin/e-smith/expand-template /etc/my.cnf
# create db here if needed
ExecStartPre=/sbin/e-smith/systemd/mariadb-initialize
#reset
ExecStart=
#ours
ExecStart=/usr/libexec/mysqld \
ExecStart=/usr/sbin/mariadbd \
--defaults-file=/etc/my.cnf \
--basedir=/usr \
--datadir=/var/lib/mysql \
--user=mysql \
--pid-file=/var/run/mariadb/mariadb.pid
ExecStartPost=-/sbin/e-smith/systemd/mariadb-post
--pid-file=/run/mariadb/mariadb.pid
[Install]
WantedBy=sme-server.target

View File

@@ -11,8 +11,10 @@ IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=-/usr/bin/mariadb-upgrade
ExecStart=/sbin/e-smith/systemd/mysql.init start
ExecStop=/sbin/e-smith/systemd/mysql.init stop
SyslogIdentifier=mysql.init
[Install]
WantedBy=sme-server.target

View File

@@ -0,0 +1 @@
d /run/mariadb 0755 mysql mysql -

0
root/var/lib/mysql.private/.gitignore vendored Normal file
View File

View File

@@ -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 5
%define release 14
Version: %{version}
Release: %{release}%{?dist}
License: GPL
@@ -13,13 +13,30 @@ 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 > 10.5.0
Requires: /usr/bin/mariadb-upgrade
Requires: smeserver-base
Requires: smeserver-lib >= 1.15.1-19
# daemontools bins in use
Requires: /usr/bin/setuidgid
Provides: e-smith-mysql = 2.7.0
Obsoletes: e-smith-mysql < 2.7.0
BuildRequires: smeserver-devtools >= 1.13.1-03
# MariaDB from MariaDB repo
Requires: mariadb-server >= 11.4.0
Requires: mariadb >= 11.4.0
Requires: mariadb-backup
Requires: mariadb-connector-c >= 3.4.4
Requires: mariadb-connector-c-config
Requires: MariaDB-connect-engine
# provides some plugins we used to have
Requires: MariaDB-test
# el8 provides /usr/lib64/mariadb/plugin/auth_gssapi.so in mariadb-gssapi-server
# Mariadb provides /usr/lib64/mysql/plugin/auth_gssapi.so in MariaDB-gssapi-server
Requires: MariaDB-gssapi-server
# not available after 10.x
#Requires: MariaDB-compat
Requires: mariadb-common ,mariadb-errmsg,mariadb-server-utils
AutoReqProv: no
%description
@@ -40,6 +57,8 @@ rm -rf $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)' \
--file "/usr/bin/mysql_filter_tables" 'attr(0554,root,root)' \
--file "/usr/bin/mysql_filter_user_table" '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)' \
@@ -51,12 +70,6 @@ echo "%doc COPYING" >> %{name}-%{version}-filelist
rm -rf $RPM_BUILD_ROOT
%pre
if [ $1 -gt 1 ] ; then
if [ -e /var/service/mariadb/run ] ; then
/usr/bin/sv d mariadb
/usr/bin/sv d mariadb/log
fi
fi
%post
@@ -66,6 +79,36 @@ fi
%defattr(-,root,root)
%changelog
* Sun Apr 20 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-14.sme
- set innodb_page_size=64k [SME: 12982]
breaking change, needs backup and restore of mariadb databases
- convert mysql* bins call to mariadb-* [SME: 12983]
- revert [SME: 12591]
* Sun Apr 06 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-13.sme
- fix Specified key was too long with older mysql db tables [SME: 12980]
added back mysql_upgrade in 00_restore_dumped_dbs
* Fri Apr 04 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-12.sme
- restore root user, pasword and socket login [SME: 12978]
* Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-11.sme
- upgrade to support mariadb 11.4 [SME: 12930]
move mariadb-upgrade to mysql.init unit
remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
add a tmp.d for pid file, add post action dnf script
update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]
* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
* Mon Apr 08 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-7.sme
- add missing mysql.private folder [SME: 11856]
* Sat Apr 06 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-6.sme
- backup users priv, plugins, udfs, servers, stats, timezones [SME: 12591]
* Fri Apr 05 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-5.sme
- tidy spec and sources for mariadb10.5 support [SME: 12524]
- try to make compatible with higher version from mariadb repo [SME: 11856]