smeserver-limesurvey/root/etc/e-smith/templates/etc/e-smith/sql/init/limesurvey

59 lines
2.0 KiB
Plaintext

{
my $db = ${'limesurvey'}{'DbName'} || 'limesurvey';
my $user = ${'limesurvey'}{'DbUser'} || 'limesurvey';
my $pass = ${'limesurvey'}{'DbPassword'} || 'secret';
my $schema = "/usr/share/limesurvey/installer/sql/create-mysql.sql";
$OUT .= <<"END";
#! /bin/sh
if [ ! -d /var/lib/mysql/$db ]; then
/usr/bin/mysql -e 'create database $db'
cat $schema | perl -pe 's/prefix_//g' | /usr/bin/mysql $db
fi
/usr/bin/mysql <<EOF
USE mysql;
REPLACE INTO user (
host,
user,
password)
VALUES (
'localhost',
'$user',
PASSWORD ('$pass'));
REPLACE INTO db (
host,
db,
user,
select_priv, insert_priv, update_priv, delete_priv,
create_priv, alter_priv, index_priv, drop_priv, create_tmp_table_priv,
grant_priv, lock_tables_priv, references_priv)
VALUES (
'localhost',
'$db',
'$user',
'Y', 'Y', 'Y', 'Y',
'Y', 'Y', 'Y', 'Y', 'Y',
'N', 'Y', 'Y');
FLUSH PRIVILEGES;
use $db;
ALTER TABLE plugins ADD CONSTRAINT uniq_name UNIQUE(\\`name\\`);
INSERT into plugins (\\`name\\`,\\`active\\`) VALUES ('Authwebserver','1') ON DUPLICATE KEY UPDATE active=1;
ALTER TABLE plugins DROP INDEX uniq_name;
ALTER TABLE plugin_settings ADD CONSTRAINT uniq_plugin UNIQUE (\\`plugin_id\\`,\\`key\\`);
INSERT INTO plugin_settings (\\`plugin_id\\`,\\`key\\`,\\`value\\`) VALUES ((SELECT id from plugins where name='Authwebserver'),'strip_domain', NULL) ON DUPLICATE KEY update value=NULL;
INSERT INTO plugin_settings (\\`plugin_id\\`,\\`key\\`,\\`value\\`) VALUES ((SELECT id from plugins where name='Authwebserver'),'serverkey', '"REMOTE_USER"') ON DUPLICATE KEY update value='"REMOTE_USER"';
ALTER TABLE plugin_settings DROP INDEX uniq_plugin;
EOF
END
}