Created
June 5, 2014 01:18
-
-
Save ycombinator/0510f4bfd6a02dcee929 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# | |
# This script builds the various parts of the site (Getting Started guides, | |
# blog, etc.) and combines them into a single directory, `site_html`. | |
# | |
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
BUILD_DIR=/tmp/developer.rackspace.com | |
WORK_DIR=$BUILD_DIR/_work | |
TARGET_DIR=$PROJECT_ROOT/_site | |
ALL_PIDS=$(pgrep build_site.sh) | |
NUM_ALL_PIDS=$(echo "$ALL_PIDS" | wc -l) | |
if (( $NUM_ALL_PIDS > 1 )); then | |
# If there's clones of me already running, kill all of them | |
# so I'm the only one running | |
for pid in "$ALL_PIDS"; do | |
if [ $pid != $$ ]; then | |
echo "Killing my clone with PID = $pid" | |
kill $pid | |
fi | |
done | |
fi | |
# Create temporary work directory | |
rm -rf $WORK_DIR | |
mkdir -p $WORK_DIR | |
# Copy the site source into the work directory | |
rsync -Ca $PROJECT_ROOT/src/site_source/ $WORK_DIR/ | |
# Build the Getting Started guides in the `docs/` directory using Sphinx | |
cd $PROJECT_ROOT/src/docs | |
/usr/local/bin/sphinx-build . $WORK_DIR/docs | |
# Build the web site HTML | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
cd $WORK_DIR | |
/usr/local/bin/jekyll build --source . --destination $BUILD_DIR/_site | |
# Copy to target dir | |
rsync -Ca $BUILD_DIR/_site/ $TARGET_DIR/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment