#!/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." echo -n "Adding default settings to git config... " if [ "$2" = "remote" ]; then git config --add receive.denyCurrentBranch "ignore" fi git config --add fugitive.blog-url "" git config --add fugitive.templates-dir "_templates" git config --add fugitive.articles-dir "_articles" git config --add fugitive.public-dir "_public" git config --add fugitive.preproc "" echo "done." fugitive_install_hooks 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/feed.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/README </dev/null echo "done." fi echo "Installation complete, please set your blog url using" echo '`git config fugitive.blog-url ""`.' cd - >/dev/null } case "$1" in "--help"|"-h") fugitive_help >&2;; # TODO "--install"|"--install-local") fugitive_install "$2" "local";; "--install-remote") fugitive_install "$2" "remote";; "--install-hooks") fugitive_install_hooks;; *) fugitive_usage >&2;; # TODO esac