initial commit of file from CVS for smeserver-mysql on Sat Mar 23 16:06:28 AEDT 2024
This commit is contained in:
@@ -0,0 +1 @@
|
||||
yes
|
@@ -0,0 +1 @@
|
||||
enabled
|
1
root/etc/e-smith/db/configuration/defaults/mariadb/type
Normal file
1
root/etc/e-smith/db/configuration/defaults/mariadb/type
Normal file
@@ -0,0 +1 @@
|
||||
service
|
@@ -0,0 +1 @@
|
||||
enabled
|
@@ -0,0 +1 @@
|
||||
service
|
11
root/etc/e-smith/db/configuration/migrate/00mysqld2mariadb
Normal file
11
root/etc/e-smith/db/configuration/migrate/00mysqld2mariadb
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
# Rename mysqld service entry to mariadb
|
||||
|
||||
my $mysqld = $DB->get('mysqld') or return;
|
||||
my $mariadb = $DB->get('mariadb') ||
|
||||
$DB->new_record('mariadb', { type => 'service' });
|
||||
|
||||
$mariadb->merge_props($mysqld->props);
|
||||
$mysqld->delete;
|
||||
|
||||
}
|
6
root/etc/e-smith/db/configuration/migrate/15innodb
Normal file
6
root/etc/e-smith/db/configuration/migrate/15innodb
Normal file
@@ -0,0 +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');
|
||||
}
|
3
root/etc/e-smith/events/actions/mysql-delete-db-files
Normal file
3
root/etc/e-smith/events/actions/mysql-delete-db-files
Normal file
@@ -0,0 +1,3 @@
|
||||
#! /bin/sh
|
||||
|
||||
cd /var/lib/mysql && find . -type f | xargs rm -f
|
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec /bin/rm -f /home/e-smith/db/mysql/*.dump
|
41
root/etc/e-smith/events/actions/mysql-dump-tables
Normal file
41
root/etc/e-smith/events/actions/mysql-dump-tables
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
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 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
|
||||
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"
|
||||
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 $(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
|
||||
done
|
17
root/etc/e-smith/events/actions/mysql-load-tables
Normal file
17
root/etc/e-smith/events/actions/mysql-load-tables
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
status=$(/sbin/e-smith/config getprop mariadb status)
|
||||
if [ "$status" = "disabled" ]
|
||||
then
|
||||
echo "mysqld is disabled - no tables restored" >&2
|
||||
exit 0
|
||||
fi
|
||||
/bin/rm -f /home/e-smith/db/mysql/information_schema.dump
|
||||
/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')
|
||||
do
|
||||
mv $db /etc/e-smith/sql/init/01_$(basename $db .dump).sql
|
||||
done
|
||||
fi
|
0
root/etc/e-smith/sql/init/.gitignore
vendored
Normal file
0
root/etc/e-smith/sql/init/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
PERMS=0540
|
@@ -0,0 +1 @@
|
||||
PERMS=0540
|
@@ -0,0 +1,3 @@
|
||||
PERMS=0400
|
||||
UID="root"
|
||||
GID="root"
|
@@ -0,0 +1,3 @@
|
||||
PERMS=0400
|
||||
UID="root"
|
||||
GID="root"
|
@@ -0,0 +1,19 @@
|
||||
#! /bin/sh
|
||||
|
||||
( cat /home/e-smith/db/mysql/mysql.dump ;
|
||||
cat /var/lib/mysql/set.password ) | mysql || exit 1
|
||||
/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
|
||||
/bin/rm /home/e-smith/db/mysql/mysql.dump
|
||||
exit 0
|
||||
fi
|
||||
echo waiting for mysqld to restart
|
||||
sleep 1
|
||||
done
|
||||
echo mysqld failed to restart
|
||||
exit 1
|
@@ -0,0 +1,16 @@
|
||||
#!/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
|
33
root/etc/e-smith/templates/etc/my.cnf/000readme
Normal file
33
root/etc/e-smith/templates/etc/my.cnf/000readme
Normal file
@@ -0,0 +1,33 @@
|
||||
###########################################################
|
||||
# Here is a cheat-sheet for this file as of MySQL 4.0.14
|
||||
# 2003-12-18 - tony_clayton@mitel.com
|
||||
#
|
||||
# 1. The mysqld binary reads options from the [mysqld] section,
|
||||
# and then overrides those values with any passed-in
|
||||
# arguments.
|
||||
#
|
||||
# 2. The mysqld_safe script reads options from the following
|
||||
# sections in order, overriding any previous values with newer
|
||||
# ones:
|
||||
# [mysqld] [server] [mysqld_safe] [safe_mysqld]
|
||||
# It then overrides those values with any passed-in
|
||||
# arguments, and invokes the mysqld binary (see #1 above) with
|
||||
# the resulting argument list.
|
||||
#
|
||||
# * The server and safe_mysqld sections are deprecated in
|
||||
# favour of mysqld and mysqld_safe respectively.
|
||||
#
|
||||
# 3. The mysql or mysqld initscript reads options from the
|
||||
# following sections in order, overriding any previous values
|
||||
# with newer ones:
|
||||
# [mysqld] [mysql_server] [mysql.server]
|
||||
# It then overrides those values with any passed-in arguments,
|
||||
# and invokes the mysqld_safe script (see #2 above) with the
|
||||
# resulting argument list.
|
||||
#
|
||||
# * The SMEServer doesn't have any need for initscript-only
|
||||
# options, so we don't use mysql_server and mysql.server
|
||||
# sections.
|
||||
#
|
||||
###########################################################
|
||||
|
1
root/etc/e-smith/templates/etc/my.cnf/005mysqld
Normal file
1
root/etc/e-smith/templates/etc/my.cnf/005mysqld
Normal file
@@ -0,0 +1 @@
|
||||
[mysqld]
|
1
root/etc/e-smith/templates/etc/my.cnf/006pid-file
Normal file
1
root/etc/e-smith/templates/etc/my.cnf/006pid-file
Normal file
@@ -0,0 +1 @@
|
||||
pid-file=/var/run/mariadb/mariadb.pid
|
1
root/etc/e-smith/templates/etc/my.cnf/007basedir
Normal file
1
root/etc/e-smith/templates/etc/my.cnf/007basedir
Normal file
@@ -0,0 +1 @@
|
||||
basedir=/usr
|
1
root/etc/e-smith/templates/etc/my.cnf/008datadir
Normal file
1
root/etc/e-smith/templates/etc/my.cnf/008datadir
Normal file
@@ -0,0 +1 @@
|
||||
datadir=/var/lib/mysql
|
14
root/etc/e-smith/templates/etc/my.cnf/009innodb
Normal file
14
root/etc/e-smith/templates/etc/my.cnf/009innodb
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
#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' }
|
||||
|
5
root/etc/e-smith/templates/etc/my.cnf/009socket
Normal file
5
root/etc/e-smith/templates/etc/my.cnf/009socket
Normal file
@@ -0,0 +1,5 @@
|
||||
socket=/var/lib/mysql/mysql.sock
|
||||
{
|
||||
my $localonly = $mariadb{LocalNetworkingOnly} || "no";
|
||||
$OUT = ($localonly eq 'yes') ? "skip-networking" : "# networking is enabled";
|
||||
}
|
1
root/etc/e-smith/templates/etc/my.cnf/011user
Normal file
1
root/etc/e-smith/templates/etc/my.cnf/011user
Normal file
@@ -0,0 +1 @@
|
||||
user=mysql
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
$OUT = '';
|
||||
# changed 0 to 32186 for mariadb 5.5 see BZ 12417
|
||||
my $limit = ${'mariadb'}{OpenFilesLimit} || 32186;
|
||||
return if $limit eq 0;
|
||||
|
||||
$OUT .= "open_files_limit=$limit\n";
|
||||
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
{
|
||||
$OUT = '';
|
||||
my $var;
|
||||
$var = ${'mariadb'}{'MaxConnections'} || undef;
|
||||
#default 151; range 10 to 100000
|
||||
$OUT .= "max_connections=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'WaitTimeout'} || undef;
|
||||
#default 28800
|
||||
$OUT .= "wait_timeout=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'QueryCacheLimit'} || undef;
|
||||
#default 1048576 (1M)
|
||||
$OUT .= "query_cache_limit=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'QueryCacheSize'} || '1M';
|
||||
#default 1048576 (1M)
|
||||
$OUT .= "query_cache_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'QueryCacheType'} || '1';
|
||||
#default 0 or OFF, 1 or ON, 2 or DEMAND
|
||||
$OUT .= "query_cache_type=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'SortBufferSize'} || undef;
|
||||
#default 2M
|
||||
$OUT .= "sort_buffer_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'ReadRndBufferSize'} || undef;
|
||||
#default 262144 from 8200 to 2147483647
|
||||
$OUT .= "read_rnd_buffer_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'TableOpenCache'} || undef;
|
||||
#default 400 (2000 sice 10.1.7)
|
||||
$OUT .= "table_open_cache=$var\n" if defined $var;
|
||||
|
||||
#Introduced: MariaDB 10.2.2
|
||||
#$var = ${'mariadb'}{'TableOpenCacheInstances'} || undef;
|
||||
##default 8
|
||||
#$OUT .= "table_open_cache_instances=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'TmpTableSize'} || undef;
|
||||
#default 16M
|
||||
$OUT .= "tmp_table_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'MaxHeapTableSize'} || undef;
|
||||
#default 16M
|
||||
$OUT .= "max_heap_table_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'ThreadCacheSize'} || 256;
|
||||
#default 0 from 0 to 16384
|
||||
$OUT .= "thread_cache_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'KeyBufferSize'} || undef;
|
||||
#default 134217728 - myisam only
|
||||
$OUT .= "key_buffer_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'MyisamSortBufferSize'} || undef;
|
||||
#default 128M - before 10.0.3: 8M
|
||||
$OUT .= "myisam_sort_buffer_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'JoinBufferSize'} || 262144;
|
||||
#default 262144
|
||||
$OUT .= "join_buffer_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'ReadBufferSize'} || undef;
|
||||
#default 131072
|
||||
$OUT .= "read_buffer_size=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'ConnectTimeout'} || undef;
|
||||
#default 10
|
||||
$OUT .= "connect_timeout=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'MaxConnectErrors'} || 100;
|
||||
#default 100
|
||||
$OUT .= "max_connect_errors=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'MaxAllowedPacket'} || '16M';
|
||||
#default 4M
|
||||
$OUT .= "max_allowed_packet=$var\n" if defined $var;
|
||||
|
||||
$var = ${'mariadb'}{'SlowQueries'} ||undef;
|
||||
if (defined $var)
|
||||
{
|
||||
$OUT .= "log_slow_queries=1\n"; # change to slow_query_log in mariadb 10.1
|
||||
$OUT .= "long_query_time=$var\n";
|
||||
$OUT .= "slow_query_log_file=\"/var/log/mariadb/slow_queries.log\"\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
3
root/etc/e-smith/templates/etc/my.cnf/015logerror
Normal file
3
root/etc/e-smith/templates/etc/my.cnf/015logerror
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
log_error=/var/log/mariadb/mariadb.log
|
||||
|
4
root/etc/e-smith/templates/etc/my.cnf/040mysqld_safe
Normal file
4
root/etc/e-smith/templates/etc/my.cnf/040mysqld_safe
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
{ # allow backwards-compatibility with safe_mysqld (mysql < 4.0)
|
||||
-f "/usr/bin/mysqld_safe" ? "[mysqld_safe]" : "[safe_mysqld]";
|
||||
}
|
14
root/etc/e-smith/templates/etc/rsyslog.conf/32mysqlinit
Normal file
14
root/etc/e-smith/templates/etc/rsyslog.conf/32mysqlinit
Normal file
@@ -0,0 +1,14 @@
|
||||
# *-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
root/etc/e-smith/templates/root/.my.cnf/50client
Normal file
1
root/etc/e-smith/templates/root/.my.cnf/50client
Normal file
@@ -0,0 +1 @@
|
||||
[client]
|
9
root/etc/e-smith/templates/root/.my.cnf/55password
Normal file
9
root/etc/e-smith/templates/root/.my.cnf/55password
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
#----------------------------------------------------------
|
||||
# Read (and possibly create) DAP password
|
||||
#----------------------------------------------------------
|
||||
|
||||
use esmith::util;
|
||||
my $pw = esmith::util::LdapPassword;
|
||||
$OUT .= "password=$pw";
|
||||
}
|
9
root/etc/e-smith/templates/root/.my.cnf/template-begin
Normal file
9
root/etc/e-smith/templates/root/.my.cnf/template-begin
Normal file
@@ -0,0 +1,9 @@
|
||||
#------------------------------------------------------------
|
||||
# DO NOT MODIFY THIS FILE! It is updated automatically by the
|
||||
# e-smith server and gateway software. Instead, modify the source
|
||||
# template in the /etc/e-smith/templates directory. For more
|
||||
# information, see http://www.e-smith.org.
|
||||
#
|
||||
# copyright (C) 1999-2001 e-smith, inc.
|
||||
#------------------------------------------------------------
|
||||
|
4
root/etc/e-smith/templates/root/.my.cnf/template-end
Normal file
4
root/etc/e-smith/templates/root/.my.cnf/template-end
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
#------------------------------------------------------------
|
||||
# TEMPLATE END
|
||||
#------------------------------------------------------------
|
12
root/etc/e-smith/templates/var/lib/mysql/set.password
Normal file
12
root/etc/e-smith/templates/var/lib/mysql/set.password
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
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";
|
||||
}
|
9
root/etc/e-smith/templates/var/lib/mysql/set.password2
Normal file
9
root/etc/e-smith/templates/var/lib/mysql/set.password2
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
use esmith::util;
|
||||
|
||||
my $pw = esmith::util::LdapPassword();
|
||||
|
||||
$OUT .= "use mysql;\n";
|
||||
$OUT .= "SET PASSWORD FOR 'root'\@localhost = PASSWORD(\"$pw\"); \n";
|
||||
$OUT .= "FLUSH PRIVILEGES;\n";
|
||||
}
|
17
root/etc/logrotate.d/mariadb-sme
Normal file
17
root/etc/logrotate.d/mariadb-sme
Normal file
@@ -0,0 +1,17 @@
|
||||
/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
|
||||
}
|
||||
|
9
root/etc/logrotate.d/mysqlinit
Normal file
9
root/etc/logrotate.d/mysqlinit
Normal file
@@ -0,0 +1,9 @@
|
||||
/var/log/mysql.init/*.log {
|
||||
create 640 root root
|
||||
notifempty
|
||||
daily
|
||||
rotate 3
|
||||
missingok
|
||||
compress
|
||||
}
|
||||
|
Reference in New Issue
Block a user