24 lines
693 B
Bash
Executable File
24 lines
693 B
Bash
Executable File
#!/bin/bash
|
|
|
|
source lib/metascript.sh
|
|
|
|
defaultmetainit $@
|
|
|
|
log_info "assume postgres is already installed localy"
|
|
|
|
log_info "https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/linux_database_configuration.html#requirements"
|
|
|
|
source config_db_query.sh
|
|
|
|
{
|
|
cat <<EOF
|
|
CREATE USER $username WITH PASSWORD '$password' CREATEDB;
|
|
CREATE DATABASE ${database_name} TEMPLATE template0 ENCODING 'UTF8';
|
|
ALTER DATABASE ${database_name} OWNER TO $username;
|
|
GRANT ALL PRIVILEGES ON DATABASE ${database_name} TO $username;
|
|
GRANT ALL PRIVILEGES ON SCHEMA public TO $username;
|
|
EOF
|
|
} | pipeto sudo -u postgres psql -f -
|
|
|
|
log_info "created database ${database_name} with user $username"
|