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
|
||||
}
|
||||
|
0
root/home/e-smith/db/mysql/.gitignore
vendored
Normal file
0
root/home/e-smith/db/mysql/.gitignore
vendored
Normal file
61
root/sbin/e-smith/mysql-preload
Normal file
61
root/sbin/e-smith/mysql-preload
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/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 = "/usr/libexec/mysqld";
|
||||
if (-f "/usr/sbin/mysqld") {
|
||||
$mysqld = "/usr/sbin/mysqld";
|
||||
}
|
||||
# Hard-code user, since it is set in mysqld_safe currently.
|
||||
# See http://bugs.mysql.com/2163
|
||||
exec($mysqld, qw(--bootstrap --user=mysql --skip-grant-tables));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warn "Couldn't fork: $!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
system("/usr/bin/mysql < $file");
|
||||
}
|
||||
exit(0);
|
14
root/sbin/e-smith/systemd/mariadb-initialize
Normal file
14
root/sbin/e-smith/systemd/mariadb-initialize
Normal file
@@ -0,0 +1,14 @@
|
||||
#! /bin/sh
|
||||
|
||||
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
|
||||
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
|
72
root/sbin/e-smith/systemd/mysql.init
Normal file
72
root/sbin/e-smith/systemd/mysql.init
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 2002 Mitel Networks Corporation
|
||||
#
|
||||
# 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.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
# Source function library.
|
||||
SYSTEMCTL_SKIP_REDIRECT=1
|
||||
. /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 /var/lib/mysql/mysql.sock
|
||||
then
|
||||
exit_value=0
|
||||
HOME=/root
|
||||
export HOME
|
||||
for link in $(find /etc/e-smith/sql/init -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 mysql" perl -e '
|
||||
open (STDERR, "|/usr/bin/logger -p local1.info -t mysql.init");
|
||||
open (STDOUT, ">&STDERR");
|
||||
exec "/usr/bin/mysql";' < $link && /bin/rm $link
|
||||
;;
|
||||
*)
|
||||
action "Loading $F into mysql" perl -e '
|
||||
open (STDERR, "|/usr/bin/logger -p local1.info -t mysql.init");
|
||||
open (STDOUT, ">&STDERR");
|
||||
exec shift; ' $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
|
43
root/usr/lib/systemd/system/mariadb.service.d/50koozali.conf
Normal file
43
root/usr/lib/systemd/system/mariadb.service.d/50koozali.conf
Normal file
@@ -0,0 +1,43 @@
|
||||
[Unit]
|
||||
Description=MariaDB database server
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
|
||||
#reset
|
||||
ExecStartPre=
|
||||
#ours : we need root user as + and ! are not yet supported
|
||||
ExecStartPre=-/sbin/e-smith/service-status 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/systemd/mariadb-initialize
|
||||
|
||||
#reset
|
||||
ExecStart=
|
||||
#ours
|
||||
ExecStart=/usr/libexec/mysqld \
|
||||
--defaults-file=/etc/my.cnf \
|
||||
--basedir=/usr \
|
||||
--datadir=/var/lib/mysql \
|
||||
--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
|
||||
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
||||
|
18
root/usr/lib/systemd/system/mysql.init.service
Normal file
18
root/usr/lib/systemd/system/mysql.init.service
Normal file
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=Koozali SME Server mysql DB injector for mariadb
|
||||
After=mariadb.service
|
||||
Requires=mariadb.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Restart=no
|
||||
TimeoutSec=10min
|
||||
IgnoreSIGPIPE=no
|
||||
KillMode=process
|
||||
GuessMainPID=no
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/sbin/e-smith/systemd/mysql.init start
|
||||
ExecStop=/sbin/e-smith/systemd/mysql.init stop
|
||||
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
0
root/var/log/mariadb/.gitignore
vendored
Normal file
0
root/var/log/mariadb/.gitignore
vendored
Normal file
Reference in New Issue
Block a user