add env var for password and set up .idea editor
This commit is contained in:
12
setup_postgres.sh
Normal file → Executable file
12
setup_postgres.sh
Normal file → Executable file
@ -3,6 +3,12 @@
|
||||
# Exit immediately if a command exits with a non-zero status.
|
||||
set -e
|
||||
|
||||
# Check if the DB_PASSWORD environment variable is set
|
||||
if [ -z "$DB_PASSWORD" ]; then
|
||||
echo "The environment variable DB_PASSWORD is not set. Please set it and rerun the script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update package lists
|
||||
sudo apt-get update
|
||||
|
||||
@ -16,8 +22,8 @@ sudo systemctl enable postgresql
|
||||
# Switch to the postgres user
|
||||
sudo -i -u postgres bash << EOF
|
||||
|
||||
# Create user 'ente' with password 'ente_password'
|
||||
psql -c "CREATE USER ente WITH PASSWORD 'ente_password';"
|
||||
# Create user 'ente' with the password from the environment variable
|
||||
psql -c "CREATE USER ente WITH PASSWORD '$DB_PASSWORD';"
|
||||
|
||||
# Create a new database owned by 'ente'
|
||||
psql -c "CREATE DATABASE ente_db OWNER ente;"
|
||||
@ -55,6 +61,6 @@ sudo systemctl restart postgresql
|
||||
|
||||
# Confirm PostgreSQL is running and listening on the correct port
|
||||
sudo systemctl status postgresql
|
||||
# netstat -plnt | grep postgres
|
||||
netstat -plnt | grep postgres
|
||||
|
||||
echo "PostgreSQL has been set up successfully with SSL. User 'ente' has been created with access via TCP/IP and SSL."
|
||||
|
Reference in New Issue
Block a user