-
Notifications
You must be signed in to change notification settings - Fork 0
/
restart_db.sh
37 lines (32 loc) · 1.26 KB
/
restart_db.sh
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
#!/bin/bash
#
#-----------------------------------
# @autor: Wendell P. Barreto
# @email: [email protected]
# @project: virtualmuseum
# @doc: restart_db.sh
# ----------------------------------
while true; do
read -p "Are you using Linux (y or n)? " yn
case $yn in
[Yy]* )
sudo -u postgres psql -c 'DROP DATABASE virtualmuseum_db'
sudo -u postgres psql -c 'CREATE DATABASE virtualmuseum_db'
sudo -u postgres psql -c 'CREATE USER virtualmuseum_admin'
sudo -u postgres psql -c "ALTER USER virtualmuseum_admin WITH PASSWORD 'q1IUilS14,747Qx'"
sudo -u postgres psql -c 'GRANT ALL PRIVILEGES ON DATABASE virtualmuseum_db TO virtualmuseum_admin'
sudo -u postgres psql -d virtualmuseum_db -c 'CREATE EXTENSION hstore'
break;;
[Nn]* )
psql -c 'DROP DATABASE virtualmuseum_db'
psql -c 'CREATE DATABASE virtualmuseum_db'
psql -c 'CREATE USER virtualmuseum_admin'
sudo -u postgres psql -c "ALTER USER virtualmuseum_admin WITH PASSWORD 'q1IUilS14,747Qx'"
psql -c 'GRANT ALL PRIVILEGES ON DATABASE virtualmuseum_db TO virtualmuseum_admin'
psql -d virtualmuseum_db -c 'CREATE EXTENSION hstore'
break;;
* ) echo "Please answer yes or no.";;
esac
done
python manage.py syncdb
python manage.py collectstatic