#!/bin/sh replace_string() { sed "s//$2/" } fugitive_write_template() { name=`git config --get user.name` base64 -d | gunzip | replace_string "name" "$name" | \ replace_string "year" "`date +%Y`" } fugitive_install_hooks() { echo -n "Installing fugitive hooks scripts... " (base64 -d | gunzip) > .git/hooks/pre-commit < .git/hooks/pre-receive < .git/hooks/post-commit < .git/hooks/post-receive <> .git/hooks/post-receive </dev/null echo "done." fi fugitive_install_config "$1" fugitive_install_hooks "$1" echo -n "Preventing git to track temporary and generated files... " cat >> .git/info/exclude < _templates/article.html < _templates/archives.html < _templates/top.html < _templates/bottom.html < _templates/rss.xml < _templates/atom.xml < _templates/sitemap.xml < _public/fugitive.css < _public/print.css </dev/null git commit --no-verify -m "fugitive inital import" >/dev/null 2>&1 echo "done." echo "Writing dummy article (README) and adding it to the repos... " (base64 -d | gunzip) > _articles/fugitive-readme </dev/null echo "done." fi echo "Installation complete, please set your blog url using" echo '`git config fugitive.blog-url ""`.' } fugitive_usage() { echo "This is fugitive installation script." echo "To install a local (where you commit) repository of your blog run:" echo " fugitive --install-local " echo -n "where is where you want the installation to take place, " echo "it's in the working directory by defaults." echo "To install a remote (where you push) repository of your blog run:" echo " fugitive --install-remote " echo -n "where is where you want the installation to take place, " echo "it's in the working directory by defaults." } fugitive_help() { echo -n "fugitive is a blog engine running on top of git using hooks to " echo "generate static html pages and thus having only git as dependency." fugitive_usage } DIR="." if [ "$2" != "" ]; then DIR="$2"; fi if [ ! -d "$DIR" ]; then mkdir -p "$DIR"; fi cd "$DIR" case "$1" in "--help"|"-h") fugitive_help >&2;; "--install"|"--install-local") fugitive_install "local";; "--install-remote") fugitive_install "remote";; "--install-hooks") fugitive_install_hooks ;; "--install-config") fugitive_install_config "local";; *) fugitive_usage >&2;; esac cd - >/dev/null