Siobhan Tully | 44fd4cc | 2014-02-23 00:07:12 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | if [ -z "$1" ]; then |
| 4 | echo usage: $0 "[initdb | resetdb ]" |
| 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 { |
| 36 | # python manage.py runserver 128.95.1.128:8000 |
| 37 | echo "Starting OpenCloud Service on $HOSTNAME:8000" |
| 38 | python manage.py runserver $HOSTNAME:8000& |
| 39 | } |
| 40 | |
| 41 | COMMAND=$1 |
| 42 | |
| 43 | if [ "$COMMAND" = "initdb" ]; then |
| 44 | initdb |
| 45 | createdb |
| 46 | syncdb |
| 47 | runserver |
| 48 | fi |
| 49 | if [ "$COMMAND" = "resetdb" ]; then |
| 50 | dropdb |
| 51 | createdb |
| 52 | syncdb |
| 53 | runserver |
| 54 | fi |
| 55 | if [ "$COMMAND" = "syncdb" ]; then |
| 56 | syncdb |
| 57 | runserver |
| 58 | fi |
| 59 | if [ "$COMMAND" = "runserver" ]; then |
| 60 | runserver |
| 61 | fi |
| 62 | |