-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autodeploy had bad race conditions, but no more.
- Loading branch information
Showing
1 changed file
with
27 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|