From 44fd4cc7ec7f9e1a6f960627ce6870695846a506 Mon Sep 17 00:00:00 2001 From: Siobhan Tully Date: Sun, 23 Feb 2014 00:07:12 -0500 Subject: [PATCH] Added in initial make -- rpm support, tested against Fedora 16, code in for Fedora 17 but needs additional testing. Adjusted initial_data.json to align with current code base, enacted was deprecated from core.user. New scripts/opencloud for database/init/reset/syncdb/runserver commands. --- Makefile | 36 ++++++++++ opencloud.spec | 73 +++++++++++++++++++++ planetstack/core/fixtures/initial_data.json | 45 +++++-------- planetstack/scripts/opencloud | 62 +++++++++++++++++ 4 files changed, 186 insertions(+), 30 deletions(-) create mode 100644 Makefile create mode 100644 opencloud.spec create mode 100755 planetstack/scripts/opencloud diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..be5701d --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +NAME = opencloud +SPECFILE = $(NAME).spec +VERSION = $(shell rpm -q --specfile $(SPECFILE) --qf '%{VERSION}\n' | head -n 1) +RELEASE = $(shell rpm -q --specfile $(SPECFILE) --qf '%{RELEASE}\n' | head -n 1) + +PWD = $(shell pwd) + +dist rpm: $(NAME)-$(VERSION)-$(RELEASE).rpm + +$(NAME)-$(VERSION).tar.gz: + mkdir -p $(NAME)-$(VERSION) + rsync -av --exclude=.svn --exclude=.git --exclude=*.tar.gz --exclude=$(NAME)-$(VERSION)/ ./ $(NAME)-$(VERSION) + tar -czf $@ $(NAME)-$(VERSION) + rm -fr $(NAME)-$(VERSION) + +$(NAME)-$(VERSION)-$(RELEASE).rpm: $(NAME)-$(VERSION).tar.gz + mkdir -p build + rpmbuild -bb --define '_sourcedir $(PWD)' \ + --define '_builddir $(PWD)/build' \ + --define '_srcrpmdir $(PWD)' \ + --define '_rpmdir $(PWD)' \ + --define '_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \ + $(SPECFILE) + +srpm: $(NAME)-$(VERSION)-$(RELEASE).src.rpm +$(NAME)-$(VERSION)-$(RELEASE).src.rpm: $(NAME)-$(VERSION).tar.gz + rpmbuild -bs --define "_sourcedir $$(pwd)" \ + --define "_srcrpmdir $$(pwd)" \ + $(SPECFILE) + +clean: + rm -f $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)-$(RELEASE).src.rpm $(NAME)-$(VERSION)-$(RELEASE).noarch.rpm + rm -rf build + +.PHONY: dist + diff --git a/opencloud.spec b/opencloud.spec new file mode 100644 index 0000000..dab5f11 --- /dev/null +++ b/opencloud.spec @@ -0,0 +1,73 @@ +Summary: OpenCloud core services +Name: opencloud +Version: 1.0 +Release: 1 +License: GPL+ +Group: Development/Tools +Source0: %{_tmppath}/%{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} +requires: postgresql +requires: postgresql-server +requires: python-psycopg2 +requires: graphviz +requires: graphviz-devel +requires: graphviz-python +requires: libxslt-devel +requires: python-pip +requires: tar +requires: gcc + +%description +%{summary} + +%prep +%setup -q + +%build +# Empty section. + +%pre +pip-python install django==1.5 +pip-python install djangorestframework +pip-python install markdown # Markdown support for the browseable API. +pip-python install pyyaml # YAML content-type support. +pip-python install django-filter # Filtering support +pip-python install lxml # XML manipulation library +pip-python install netaddr # IP Addr library +pip-python install pytz +pip-python install django-timezones +pip-python install requests +pip-python install django-crispy-forms +pip-python install django-geoposition +pip-python install django-extensions +pip-python install django-suit +pip-python install django-evolution + +easy_install django_evolution + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot} +install -d %{buildroot}/opt/planetstack + +# in builddir +cp -rp /opt/plstackapi/planetstack %{buildroot}/opt/. + +find %{buildroot}/opt/planetstack -type f -print | sed "s@^$RPM_BUILD_ROOT@@g" > %{_tmppath}/tmp-filelist + +%clean +rm -rf %{buildroot} + +%files -f %{_tmppath}/tmp-filelist +%defattr(-,root,root,-) + +%post +/opt/planetstack/scripts/opencloud initdb + +%preun +rm -rf /opt/planetstack + +%changelog +* Sat Feb 22 2014 Siobhan Tully 1.0.0 +- First Build + diff --git a/planetstack/core/fixtures/initial_data.json b/planetstack/core/fixtures/initial_data.json index 6650547..469bc31 100644 --- a/planetstack/core/fixtures/initial_data.json +++ b/planetstack/core/fixtures/initial_data.json @@ -495,8 +495,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$v5qKhIyhSQ2N$V8vh2mkqYdjQib6d2jBkpwV57eMBfhd/9eiXqaDLUWg=", - "email": "padmin@vicci.org", - "enacted": null + "email": "padmin@vicci.org" } }, { @@ -520,8 +519,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "tony@onlab.us", - "enacted": null + "email": "tony@onlab.us" } }, { @@ -545,8 +543,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "mike@onlab.us", - "enacted": null + "email": "mike@onlab.us" } }, { @@ -570,8 +567,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "andy@onlab.us", - "enacted": null + "email": "andy@onlab.us" } }, { @@ -595,8 +591,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "sapan@onlab.us", - "enacted": null + "email": "sapan@onlab.us" } }, { @@ -620,8 +615,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "jcnelson@cs.princeton.edu", - "enacted": null + "email": "jcnelson@cs.princeton.edu" } }, { @@ -645,8 +639,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "llp@onlab.us", - "enacted": null + "email": "llp@onlab.us" } }, { @@ -670,8 +663,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "scott@onlab.us", - "enacted": null + "email": "scott@onlab.us" } }, { @@ -695,8 +687,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "ali@onlab.us", - "enacted": null + "email": "ali@onlab.us" } }, { @@ -720,8 +711,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "bill@onlab.us", - "enacted": null + "email": "bill@onlab.us" } }, { @@ -745,8 +735,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "guru@onlab.us", - "enacted": null + "email": "guru@onlab.us" } }, { @@ -770,8 +759,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "marc@onlab.us", - "enacted": null + "email": "marc@onlab.us" } }, { @@ -795,8 +783,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$dLKRXWJlkuvm$Ycamy79oT1lN0Q5R3B3nvlr70n2X50mL86yraDwzuWk=", - "email": "siobhan@onlab.us", - "enacted": null + "email": "siobhan@onlab.us" } }, { @@ -820,8 +807,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "pbkdf2_sha256$10000$jaLSTW2ksHEN$HDpjDKieFDjMvtV5wbF/ow3zfq8EqcFtNXLfuo+150s=", - "email": "demo@onlab.us", - "enacted": null + "email": "demo@onlab.us" } }, { @@ -845,8 +831,7 @@ "timezone": "America/New_York", "is_admin": true, "password": "!", - "email": "jhh@cs.arizona.edu", - "enacted": null + "email": "jhh@cs.arizona.edu" } }, { diff --git a/planetstack/scripts/opencloud b/planetstack/scripts/opencloud new file mode 100755 index 0000000..3005865 --- /dev/null +++ b/planetstack/scripts/opencloud @@ -0,0 +1,62 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo usage: $0 "[initdb | resetdb ]" + 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 { +# python manage.py runserver 128.95.1.128:8000 + echo "Starting OpenCloud Service on $HOSTNAME:8000" + python manage.py runserver $HOSTNAME:8000& +} + +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 + -- 2.43.0