-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgres.bits
More file actions
46 lines (33 loc) · 1 KB
/
postgres.bits
File metadata and controls
46 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#-----------
# VARIABLES
#-----------
POSTGRES_VERSION=${POSTGRES_VERSION-11}
PGADMIN_VERSION=${PGADMIN_VERSION-3}
LINUX_DISTRIBUTION=${LINUX_DISTRIBUTION-$(lsb_release -cs)}
#-----------
# HELPERS
#-----------
set_env()
{
KEY=$1
VAL=$2
echo "export $KEY=$VAL" >> $HOME/.bash_aliases
}
#-----------
# INSTALLER
#-----------
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${LINUX_DISTRIBUTION}-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get -f -y install
apt-get install -y postgresql-$POSTGRES_VERSION pgadmin$PGADMIN_VERSION
printf "%b" "# MAPNAME\tSYSTEM-USERNAME\tPG-USERNAME
adminmap\tpostgres\tpostgres
adminmap\troot\tpostgres
" > /etc/postgresql/$POSTGRES_VERSION/main/pg_ident.conf
sed -i 's|peer|peer\tmap=adminmap|g' /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf
set_env PGUSER postgres
source $HOME/.bash_aliases
/etc/init.d/postgresql restart
touch /opt/postgres.bits