|
|
@ -5,11 +5,19 @@ my $pass = ${'ejabberd'}{'DbPassword'} || 'secret'; |
|
|
|
|
|
|
|
|
|
|
|
$OUT .= <<"END"; |
|
|
|
$OUT .= <<"END"; |
|
|
|
#! /bin/sh |
|
|
|
#! /bin/sh |
|
|
|
|
|
|
|
SCHEMA=\$(rpm -ql ejabberd | grep mysql.sql) |
|
|
|
if [ \! -d /var/lib/mysql/$db ]; then |
|
|
|
if [ \! -d /var/lib/mysql/$db ]; then |
|
|
|
|
|
|
|
# If database doesn't exists, create it and load the schema |
|
|
|
/usr/bin/mysqladmin create $db |
|
|
|
/usr/bin/mysqladmin create $db |
|
|
|
for SQL in \$(rpm -qd ejabberd-modules | grep mysql.sql); do |
|
|
|
/usr/bin/mysql $db < \$SCHEMA |
|
|
|
|
|
|
|
for SQL in \$(rpm -qd ejabberd-modules | grep mod_archive_odbc_mysql.sql); do |
|
|
|
/usr/bin/mysql $db < \$SQL |
|
|
|
/usr/bin/mysql $db < \$SQL |
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
# If database exists, first drop actual indexes |
|
|
|
|
|
|
|
grep -Pi '^CREATE(\ UNIQUE)?\ INDEX' \$SCHEMA | sed -e 's/CREATE/DROP/g' -e 's/(.*)//g' -e 's/USING BTREE //g' -e 's/UNIQUE //g' | /usr/bin/mysql -f $db |
|
|
|
|
|
|
|
# and update the database (create missing tables and indexes) |
|
|
|
|
|
|
|
sed -r -e 's/CREATE TABLE (.*) \\(/CREATE TABLE IF NOT EXISTS \\1 \\(/gi' \$SCHEMA | /usr/bin/mysql -f $db |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
/usr/bin/mysql <<EOF |
|
|
|
/usr/bin/mysql <<EOF |
|
|
|