Skip to content

Instantly share code, notes, and snippets.

@oremj
Created January 6, 2011 00:03
Show Gist options
  • Save oremj/767269 to your computer and use it in GitHub Desktop.
Save oremj/767269 to your computer and use it in GitHub Desktop.
updates amo
#!/bin/bash
AMO_DIR=/data/amo_python/src/prod/zamboni
SRC_TAG=$1
VENDOR_TAG=$2
function confirm {
PROMPT=$1
read -p "$PROMPT [y/n]: " YESNO
if [[ $YESNO == 'y' ]]
then
return 0
else
return 1
fi
}
function git_checkout_tag {
TAG=$1
git fetch -t origin &&
git checkout $TAG &&
git submodule sync
git submodule update --init
if [[ $? == 1 ]]
then
echo "There was a network error talking to github"
exit 1
fi
}
function update_code {
git_checkout_tag $SRC_TAG
if [[ ! -z $VENDOR_TAG ]]
then
pushd vendor > /dev/null
git_checkout_tag $VENDOR_TAG
popd > /dev/null
fi
}
function update_locales {
pushd locale > /dev/null
svn revert -R .
svn up
popd > /dev/null
}
if [[ -z $SRC_TAG ]]
then
exit
fi
if confirm "Disable cron?"
then
mv /etc/cron.d/addons-prod-maint /tmp/addons-prod-maint
fi
cd $AMO_DIR
set -x
/usr/bin/find . -name "*.pyc" -exec rm "{}" \;
update_code
set +x
if confirm "Update locales?"
then
update_locales
fi
if confirm "Compress assets?"
then
python26 manage.py compress_assets
fi
if confirm "Run schematic?"
then
schematic migrations | tee /tmp/migrations-$(date +"%Y%m%d%H%M%S").out
fi
if confirm "Push live?"
then
/data/bin/omg_push_zamboni_live.sh
if confirm "Push and restart celeryd?"
then
issue-multi-command amo_gearman '/data/bin/libget/get-php5-www-git.sh; service celeryd-prod restart'
issue-multi-command amo_gearman 'service celeryd-prod-devhub restart'
fi
issue-multi-command -c 5 amo '/data/bin/libget/get-php5-www-git.sh; apachectl graceful'
fi
if confirm "Clear redis/memcache?"
then
issue-multi-command -c 1 amo_memcache 'service memcached restart'
issue-multi-command -c 1 amo_redis 'pkill -9 -f "redis.*/amo.conf"; sleep 3; /etc/init.d/redis-amo start'
fi
if confirm "Enable cron?"
then
cp scripts/crontab/prod /etc/cron.d/addons-prod-maint
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment