blob: 300586551d239113fa93bc0a5b3804bffaef5f65 [file] [log] [blame]
Siobhan Tully44fd4cc2014-02-23 00:07:12 -05001#!/bin/sh
2
3if [ -z "$1" ]; then
4 echo usage: $0 "[initdb | resetdb ]"
5 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 {
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
41COMMAND=$1
42
43if [ "$COMMAND" = "initdb" ]; then
44 initdb
45 createdb
46 syncdb
47 runserver
48fi
49if [ "$COMMAND" = "resetdb" ]; then
50 dropdb
51 createdb
52 syncdb
53 runserver
54fi
55if [ "$COMMAND" = "syncdb" ]; then
56 syncdb
57 runserver
58fi
59if [ "$COMMAND" = "runserver" ]; then
60 runserver
61fi
62