Siobhan Tully | 44fd4cc | 2014-02-23 00:07:12 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | if [ -z "$1" ]; then |
Scott Baker | f4db381 | 2014-05-09 16:42:13 -0700 | [diff] [blame] | 4 | echo usage: $0 "[initdb | createdb | dropdb | syncdb | runserver | resetdb | dumpdata]" |
Siobhan Tully | 44fd4cc | 2014-02-23 00:07:12 -0500 | [diff] [blame] | 5 | exit |
| 6 | fi |
| 7 | |
| 8 | cd /opt/planetstack |
| 9 | |
| 10 | function initdb { |
| 11 | #Figure out if the script is running on Fedora 16 or 17 |
| 12 | if grep 16 /etc/fedora-release; then |
| 13 | sudo -u postgres initdb -D /var/lib/pgsql/data/ |
| 14 | sudo -u postgres pg_ctl -D /var/lib/pgsql/data -l logfile start |
| 15 | else |
| 16 | #Try normal Fedora 17 commands |
| 17 | echo "Trying Fedora 17 commands" > /dev/stdout |
| 18 | /sbin/service postgresql initdb |
| 19 | /sbin/service postgresql start |
| 20 | /sbin/chkconfig postgresql on |
| 21 | fi |
| 22 | } |
| 23 | function createdb { |
| 24 | echo "Creating OpenCloud database..." |
| 25 | sudo -u postgres createdb planetstack |
| 26 | } |
| 27 | function dropdb { |
| 28 | echo "Dropping OpenCloud database..." |
| 29 | sudo -u postgres dropdb planetstack |
| 30 | } |
| 31 | function syncdb { |
| 32 | echo "Syncing OpenCloud services..." |
| 33 | python /opt/planetstack/manage.py syncdb --noinput |
| 34 | } |
| 35 | function runserver { |
Siobhan Tully | 44fd4cc | 2014-02-23 00:07:12 -0500 | [diff] [blame] | 36 | echo "Starting OpenCloud Service on $HOSTNAME:8000" |
| 37 | python manage.py runserver $HOSTNAME:8000& |
| 38 | } |
| 39 | |
Scott Baker | f4db381 | 2014-05-09 16:42:13 -0700 | [diff] [blame] | 40 | function dumpdata { |
| 41 | echo "Saving off OpenCloud data to /opt/planetstack/initial_data.json. Please compare against /opt/planetstack/core/fixtures/initial_data.json to be sure of replacing these changes as the default initialization values." |
| 42 | python manage.py dumpdata core hpc syndicate requestrouter --indent 4 > /opt/planetstack/initial_data.json |
| 43 | } |
| 44 | |
Siobhan Tully | 44fd4cc | 2014-02-23 00:07:12 -0500 | [diff] [blame] | 45 | COMMAND=$1 |
| 46 | |
| 47 | if [ "$COMMAND" = "initdb" ]; then |
| 48 | initdb |
| 49 | createdb |
| 50 | syncdb |
| 51 | runserver |
| 52 | fi |
| 53 | if [ "$COMMAND" = "resetdb" ]; then |
| 54 | dropdb |
| 55 | createdb |
| 56 | syncdb |
| 57 | runserver |
| 58 | fi |
| 59 | if [ "$COMMAND" = "syncdb" ]; then |
| 60 | syncdb |
| 61 | runserver |
| 62 | fi |
| 63 | if [ "$COMMAND" = "runserver" ]; then |
| 64 | runserver |
| 65 | fi |
Scott Baker | f4db381 | 2014-05-09 16:42:13 -0700 | [diff] [blame] | 66 | if [ "$COMMAND" = "dumpdata" ]; then |
| 67 | dumpdata |
| 68 | fi |