Created
July 13, 2017 07:18
-
-
Save ilyaruby/5760100ff159705dc6762e821c42ebf1 to your computer and use it in GitHub Desktop.
Script to create a ramdisk postgreSQL database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo mkdir /run/postgresql 2>/dev/null | |
sudo chown postgres.postgres /run/postgresql | |
[ `whoami` = postgres ] || exec sudo -u postgres -g postgres -s <<HEREDOC | |
echo SUDOING | |
cd /dev/shm | |
mkdir /dev/shm/postgresql | |
echo initializing db | |
initdb --locale=en_GB.UTF-8 -D /dev/shm/postgresql 1> /dev/null | |
echo reconfiguring | |
sed -i 's/.*port = .*/port = 5432/' /dev/shm/postgresql/postgresql.conf 1>/dev/null | |
mkdir /dev/shm/postgresql/log | |
cd /dev/shm/postgresql | |
echo starting postgresql on ramdisk | |
pg_ctl -D /dev/shm/postgresql -l /dev/shm/postgresql/log/postgresql-9.5-main.log start 1>/dev/null | |
echo waiting for a postgres daemon to start | |
sleep 5 | |
echo "creating databases" | |
psql -U postgres -p 5432 -c 'create role hr_crm_username login createdb'; | |
HEREDOC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment