blob: 63b64402b9e3196c2e8a5a79a2b7caa62ec2a6c3 [file] [log] [blame]
Siobhan Tully44fd4cc2014-02-23 00:07:12 -05001#!/bin/sh
2
3if [ -z "$1" ]; then
Scott Bakerf4db3812014-05-09 16:42:13 -07004 echo usage: $0 "[initdb | createdb | dropdb | syncdb | runserver | resetdb | dumpdata]"
Siobhan Tully44fd4cc2014-02-23 00:07:12 -05005 exit
6fi
7
8cd /opt/planetstack
9
10function 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}
23function createdb {
24 echo "Creating OpenCloud database..."
25 sudo -u postgres createdb planetstack
26}
27function dropdb {
28 echo "Dropping OpenCloud database..."
29 sudo -u postgres dropdb planetstack
30}
31function syncdb {
32 echo "Syncing OpenCloud services..."
33 python /opt/planetstack/manage.py syncdb --noinput
34}
35function runserver {
Siobhan Tully44fd4cc2014-02-23 00:07:12 -050036 echo "Starting OpenCloud Service on $HOSTNAME:8000"
37 python manage.py runserver $HOSTNAME:8000&
38}
39
Scott Bakerf4db3812014-05-09 16:42:13 -070040function 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 Tully44fd4cc2014-02-23 00:07:12 -050045COMMAND=$1
46
47if [ "$COMMAND" = "initdb" ]; then
48 initdb
49 createdb
50 syncdb
51 runserver
52fi
53if [ "$COMMAND" = "resetdb" ]; then
54 dropdb
55 createdb
56 syncdb
57 runserver
58fi
59if [ "$COMMAND" = "syncdb" ]; then
60 syncdb
61 runserver
62fi
63if [ "$COMMAND" = "runserver" ]; then
64 runserver
65fi
Scott Bakerf4db3812014-05-09 16:42:13 -070066if [ "$COMMAND" = "dumpdata" ]; then
67 dumpdata
68fi