trying a better way of injecting schema file: mysql.sql can now be executed when we want, and YES, mysql.sh, launched at POSTINST, WILL CHANGE alternc_mail mysql user password

This commit is contained in:
Benjamin Sonntag 2015-11-16 08:50:38 +01:00
parent 0f456d247b
commit 12a3650678
2 changed files with 5 additions and 16 deletions

View File

@ -48,21 +48,9 @@
MYSQL_CONFIG="/etc/alternc/my.cnf"
MYSQL_MAIL_CONFIG="/etc/alternc/my_mail.cnf"
# We start by checking if an already configured mysql works, in that case we DON'T TOUCH IT
if [ -f "$MYSQL_CONFIG" ]
then
mysql --defaults-file="$MYSQL_CONFIG" -e "SELECT COUNT(*) FROM membres" >/dev/null
if [ "$?" = "0" ]
then
echo "MySQL already setup, schema & grant install skipped"
return
fi
fi
# The grant all is the most important right needed in this script.
echo "Granting users..."
. /etc/alternc/local.sh
# the purpose of this "grant" is to make sure that the generated my.cnf works
# this means (a) creating the user and (b) creating the database
@ -218,7 +206,7 @@ echo "Checking for MySQL connectivity"
$mysql -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED: database user setup failed"
# Final mysql setup: db schema
echo "installing AlternC schema in $database..."
$mysql < /usr/share/alternc/install/mysql.sql || echo cannot load database schema
$mysql < /usr/share/alternc/install/mysql.sql || echo "Error loading database schema, continuing..."
$mysql <<EOF
$grant_mail
EOF

View File

@ -740,10 +740,11 @@ CREATE TABLE IF NOT EXISTS `actions` (
CREATE TABLE IF NOT EXISTS `alternc_status` (
`name` varchar(48) NOT NULL DEFAULT '',
`value` longtext NOT NULL,
PRIMARY KEY (`name`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT = 'stores current AlternC schema version number';
-- make it re-exec-proof
DELETE FROM alternc_status WHERE name='alternc_version';
INSERT INTO alternc_status SET name='alternc_version',value='3.4.1.sh';