blob: 63b64402b9e3196c2e8a5a79a2b7caa62ec2a6c3 [file] [log] [blame]
#!/bin/sh
if [ -z "$1" ]; then
echo usage: $0 "[initdb | createdb | dropdb | syncdb | runserver | resetdb | dumpdata]"
exit
fi
cd /opt/planetstack
function initdb {
#Figure out if the script is running on Fedora 16 or 17
if grep 16 /etc/fedora-release; then
sudo -u postgres initdb -D /var/lib/pgsql/data/
sudo -u postgres pg_ctl -D /var/lib/pgsql/data -l logfile start
else
#Try normal Fedora 17 commands
echo "Trying Fedora 17 commands" > /dev/stdout
/sbin/service postgresql initdb
/sbin/service postgresql start
/sbin/chkconfig postgresql on
fi
}
function createdb {
echo "Creating OpenCloud database..."
sudo -u postgres createdb planetstack
}
function dropdb {
echo "Dropping OpenCloud database..."
sudo -u postgres dropdb planetstack
}
function syncdb {
echo "Syncing OpenCloud services..."
python /opt/planetstack/manage.py syncdb --noinput
}
function runserver {
echo "Starting OpenCloud Service on $HOSTNAME:8000"
python manage.py runserver $HOSTNAME:8000&
}
function dumpdata {
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."
python manage.py dumpdata core hpc syndicate requestrouter --indent 4 > /opt/planetstack/initial_data.json
}
COMMAND=$1
if [ "$COMMAND" = "initdb" ]; then
initdb
createdb
syncdb
runserver
fi
if [ "$COMMAND" = "resetdb" ]; then
dropdb
createdb
syncdb
runserver
fi
if [ "$COMMAND" = "syncdb" ]; then
syncdb
runserver
fi
if [ "$COMMAND" = "runserver" ]; then
runserver
fi
if [ "$COMMAND" = "dumpdata" ]; then
dumpdata
fi