Skip to content

Commit

Permalink
Remove race conditions
Browse files Browse the repository at this point in the history
Autodeploy had bad race conditions, but no more.
  • Loading branch information
pjz committed Apr 25, 2014
1 parent 8f93cfa commit 2472a9d
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions deploy_html
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
#!/bin/bash

NOW=`date +%Y%m%d_%H%M%S`
DESTDIR=/tmp/www
ZIPFILE=/tmp/website.$$.zip
ZIPDIR=${DESTDIR}/website_$NOW
DESTDIR_HTML=${DESTDIR}/html_$NOW

# get the latest version from github
wget https://github.com/nova-labs/website/archive/master.zip -O $ZIPFILE
# make a working dir
mkdir -p $ZIPDIR
# go to the working directory
cd $ZIPDIR

# go to the destination directory
cd $DESTDIR
# get the latest version from github
wget https://github.com/nova-labs/website/archive/master.zip -O master.zip

# unzip the website zipfile
unzip $ZIPFILE
unzip master.zip

# delete the old backup if it exists
[ -d html.prev ] && rm -rf html.prev
# move the new site to the production location
mv website-master/html $DESTDIR_HTML
mv -f website-master/deploy_html $DESTDIR/deploy_html

# move the current site to be the new backup
mv html html.prev
cd $DESTDIR

# move the new site to the production location
mv website-master/html html
mv website-master/deploy_html deploy_html
if [ ! -L html ]; then
if [ -d html ]; then
# Legacy html directory that's not a symlink
mv html html.legacy
else
# no idea wtf this is, but move it out of the way
mv html html_$NOW.wtf
fi
fi

# make the symlink, replacing an existing one if necessary
ln -snf html_$NOW html

# clean up leftovers
rm -rf website-master $ZIPFILE
rm -rf $ZIPDIR

0 comments on commit 2472a9d

Please sign in to comment.