From 9ab3132f5e4db66a9ea139cf470885ef032c529b Mon Sep 17 00:00:00 2001 From: Paul McLanahan Date: Wed, 25 Feb 2015 13:42:18 -0500 Subject: [PATCH] Fix bug 1136559: Add dev deploy cron scripts to repo. Also fix dev chief autodeploy script. --- bin/update-scripts/dev/update-dev-django.sh | 44 +++++++++++++++++++++ bin/update-scripts/dev/update-dev-locale.sh | 21 ++++++++++ bin/update-scripts/dev/update-dev-php.sh | 28 +++++++++++++ etc/cron.d/bedrock-dev.tmpl | 8 ++-- 4 files changed, 96 insertions(+), 5 deletions(-) create mode 100755 bin/update-scripts/dev/update-dev-django.sh create mode 100755 bin/update-scripts/dev/update-dev-locale.sh create mode 100755 bin/update-scripts/dev/update-dev-php.sh diff --git a/bin/update-scripts/dev/update-dev-django.sh b/bin/update-scripts/dev/update-dev-django.sh new file mode 100755 index 0000000000..4370958de2 --- /dev/null +++ b/bin/update-scripts/dev/update-dev-django.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# This must match the name of the webapp in the Chief configs (/var/www/chief/settings.py) +# This should be the only change you need to make. +WEBAPP="bedrock.dev" + +function checkretval(){ + retval=$? + if [[ $retval -gt 0 ]]; then + echo "Error!!! Exit status of the last command was $retval" + exit $retval + fi +} + +# Get the sha currently deployed +SHADEPLOYED=$(curl -s -XGET https://www-dev.allizom.org/media/revision.txt) +SHAAVAILABLE=$(git ls-remote git://github.com/mozilla/bedrock.git master | awk '{print $1;}') +# Nix the 4 bytes before the sha because it's http smart protocol +#SHAAVAILABLE="${SHAAVAILABLE:4}" + +echo "We have ${SHADEPLOYED:0:8} and ${SHAAVAILABLE:0:8} is available." + +if [ "$SHADEPLOYED" = "$SHAAVAILABLE" ]; +then + # Nothing to deploy + echo "Nothing to deploy." + exit 0 +fi + +# Here we will load the WEBAPPS object from the Chief configs and grab the update password for our $WEBAPP +PASSWORD=$(/data/bedrock-dev/src/www-dev.allizom.org-django/password.py) + +# If there was an error in the python we will raise it here ($PASSWORD contains the error in this case) +if [ $? != 0 ]; then + echo -e "$PASSWORD" + exit 1 +fi + +echo "Calling Chief for '$WEBAPP' to deploy '${SHAAVAILABLE:0:8}'" + +# This just creates a POST event to the Chief app. We populate the form fields with the information gathered above ($SHAAVAILABLE, $PASSWORD, $WEBAPP) +curl -s -F 'who=web-ops_cli_script' -F "password=$PASSWORD" -F "ref=$SHAAVAILABLE" http://$(hostname)/chief/$WEBAPP -o /dev/null +checkretval + diff --git a/bin/update-scripts/dev/update-dev-locale.sh b/bin/update-scripts/dev/update-dev-locale.sh new file mode 100755 index 0000000000..32c4f9862e --- /dev/null +++ b/bin/update-scripts/dev/update-dev-locale.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +UPSTREAM=$(svn info https://svn.mozilla.org/projects/mozilla.com/trunk/locales | grep Revision | cut -f2 -d' ') +cd /data/bedrock-dev/src/www-dev.allizom.org-django/bedrock + +pushd locale > /dev/null +RUNNING=$(svnversion ./ | tr -d '[A-Z]') +UPDATED=0 +if [ "$RUNNING" != "$UPSTREAM" ]; then + svn cleanup + svn -q up + UPDATED=1 +fi +popd > /dev/null + +if [ $UPDATED -eq 1 ]; then + /data/bedrock-dev/deploy -q www-dev.allizom.org-django/bedrock/locale +else +# echo "Nothing to deploy." + exit 0 +fi diff --git a/bin/update-scripts/dev/update-dev-php.sh b/bin/update-scripts/dev/update-dev-php.sh new file mode 100755 index 0000000000..52a0360155 --- /dev/null +++ b/bin/update-scripts/dev/update-dev-php.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +UPSTREAM=$(svn info https://svn.mozilla.org/projects/mozilla.org/trunk | grep Revision | cut -f2 -d' ') +cd /data/bedrock-dev/src/www-dev.allizom.org + +RUNNING=$(svnversion ./ | tr -d '[A-Z]') +UPDATED=0 +if [ "$RUNNING" != "$UPSTREAM" ]; then + svn cleanup + svn -q up + UPDATED=1 +fi + +cd org +RUNNING=$(svnversion ./ | tr -d '[A-Z]') +if [ "$RUNNING" != "$UPSTREAM" ]; then + svn cleanup + svn -q up + UPDATED=1 +fi + +if [ $UPDATED -eq 1 ]; then + /data/bedrock-dev/deploy www-dev.allizom.org > /dev/null 2>&1 +else + # removing per bug 1087514 + # echo "Nothing to deploy." + exit 0 +fi diff --git a/etc/cron.d/bedrock-dev.tmpl b/etc/cron.d/bedrock-dev.tmpl index 8b4427ca13..c1d7d64e5a 100644 --- a/etc/cron.d/bedrock-dev.tmpl +++ b/etc/cron.d/bedrock-dev.tmpl @@ -4,14 +4,12 @@ MAILTO="webops-cron@mozilla.com,cron-bedrock@mozilla.com" -0-59/10 * * * * root /data/bedrock-dev/src/update-www-dev.allizom.org.sh -# TODO Make this run chief -1-59/10 * * * * root /data/bedrock-dev/src/update-www-dev.allizom.org-django.sh +*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-php.sh +*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-django.sh +*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-locale.sh */5 * * * * {{ django_manage }} rnasync > /dev/null 2>&1 -*/15 * * * * root /data/bedrock-dev/src/update-www-dev.allizom.org-svn-locale.sh - # bug 1014586 3 */2 * * * {{ django_cron }} update_tweets > /dev/null 2>&1