-
Notifications
You must be signed in to change notification settings - Fork 0
/
restart_db.sh
35 lines (30 loc) · 1013 Bytes
/
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
#!/bin/bash
#
#-----------------------------------
# @autor: Wendell P. Barreto
# @email: [email protected]
# @project: fotec
# @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 fotec_db'
sudo -u postgres psql -c 'CREATE DATABASE fotec_db'
sudo -u postgres psql -c 'CREATE USER fotec_admin'
sudo -u postgres psql -c 'GRANT ALL PRIVILEGES ON DATABASE fotec_db TO fotec_admin'
# sudo -u postgres psql -d fotec_db -c 'CREATE EXTENSION hstore'
break;;
[Nn]* )
psql -c 'DROP DATABASE fotec_db'
psql -c 'CREATE DATABASE fotec_db'
psql -c 'CREATE USER fotec_admin'
psql -c 'GRANT ALL PRIVILEGES ON DATABASE fotec_db TO fotec_admin'
# psql -d fotec_db -c 'CREATE EXTENSION hstore'
break;;
* ) echo "Please answer yes or no.";;
esac
done
python manage.py syncdb
python manage.py collectstatic --noinput