Created
March 10, 2014 10:39
-
-
Save DirkR/9462794 to your computer and use it in GitHub Desktop.
Update a python-powered static site blog based on (external) request.
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/sh | |
# (C) 2014 Dirk Ruediger | |
# Licensed under Do-with-it-wht-you-want license. | |
# | |
# Update a static site blog based on (external) request. | |
# This script works for python-powered blogs (pip, virtualenv, pelican, ...), | |
# but can adopted to other platforms easily. | |
# | |
# This script scans the project folder for a file '.dirty'. | |
# If this file is found, then it checks, if the requerements | |
# changed and, if anything changed, updates them. | |
# | |
# Then the git workspace and all git submodules are updated. | |
# Next step is to generate the project and rsync it to it's web space. | |
# | |
# The script can be run via cron. | |
# | |
PROJECT_HOME=$HOME/Projects/niebegeg.net | |
PUBLISH_DIR=/var/www/niebegeg.net | |
VIRTUAL_ENV=$HOME/.virtualenvs/pelican/ | |
update_requirements() { | |
UPDATE_REQUIREMENTS=1 | |
if [ -f $PROJECT_HOME/.requirements.bak ] | |
then | |
diff -q $PROJECT_HOME/requirements.txt $PROJECT_HOME/.requirements.bak && UPDATE_REQUIREMENTS=0 | |
fi | |
if [ $UPDATE_REQUIREMENTS == 1 ] | |
then | |
pip install --exists-action i --upgrade -r $PROJECT_HOME/requirements.txt | |
cp $PROJECT_HOME/requirements.txt $PROJECT_HOME/.requirements.bak | |
fi | |
} | |
. $VIRTUAL_ENV/bin/activate | |
if [ -f $PROJECT_HOME/.dirty ] | |
then | |
( | |
rm -f $PROJECT_HOME/.dirty | |
cd $PROJECT_HOME | |
update_requirements | |
git pull | |
git submodule init && git submodule update | |
$VIRTUAL_ENV/bin/pelican -o $PROJECT_HOME/output -s publishconf.py $PROJECT_HOME/content | |
rsync -ar --delete $PROJECT_HOME/output/ $PUBLISH_DIR/ | |
) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment