-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpostgres.sh
More file actions
30 lines (25 loc) · 776 Bytes
/
postgres.sh
File metadata and controls
30 lines (25 loc) · 776 Bytes
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
#!/usr/bin/env bash
# if operating system is macOS
if [[ $(uname -s) = 'Darwin' ]]; then
# install postgres via homebrew
brew install postgres
# start postgres
brew services start postgres
# wait a few seconds to allow the service to start
sleep 3s
# create database with current system username `whoami`
createdb
else
# install postgres and build dependency
sudo apt-get install -y postgresql libpq-dev
# create user in postgres with name of current system user
sudo -u postgres createuser "$(whoami)" -s
# create database with name of current system user
sudo -u postgres createdb "$(whoami)"
# start postgres server
sudo service postgresql start
fi
# Resource bashrc
source ~/.bashrc
# install postgres gem for rails
gem install pg