summaryrefslogtreecommitdiff
path: root/install.sh
diff options
context:
space:
mode:
authorp4bl0 <pablo@rauzy.name>2010-07-23 03:02:23 +0200
committerp4bl0 <pablo@rauzy.name>2010-07-23 03:02:23 +0200
commitf59b2bd1d4f8ff3548af12e9ca9367562e60373c (patch)
tree8a9b07c1abf96c6ea3374f42360b8b7f70f9370f /install.sh
parent4467a42aee94c85868fc4c706669fcf89707bce3 (diff)
in fact a Makefile makes no sens here, what I'll need is juste un build script. Thus src dir has no more any reason to be
Diffstat (limited to 'install.sh')
-rw-r--r--install.sh70
1 files changed, 70 insertions, 0 deletions
diff --git a/install.sh b/install.sh
new file mode 100644
index 0000000..a14c8c8
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+replace_var_by_string() {
+ sed "s/<?fugitive-install\s\+$1\s*?>/$2/"
+}
+
+fugitive_write_template() {
+ name=`git config --get user.name`
+ base64 -d | gunzip | replace_var_by_string name "$name" | \
+ replace_var_by_string year "`date +%Y`"
+}
+
+fugitive_install() {
+ DIR="."
+ if [ "$1" != "" ]; then DIR="$1"; fi
+ if [ ! -d "$DIR" ]; then mkdir -p "$DIR"; fi
+ cd "$DIR"
+ echo -n "Creating new git repository... "
+ git init >/dev/null
+ echo "done."
+ echo -n "Creating default directory tree... "
+ mkdir -p fugitive/{drafts,articles,templates}
+ echo "done."
+ echo -n "Adding default directory paths to git config... "
+ git config --add --path fugitive.templates-dir "fugitive/templates"
+ git config --add --path fugitive.articles-dir "fugitive/articles"
+ git config --add --path fugitive.public-dir "."
+ echo "done."
+ echo -n "Writing default template files... "
+ fugitive_write_template > fugitive/templates/article.html <<EOF
+#INCLUDE:article.html#
+EOF
+ fugitive_write_template > fugitive/templates/archives.html <<EOF
+#INCLUDE:archives.html#
+EOF
+ echo "done."
+ echo -n "Writing default css file... "
+ (base64 -d | gunzip) > fugitice.css <<EOF
+#INCLUDE:fugitive.css#
+EOF
+ echo "done."
+ echo -n "Installing fugitive hooks scripts... "
+ (base64 -d | gunzip) > .git/hooks/post-commit <<EOF
+#INCLUDE:post-commit.sh#
+EOF
+ chmod +x .git/hooks/post-receive
+ (base64 -d | gunzip) > .git/hooks/post-receive <<EOF
+#INCLUDE:post-receive.sh#
+EOF
+ chmod +x .git/hooks/post-receive
+ echo "done."
+ echo -n "Importing files into git repository... "
+ git add fugitive/templates/* fugitive.css >/dev/null
+ git commit -m "fugitive inital import" >/dev/null
+ echo "done."
+ echo -n "Preventing git to track generated html files... "
+ (base64 -d | gunzip) > .git/info/exclude <<EOF
+#INCLUDE:exclude#
+EOF
+ echo "done."
+ cd -
+ echo "Installation complete, please see the README file for an howto."
+}
+
+case "$1" in
+ "--help") fugitive_help >&2;;
+ "--install") fugitive_install "$2";;
+ "--install-hooks") fugitive_install_hooks "$2";;
+ *) fugitive_usage >&2;;
+esac