To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / deploy / provision.d / 080-database-load.sh @ 1613:90bed4e10cc8
History | View | Annotate | Download (559 Bytes)
| 1 | 1577:e38eee2e1d47 | Chris | #!/bin/bash |
|---|---|---|---|
| 2 | |||
| 3 | set -e |
||
| 4 | |||
| 5 | 1589:94669513c53c | Chris | # Start the database and if a dump file is found, load it. The dump |
| 6 | # file is then deleted so that the db won't be overwritten on |
||
| 7 | # subsequent runs. (The original repo contains no dump file, so it |
||
| 8 | # should exist only if you have provided some data to load.) |
||
| 9 | |||
| 10 | 1577:e38eee2e1d47 | Chris | /etc/init.d/postgresql start |
| 11 | |||
| 12 | 1611:89d3095ddc70 | Chris | dumpdir="/code-to-deploy" |
| 13 | if [ ! -d "$dumpdir" ]; then |
||
| 14 | dumpdir=/var/www/code |
||
| 15 | fi |
||
| 16 | |||
| 17 | cd "$dumpdir" |
||
| 18 | 1577:e38eee2e1d47 | Chris | |
| 19 | if [ -f postgres-dumpall ]; then |
||
| 20 | chmod ugo+r postgres-dumpall |
||
| 21 | sudo -u postgres psql -f postgres-dumpall postgres |
||
| 22 | 1589:94669513c53c | Chris | rm postgres-dumpall |
| 23 | 1577:e38eee2e1d47 | Chris | fi |