Initial commit
This commit is contained in:
29
servers/deployment/scripts/install_postgresql.sh
Executable file
29
servers/deployment/scripts/install_postgresql.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check if username and password arguments are provided
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: $0 <username> <password>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
username=$1
|
||||
password=$2
|
||||
|
||||
# Install PostgreSQL
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y postgresql
|
||||
|
||||
# Create a new database named "jfl"
|
||||
sudo -u postgres psql -c "CREATE DATABASE $username;"
|
||||
|
||||
# Create a user with provided username and password
|
||||
sudo -u postgres psql -c "CREATE USER $username WITH PASSWORD '$password';"
|
||||
|
||||
# Grant all privileges on the "jfl" database to the user
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $username TO $username;"
|
||||
|
||||
# Grant permission to create and delete databases
|
||||
sudo -u postgres psql -c "ALTER USER $username CREATEDB;"
|
||||
|
||||
echo "Database setup complete."
|
||||
|
||||
Reference in New Issue
Block a user