Skip to content

Instantly share code, notes, and snippets.

@alenteria
Last active March 5, 2024 08:13
Show Gist options
  • Select an option

  • Save alenteria/791dbe32175a01d1f1b602b25489ad22 to your computer and use it in GitHub Desktop.

Select an option

Save alenteria/791dbe32175a01d1f1b602b25489ad22 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
USER=adopisoft
echo "=== $BASH_SOURCE on $(hostname -f) at $(date)" >&2
sudo apt update -y
sudo apt install postgresql postgresql-contrib -y
echo start the postgres
sudo /etc/init.d/postgresql start
sudo -u postgres createdb adopisoft
sudo su - postgres -c \
"psql <<__END__
SELECT 'create user' ;
CREATE USER $USER ;
ALTER USER $USER CREATEDB;
SELECT 'grant him the priviledges' ;
grant all privileges on database adopisoft to $USER ;
alter user $USER password 'adopisoft';
SELECT 'AND VERIFY' ;
select * from information_schema.role_table_grants
where grantee='""$USER""' ;
SELECT 'INSTALL EXTENSIONS' ;
CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";
CREATE EXTENSION IF NOT EXISTS \"pgcrypto\";
CREATE EXTENSION IF NOT EXISTS \"dblink\";
__END__
"
sudo /etc/init.d/postgresql status
sudo netstat -tulntp | grep -i postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment