Compare commits
6 Commits
33a7cf66c6
...
pkg/dev/eo
Author | SHA1 | Date | |
---|---|---|---|
c3040e3762 | |||
2ba4b56d51 | |||
065308a921 | |||
21b93a3462 | |||
c540b65e08 | |||
5e9eae5c13 |
2
debian/control
vendored
2
debian/control
vendored
@ -10,7 +10,7 @@ Vcs-Browser: https://forge.cadoles.com/Cadoles/eole-mariadb
|
|||||||
|
|
||||||
Package: eole-mariadb
|
Package: eole-mariadb
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: ${misc:Depends}, mariadb-server, mariadb-backup
|
Depends: ${misc:Depends}, mariadb-server
|
||||||
Conflicts: eole-mysql
|
Conflicts: eole-mysql
|
||||||
Provides: eole-mysql
|
Provides: eole-mysql
|
||||||
Description: Dictionnaires et templates pour la configuration d'un serveur MariaDB, testée uniquement avec eolebase
|
Description: Dictionnaires et templates pour la configuration d'un serveur MariaDB, testée uniquement avec eolebase
|
||||||
|
@ -28,8 +28,6 @@ then
|
|||||||
|
|
||||||
previousUsers=($(awk -F ':' '{print $1}' ${readerfile} ))
|
previousUsers=($(awk -F ':' '{print $1}' ${readerfile} ))
|
||||||
|
|
||||||
index=0
|
|
||||||
|
|
||||||
for user in ${accounts[@]}
|
for user in ${accounts[@]}
|
||||||
do
|
do
|
||||||
PASS=$(awk -F ':' "/${user}:/ {print \$2}" ${readerfile})
|
PASS=$(awk -F ':' "/${user}:/ {print \$2}" ${readerfile})
|
||||||
@ -56,6 +54,7 @@ then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
index=0
|
||||||
for hst in ${hostsList[@]}
|
for hst in ${hostsList[@]}
|
||||||
do
|
do
|
||||||
SQL="DROP USER IF EXISTS '${user}'@'${hst}';"
|
SQL="DROP USER IF EXISTS '${user}'@'${hst}';"
|
||||||
@ -87,3 +86,4 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
66
posttemplate/25-mariadb-passwd
Executable file
66
posttemplate/25-mariadb-passwd
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
systemctl stop mariadb
|
||||||
|
|
||||||
|
mariadb_cfdir=/etc/mysql/
|
||||||
|
dc=$mysql_cfgdir/mariadbBackup.cnf
|
||||||
|
mariadb_rundir=/var/run/mysqld/
|
||||||
|
mariadb_statedir=/var/lib/mysql
|
||||||
|
|
||||||
|
if [ -e "$dc" -a -n "`fgrep mysql_upgrade $dc 2>/dev/null`" ]; then
|
||||||
|
pass="`sed -n 's/^[ ]*password *= *// p' $dc | head -n 1`"
|
||||||
|
# Basedir is deprecated. Remove the option if it's in an existing mariadbBackup.cnf
|
||||||
|
sed -i '/basedir/d' "$dc"
|
||||||
|
else
|
||||||
|
pass=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'`;
|
||||||
|
if [ ! -d "$mariadb_cfdir" ]; then
|
||||||
|
install -o 0 -g 0 -m 0755 -d $mariadb_cfdir
|
||||||
|
fi
|
||||||
|
umask 066
|
||||||
|
cat /dev/null > $dc
|
||||||
|
umask 022
|
||||||
|
echo "# Automatically generated DONT'T TOUCH !!!!!!" >>$dc
|
||||||
|
echo "[client]" >>$dc
|
||||||
|
echo "host = localhost" >>$dc
|
||||||
|
echo "user = maria-sys-maint" >>$dc
|
||||||
|
echo "password = $pass" >>$dc
|
||||||
|
echo "socket = $mariadb_rundir/mysqld.sock" >>$dc
|
||||||
|
echo "[mysql_upgrade]" >>$dc
|
||||||
|
echo "host = localhost" >>$dc
|
||||||
|
echo "user = maria-sys-maint" >>$dc
|
||||||
|
echo "password = $pass" >>$dc
|
||||||
|
echo "socket = $mariadb_rundir/mysqld.sock" >>$dc
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If this dir chmod go+w then the admin did it. But this file should not.
|
||||||
|
chown 0:0 $dc
|
||||||
|
chmod 0600 $dc
|
||||||
|
|
||||||
|
# If database doesn't exist we create it.
|
||||||
|
mkdir /var/lib/mariadb-files
|
||||||
|
mariadb_filesdir=/var/lib/mariadb-files
|
||||||
|
|
||||||
|
if [ ! "$(ls -A "${mariadb_statedir}")" ] && [ -d "${mariadb_filesdir}" ]; then
|
||||||
|
existingdatabase=0
|
||||||
|
initfile=`mktemp --tmpdir=/var/lib/mariadb-files/`
|
||||||
|
touch "$initfile"
|
||||||
|
chmod 600 "$initfile"
|
||||||
|
chown mysql:mysql "$initfile"
|
||||||
|
echo "USE mysql; " >> "$initfile"
|
||||||
|
db_get mysql-server/root_password && rootpw="$RET"
|
||||||
|
if [ ! -z "$rootpw" ]; then
|
||||||
|
rootpw=$(printf %q "${rootpw}")
|
||||||
|
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$rootpw';" >> "$initfile"
|
||||||
|
fi
|
||||||
|
echo "CREATE USER IF NOT EXISTS 'maria-sys-maint'@'localhost' IDENTIFIED BY '$pass';" >> "$initfile"
|
||||||
|
echo "GRANT ALL ON *.* TO 'maria-sys-maint'@'localhost' WITH GRANT OPTION;" >> "$initfile"
|
||||||
|
echo "SHUTDOWN;" >> "$initfile"
|
||||||
|
mysqld --initialize-insecure --user=mysql --init-file="$initfile"> /dev/null 2>&1 || true
|
||||||
|
rm "$initfile"
|
||||||
|
else
|
||||||
|
existingdatabase=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
systemctl start mariadb
|
||||||
|
|
||||||
|
exit 0
|
@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
DESC="Exportation des bases MariaDB"
|
|
||||||
|
|
||||||
. /usr/share/eole/schedule/config.sh
|
|
||||||
|
|
||||||
MYSQLSAVDIR=$SAVDIR/sql
|
|
||||||
OPTION="--lock-tables"
|
|
||||||
|
|
||||||
if [[ -d ${MYSQLSAVDIR} ]]
|
|
||||||
then
|
|
||||||
rm -rf ${MYSQLSAVDIR}
|
|
||||||
mkdir -p ${MYSQLSAVDIR}
|
|
||||||
fi
|
|
||||||
|
|
||||||
mariabackup --defaults-file=/etc/mysql/debian.cnf --backup --target-dir=$MYSQLSAVDIR
|
|
||||||
exit $?
|
|
7
schedule_config/config.sh
Normal file
7
schedule_config/config.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Configuration commune aux scripts schedule
|
||||||
|
# Configuration de base modifiée pour copier dans le partage nfs plutôt que /home
|
||||||
|
|
||||||
|
SAVDIR=/mnt/sauvegardes/
|
||||||
|
# pour que l'affichage de [ ok ] soit ok
|
||||||
|
export TERM='dumb'
|
||||||
|
umask 0077
|
27
schedule_scripts/mariadb
Normal file
27
schedule_scripts/mariadb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DESC="Exportation des bases MariaDB"
|
||||||
|
|
||||||
|
. /usr/share/eole/schedule/config.sh
|
||||||
|
|
||||||
|
MYSQLSAVDIR=$SAVDIR/sql
|
||||||
|
OPTION="--lock-tables"
|
||||||
|
|
||||||
|
rm -f $MYSQLSAVDIR/*.sql
|
||||||
|
mkdir -p $MYSQLSAVDIR
|
||||||
|
|
||||||
|
CMD="mysql --defaults-file=/etc/mysql/mariadbBackup.cnf -e 'show databases' | grep -v '^Database$'"
|
||||||
|
DATABASES=$(CreoleRun "$CMD" mysql)
|
||||||
|
for databasename in $DATABASES; do
|
||||||
|
case "$databasename" in
|
||||||
|
information_schema|performance_schema|bareos)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
CMD="mysqldump --defaults-file=/etc/mysql/mariadbBackup.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null"
|
||||||
|
CreoleRun "$CMD" mysql > $MYSQLSAVDIR/$databasename.sql
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
@ -8,7 +8,7 @@ wsrep_on=ON
|
|||||||
wsrep_provider=/usr/lib/galera/libgalera_smm.so
|
wsrep_provider=/usr/lib/galera/libgalera_smm.so
|
||||||
# Galera Cluster Configuration
|
# Galera Cluster Configuration
|
||||||
wsrep_cluster_name="%%dbClusterName"
|
wsrep_cluster_name="%%dbClusterName"
|
||||||
wsrep_cluster_address="gcomm://%%custom_join(%%dbClusterMember, ',')"
|
wsrep_cluster_address="gcomm://%%dbClusterMember
|
||||||
|
|
||||||
# Tunning
|
# Tunning
|
||||||
wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"
|
wsrep_provider_options="gcache.size=%%dbClusterGcacheSizeMb"
|
||||||
|
Reference in New Issue
Block a user