Create a MySQL database, generate a random password and load the feed table structure
This commit is contained in:
parent
ec322a8b7a
commit
7192c3dc4c
|
@ -6,6 +6,7 @@ templates2events("/etc/ajaxplorer/bootstrap_plugins.php", qw(webapps-update boot
|
||||||
templates2events("/var/cache/ajaxplorer/diag_result.php", qw(webapps-update bootstrap-console-save));
|
templates2events("/var/cache/ajaxplorer/diag_result.php", qw(webapps-update bootstrap-console-save));
|
||||||
templates2events("/var/cache/ajaxplorer/first_run_passed", qw(webapps-update bootstrap-console-save));
|
templates2events("/var/cache/ajaxplorer/first_run_passed", qw(webapps-update bootstrap-console-save));
|
||||||
templates2events("/var/cache/ajaxplorer/admin_counted", qw(webapps-update bootstrap-console-save));
|
templates2events("/var/cache/ajaxplorer/admin_counted", qw(webapps-update bootstrap-console-save));
|
||||||
|
templates2events("/etc/e-smith/sql/init/ajaxplorer", qw(webapps-update bootstrap-console-save));
|
||||||
templates2events("/etc/ajaxplorer/bootstrap_repositories.php", qw(webapps-update bootstrap-console-save share-create share-delete share-modify share-modify-servers));
|
templates2events("/etc/ajaxplorer/bootstrap_repositories.php", qw(webapps-update bootstrap-console-save share-create share-delete share-modify share-modify-servers));
|
||||||
templates2events("/var/lib/ajaxplorer/plugins/auth.serial/roles.ser", qw(webapps-update bootstrap-console-save share-create share-delete share-modify share-modify-servers));
|
templates2events("/var/lib/ajaxplorer/plugins/auth.serial/roles.ser", qw(webapps-update bootstrap-console-save share-create share-delete share-modify share-modify-servers));
|
||||||
templates2events("/var/lib/ajaxplorer/plugins/auth.serial/users.ser", qw(webapps-update bootstrap-console-save user-create user-delete));
|
templates2events("/var/lib/ajaxplorer/plugins/auth.serial/users.ser", qw(webapps-update bootstrap-console-save user-create user-delete));
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ajaxplorer
|
|
@ -0,0 +1 @@
|
||||||
|
ajaxplorer
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
my $rec = $DB->get('ajaxplorer')
|
||||||
|
|| $DB->new_record('ajaxplorer', {type => 'webapp'});
|
||||||
|
my $pw = $rec->prop('DbPassword');
|
||||||
|
if (not $pw or length($pw) < 57){
|
||||||
|
use MIME::Base64 qw(encode_base64);
|
||||||
|
|
||||||
|
$pw = "not set due to error";
|
||||||
|
if ( open( RANDOM, "/dev/urandom" ) ){
|
||||||
|
my $buf;
|
||||||
|
# 57 bytes is a full line of Base64 coding, and contains
|
||||||
|
# 456 bits of randomness - given a perfectly random /dev/random
|
||||||
|
if ( read( RANDOM, $buf, 57 ) != 57 ){
|
||||||
|
warn("Short read from /dev/random: $!");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$pw = encode_base64($buf);
|
||||||
|
chomp $pw;
|
||||||
|
}
|
||||||
|
close RANDOM;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
warn "Could not open /dev/urandom: $!";
|
||||||
|
}
|
||||||
|
$rec->set_prop('DbPassword', $pw);
|
||||||
|
}
|
||||||
|
}
|
46
root/etc/e-smith/templates/etc/e-smith/sql/init/ajaxplorer
Normal file
46
root/etc/e-smith/templates/etc/e-smith/sql/init/ajaxplorer
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
my $db = ${'ajaxplorer'}{'DbName'} || 'ajaxplorer';
|
||||||
|
my $user = ${'ajaxplorer'}{'DbUser'} || 'ajaxplorer';
|
||||||
|
my $pass = ${'ajaxplorer'}{'DbPassword'} || 'secret';
|
||||||
|
|
||||||
|
my $feed = "/usr/share/ajaxplorer/plugins/feed.sql/create.sql";
|
||||||
|
|
||||||
|
$OUT .= <<"END";
|
||||||
|
#! /bin/sh
|
||||||
|
if [ ! -d /var/lib/mysql/$db ]; then
|
||||||
|
/usr/bin/mysql -e 'create database $db'
|
||||||
|
/usr/bin/mysql $db < $feed
|
||||||
|
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;
|
||||||
|
EOF
|
||||||
|
END
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user