initial commit of file from CVS for smeserver-mysql on Sat Mar 23 16:06:28 AEDT 2024

This commit is contained in:
Trevor Batley
2024-03-23 16:06:28 +11:00
parent 715005ffa3
commit df83d181c9
67 changed files with 2762 additions and 2 deletions

View 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 = "/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);

View File

@@ -0,0 +1,58 @@
#!/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

View File

@@ -0,0 +1,82 @@
#!/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

View File

@@ -0,0 +1,18 @@
#!/bin/bash
for i in $(seq 1 20);
do
if [ -S !!!SOCKET!!! ]
then
/usr/bin/mysql!!!VER!!! < /var/lib/mysql/set.password2
echo "root password set"
exit 0
fi
echo waiting for rh-mariadb105-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