From abe54be58b221d1518bc5839b6f921a1f5873c4d Mon Sep 17 00:00:00 2001 From: Marc Date: Sat, 4 Oct 2014 17:40:13 +0000 Subject: [PATCH] deploy.sh: make sure git is installed --- README.md | 6 +-- TODO.md | 2 +- .../tests/functional_tests/tests.py | 3 ++ orchestra/bin/orchestra-admin | 7 +-- orchestra/conf/base_settings.py | 3 -- orchestra/conf/devel_settings.py | 3 ++ scripts/container/deploy.sh | 50 ++++++++++--------- 7 files changed, 39 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index b268ef80..1a04177e 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,7 @@ If you are planing to do some development or perhaps just checking out this proj ```bash wget -O /tmp/create.sh \ https://raw2.github.com/glic3rinu/django-orchestra/master/scripts/container/create.sh - chmod +x /tmp/create.sh - sudo /tmp/create.sh + sudo bash /tmp/create.sh sudo lxc-start -n orchestra ``` @@ -46,9 +45,8 @@ If you are planing to do some development or perhaps just checking out this proj ```bash wget -O /tmp/deploy.sh \ https://raw2.github.com/glic3rinu/django-orchestra/master/scripts/container/deploy.sh - chmod +x /tmp/deploy.sh cd /tmp/ # Moving away from /root before running deploy.sh - /tmp/deploy.sh + bash /tmp/deploy.sh ``` Django-orchestra source code should be now under `~orchestra/django-orchestra` and an Orchestra instance called _panel_ under `~orchestra/panel` diff --git a/TODO.md b/TODO.md index 6ae7c4ad..74c25d43 100644 --- a/TODO.md +++ b/TODO.md @@ -162,4 +162,4 @@ APPS app? * interdependency user <-> account with the old usermodel -* replace running_syncdb() by db_ready() +* pip upgrade or install diff --git a/orchestra/apps/systemusers/tests/functional_tests/tests.py b/orchestra/apps/systemusers/tests/functional_tests/tests.py index 4cbd1b97..a94e0209 100644 --- a/orchestra/apps/systemusers/tests/functional_tests/tests.py +++ b/orchestra/apps/systemusers/tests/functional_tests/tests.py @@ -170,6 +170,9 @@ class SystemUserMixin(object): # TODO +# TODO test resources + + class RESTSystemUserMixin(SystemUserMixin): def setUp(self): super(RESTSystemUserMixin, self).setUp() diff --git a/orchestra/bin/orchestra-admin b/orchestra/bin/orchestra-admin index 9fcee96d..19d91cda 100755 --- a/orchestra/bin/orchestra-admin +++ b/orchestra/bin/orchestra-admin @@ -144,7 +144,6 @@ function install_requirements () { kombu==3.0.23 \ billiard==3.3.0.18 \ Markdown==2.4 \ - django-debug-toolbar==1.2.1 \ djangorestframework==2.3.14 \ paramiko==1.15.1 \ ecdsa==0.11 \ @@ -153,7 +152,6 @@ function install_requirements () { passlib==1.6.2 \ jsonfield==0.9.22 \ lxml==3.3.5 \ - django-nose==1.2 \ python-dateutil==2.2 \ django-iban==0.3.0" @@ -165,7 +163,10 @@ function install_requirements () { xvfbwrapper \ freezegun \ coverage \ - orchestra-orm==dev" + orchestra-orm==dev \ + django-debug-toolbar==1.2.1 \ + django-nose==1.2 \ + sqlparse" fi # Make sure locales are in place before installing postgres diff --git a/orchestra/conf/base_settings.py b/orchestra/conf/base_settings.py index 554be0ff..b47bcc4b 100644 --- a/orchestra/conf/base_settings.py +++ b/orchestra/conf/base_settings.py @@ -253,6 +253,3 @@ PASSLIB_CONFIG = ( "superuser__django_pbkdf2_sha256__default_rounds = 15000\n" "superuser__sha512_crypt__default_rounds = 120000\n" ) - - -TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' diff --git a/orchestra/conf/devel_settings.py b/orchestra/conf/devel_settings.py index c89e40c4..82e2fc53 100644 --- a/orchestra/conf/devel_settings.py +++ b/orchestra/conf/devel_settings.py @@ -18,3 +18,6 @@ if "celeryd" in sys.argv or 'celeryev' in sys.argv or 'celerybeat' in sys.argv: INSTALLED_APPS += ('debug_toolbar', ) MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) INTERNAL_IPS = ('127.0.0.1', '10.0.3.1',) #10.0.3.1 is the lxcbr0 ip + + +TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' diff --git a/scripts/container/deploy.sh b/scripts/container/deploy.sh index 047b0e5a..ff3441d7 100755 --- a/scripts/container/deploy.sh +++ b/scripts/container/deploy.sh @@ -22,35 +22,40 @@ PROJECT_NAME='panel' BASE_DIR="$HOME/$PROJECT_NAME" -run () { +surun () { echo " ${bold}\$ su $USER -c \"${@}\"${normal}" su $USER -c "${@}" } +run () { + echo " ${bold}\$ ${@}${normal}" + ${@} +} + # Create a system user for running Orchestra useradd orchestra -s "/bin/bash" echo "$USER:$PASSWORD" | chpasswd mkdir $HOME chown $USER.$USER $HOME -sudo adduser $USER sudo +run adduser $USER sudo CURRENT_VERSION=$(python -c "from orchestra import get_version; print get_version();" 2> /dev/null || false) if [[ ! $CURRENT_VERSION ]]; then # First Orchestra installation - sudo apt-get -y install git python-pip - run "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" + run "apt-get -y install git python-pip" + surun "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" echo $HOME/django-orchestra/ | sudo tee /usr/local/lib/python2.7/dist-packages/orchestra.pth - sudo cp $HOME/django-orchestra/orchestra/bin/orchestra-admin /usr/local/bin/ + run "cp $HOME/django-orchestra/orchestra/bin/orchestra-admin /usr/local/bin/" fi sudo orchestra-admin install_requirements if [[ ! -e $BASE_DIR ]]; then cd $HOME - run "orchestra-admin startproject $PROJECT_NAME" + surun "orchestra-admin startproject $PROJECT_NAME" cd - fi @@ -60,46 +65,43 @@ if [[ ! $(sudo su postgres -c "psql -lqt" | awk {'print $1'} | grep '^orchestra$ # orchestra database does not esists # Speeding up tests, don't do this in production! POSTGRES_VERSION=$(psql --version | head -n1 | awk {'print $3'} | sed -r "s/(^[0-9\.]*).*/\1/") - sudo sed -i "s/^#fsync =\s*.*/fsync = off/" \ + sed -i "s/^#fsync =\s*.*/fsync = off/" \ /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf - sudo sed -i "s/^#full_page_writes =\s*.*/full_page_writes = off/" \ + sed -i "s/^#full_page_writes =\s*.*/full_page_writes = off/" \ /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf - sudo service postgresql restart - sudo python $MANAGE setuppostgres --db_name orchestra --db_user orchestra --db_password orchestra + run "service postgresql restart" + run "python $MANAGE setuppostgres --db_name orchestra --db_user orchestra --db_password orchestra" # Create database permissions are needed for running tests sudo su postgres -c 'psql -c "ALTER USER orchestra CREATEDB;"' fi if [[ $CURRENT_VERSION ]]; then # Per version upgrade specific operations - sudo python $MANAGE postupgradeorchestra --no-restart --from $CURRENT_VERSION + run "python $MANAGE postupgradeorchestra --no-restart --from $CURRENT_VERSION" else - sudo python $MANAGE syncdb --noinput - sudo python $MANAGE migrate --noinput + run "python $MANAGE syncdb --noinput" + run "python $MANAGE migrate --noinput" fi sudo python $MANAGE setupcelery --username $USER --processes 2 # Install and configure Nginx web server -run "mkdir $BASE_DIR/static" -run "python $MANAGE collectstatic --noinput" -sudo apt-get install -y nginx uwsgi uwsgi-plugin-python -sudo python $MANAGE setupnginx -sudo service nginx start +surun "mkdir $BASE_DIR/static" +surun "python $MANAGE collectstatic --noinput" +run "apt-get install -y nginx uwsgi uwsgi-plugin-python" +run "python $MANAGE setupnginx" +run "service nginx start" # Apply changes -sudo python $MANAGE restartservices +run "python $MANAGE restartservices" # Create a orchestra user cat <<- EOF | python $MANAGE shell -from django.contrib.auth.models import User from orchestra.apps.accounts.models import Account -if not User.objects.filter(username=$USER).exists(): +if not Account.objects.filter(username=$USER).exists(): print 'Creating orchestra superuser' - user = User.objects.create_superuser($USER, "'$USER@localhost'", $PASSWORD) - user.account = Account.objects.create(user=user) - user.save() + Account.objects.create_superuser($USER, "'$USER@localhost'", $PASSWORD) EOF