Initial commit

This commit is contained in:
2024-07-13 00:53:45 +03:00
commit 00eabc8150
25 changed files with 870 additions and 0 deletions

View 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."