Created
January 24, 2015 13:39
-
-
Save brouberol/29cef38baf600cd009b8 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 | |
PAGE_DIR=/var/www/ | |
TMP_PAGE_CLONE=$HOME/page-tmp | |
PAGE_GIT=/home/git/page.git | |
PAGE=$TMP_PAGE_CLONE/index.html | |
CURRENT_AGE=`python -c 'from datetime import date;print(date.today() - date(1990, 11, 4)).days / 365'` | |
CURRENT_YEAR=`date +%Y` | |
function template_replace { | |
echo "Replacing '{{$1}}' by '$2'"; | |
sed -i "s/{{$1}}/$2/" $PAGE; | |
} | |
git clone $PAGE_GIT $TMP_PAGE_CLONE | |
# Replace placeholders by computed values | |
template_replace age $CURRENT_AGE | |
template_replace year $CURRENT_YEAR | |
cp -rvu --preserve=mode,ownership $TMP_PAGE_CLONE/* $PAGE_DIR | |
rm -rf $TMP_PAGE_CLONE | |
echo "Temporary repository removed" | |
echo "Deployment complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment