30 Fix 3
This commit is contained in:
@@ -6,7 +6,7 @@ function installpostgre()
|
||||
$configPath = $dir . '/config.php';
|
||||
|
||||
$password = null;
|
||||
$db_user = 'dragoncore2'; // default user
|
||||
$db_user = 'dragoncore30'; // default user
|
||||
$db_name = 'dragoncore'; // default db name
|
||||
|
||||
// If config already exists, load existing password (and user if needed)
|
||||
@@ -44,6 +44,13 @@ function installpostgre()
|
||||
echo 'sudo -u postgres psql -c "CREATE USER ' . $db_user . ' WITH PASSWORD \'' . $password . '\';"' . "\n";
|
||||
echo 'sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE ' . $db_name . ' TO ' . $db_user . ';"' . "\n";
|
||||
echo 'sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA public TO ' . $db_user . ';"' . "\n";
|
||||
|
||||
// *** Change owner of all tables in public to $db_user ***
|
||||
echo "sudo -u postgres psql -d {$db_name} -c 'DO \$\$ DECLARE r RECORD; BEGIN FOR r IN SELECT tablename FROM pg_tables WHERE schemaname = ''public'' LOOP EXECUTE ''ALTER TABLE public.'' || quote_ident(r.tablename) || '' OWNER TO {$db_user}''; END LOOP; END \$\$;'" . "\n";
|
||||
|
||||
// *** Change owner of all sequences in public to $db_user ***
|
||||
echo "sudo -u postgres psql -d {$db_name} -c 'DO \$\$ DECLARE r RECORD; BEGIN FOR r IN SELECT sequencename FROM pg_sequences WHERE schemaname = ''public'' LOOP EXECUTE ''ALTER SEQUENCE public.'' || quote_ident(r.sequencename) || '' OWNER TO {$db_user}''; END LOOP; END \$\$;'" . "\n";
|
||||
|
||||
echo 'sudo systemctl restart postgresql' . "\n";
|
||||
|
||||
// If config already existed, don't overwrite it
|
||||
|
||||
Reference in New Issue
Block a user