2010-07-23 02:52:43 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-07-25 00:57:27 +02:00
|
|
|
replace_string() {
|
2010-09-16 19:02:24 +02:00
|
|
|
sed "s/<?fugitive-install[[:space:]]\+$1[[:space:]]*?>/$2/"
|
2010-07-23 02:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fugitive_write_template() {
|
|
|
|
name=`git config --get user.name`
|
2010-07-25 00:57:27 +02:00
|
|
|
base64 -d | gunzip | replace_string "name" "$name" | \
|
|
|
|
replace_string "year" "`date +%Y`"
|
2010-07-23 02:52:43 +02:00
|
|
|
}
|
|
|
|
|
2010-07-23 11:48:56 +02:00
|
|
|
fugitive_install_hooks() {
|
|
|
|
echo -n "Installing fugitive hooks scripts... "
|
2010-08-10 22:25:11 +02:00
|
|
|
(base64 -d | gunzip) >> .git/hooks/pre-commit <<EOF
|
|
|
|
#INCLUDE:pre-commit.sh#
|
|
|
|
EOF
|
|
|
|
(base64 -d | gunzip) >> .git/hooks/pre-receive <<EOF
|
|
|
|
#INCLUDE:pre-receive.sh#
|
|
|
|
EOF
|
2010-07-23 11:48:56 +02:00
|
|
|
(base64 -d | gunzip) > .git/hooks/post-commit <<EOF
|
|
|
|
#INCLUDE:post-commit.sh#
|
|
|
|
EOF
|
|
|
|
(base64 -d | gunzip) > .git/hooks/post-receive <<EOF
|
|
|
|
#INCLUDE:post-receive.sh#
|
|
|
|
EOF
|
2010-08-02 13:49:17 +02:00
|
|
|
(base64 -d | gunzip | \
|
|
|
|
tee -a .git/hooks/post-commit) >> .git/hooks/post-receive <<EOF
|
|
|
|
#INCLUDE:html-gen.sh#
|
|
|
|
EOF
|
2010-08-10 22:25:11 +02:00
|
|
|
chmod +x .git/hooks/pre-commit
|
|
|
|
chmod +x .git/hooks/pre-receive
|
2010-08-02 13:49:17 +02:00
|
|
|
chmod +x .git/hooks/post-commit
|
2010-07-23 11:48:56 +02:00
|
|
|
chmod +x .git/hooks/post-receive
|
|
|
|
echo "done."
|
|
|
|
}
|
|
|
|
|
2010-09-24 15:12:41 +02:00
|
|
|
fugitive_install_config() {
|
|
|
|
echo -n "Adding default fugitive settings to git config... "
|
|
|
|
if [ "$1" = "remote" ]; then
|
2010-07-26 18:59:25 +02:00
|
|
|
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"
|
2010-07-26 11:45:37 +02:00
|
|
|
git config --add fugitive.preproc ""
|
2010-07-23 02:52:43 +02:00
|
|
|
echo "done."
|
2010-09-24 15:12:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fugitive_install() {
|
|
|
|
if [ -d ".git" ]; then
|
|
|
|
echo "There's already a git repository here, aborting install."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo -n "Creating new git repository... "
|
|
|
|
git init >/dev/null
|
|
|
|
echo "done."
|
2011-05-21 14:37:16 +02:00
|
|
|
fugitive_install_config "$1"
|
2010-09-24 15:12:41 +02:00
|
|
|
fugitive_install_hooks "$1"
|
2010-07-26 18:59:25 +02:00
|
|
|
echo -n "Preventing git to track temporary and generated files... "
|
|
|
|
cat >> .git/info/exclude <<EOF
|
|
|
|
*~
|
|
|
|
_public/index.html
|
|
|
|
_public/archives.html
|
|
|
|
_public/feed.xml
|
|
|
|
EOF
|
|
|
|
echo "done."
|
2010-09-24 15:12:41 +02:00
|
|
|
if [ "$1" = "local" ]; then
|
2010-07-26 18:59:25 +02:00
|
|
|
echo -n "Creating default directory tree... "
|
|
|
|
mkdir -p _drafts _articles _templates _public
|
|
|
|
echo "done."
|
|
|
|
echo -n "Writing default template files... "
|
|
|
|
fugitive_write_template > _templates/article.html <<EOF
|
2010-07-25 00:57:27 +02:00
|
|
|
#INCLUDE:default-files/article.html#
|
2010-07-23 02:52:43 +02:00
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
fugitive_write_template > _templates/archives.html <<EOF
|
2010-07-25 00:57:27 +02:00
|
|
|
#INCLUDE:default-files/archives.html#
|
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
fugitive_write_template > _templates/top.html <<EOF
|
2010-07-25 18:52:35 +02:00
|
|
|
#INCLUDE:default-files/top.html#
|
2010-07-25 00:57:27 +02:00
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
fugitive_write_template > _templates/bottom.html <<EOF
|
2010-07-25 18:52:35 +02:00
|
|
|
#INCLUDE:default-files/bottom.html#
|
2010-07-24 04:27:49 +02:00
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
fugitive_write_template > _templates/feed.xml <<EOF
|
2010-07-25 18:52:35 +02:00
|
|
|
#INCLUDE:default-files/feed.xml#
|
2010-07-23 02:52:43 +02:00
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
echo "done."
|
|
|
|
echo -n "Writing default css files... "
|
|
|
|
(base64 -d | gunzip) > _public/fugitive.css <<EOF
|
2010-07-25 00:57:27 +02:00
|
|
|
#INCLUDE:default-files/fugitive.css#
|
2010-07-24 01:28:59 +02:00
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
(base64 -d | gunzip) > _public/print.css <<EOF
|
2010-07-25 00:57:27 +02:00
|
|
|
#INCLUDE:default-files/print.css#
|
2010-07-23 02:52:43 +02:00
|
|
|
EOF
|
2010-07-26 18:59:25 +02:00
|
|
|
echo "done."
|
|
|
|
echo -n "Importing files into git repository... "
|
|
|
|
git add _templates/* _public/*.css >/dev/null
|
2010-08-10 22:25:11 +02:00
|
|
|
git commit --no-verify -m "fugitive inital import" >/dev/null 2>&1
|
2010-07-26 18:59:25 +02:00
|
|
|
echo "done."
|
|
|
|
echo "Writing dummy article (README) and adding it to the repos... "
|
2010-09-04 23:00:53 +02:00
|
|
|
(base64 -d | gunzip) > _articles/fugitive-readme <<EOF
|
2010-07-25 18:52:35 +02:00
|
|
|
#INCLUDE:README#
|
|
|
|
EOF
|
2010-09-04 23:00:53 +02:00
|
|
|
git add _articles/fugitive-readme
|
2011-05-21 14:26:47 +02:00
|
|
|
git commit --no-verify --author="p4bl0 <r@uzy.me>" \
|
2010-09-24 14:56:11 +02:00
|
|
|
-m "fugitive: README" >/dev/null
|
2010-07-26 18:59:25 +02:00
|
|
|
echo "done."
|
|
|
|
fi
|
2010-08-02 13:49:17 +02:00
|
|
|
echo "Installation complete, please set your blog url using"
|
|
|
|
echo '`git config fugitive.blog-url "<url>"`.'
|
2010-07-23 02:52:43 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 23:18:25 +02:00
|
|
|
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 <dir>"
|
|
|
|
echo -n "where <dir> 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 <dir>"
|
|
|
|
echo -n "where <dir> 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
|
|
|
|
}
|
|
|
|
|
2010-09-24 15:12:41 +02:00
|
|
|
DIR="."
|
|
|
|
if [ "$2" != "" ]; then DIR="$2"; fi
|
|
|
|
if [ ! -d "$DIR" ]; then mkdir -p "$DIR"; fi
|
|
|
|
cd "$DIR"
|
2010-07-23 02:52:43 +02:00
|
|
|
case "$1" in
|
2010-09-04 23:18:25 +02:00
|
|
|
"--help"|"-h") fugitive_help >&2;;
|
2010-09-24 15:12:41 +02:00
|
|
|
"--install"|"--install-local") fugitive_install "local";;
|
|
|
|
"--install-remote") fugitive_install "remote";;
|
|
|
|
"--install-hooks") fugitive_install_hooks ;;
|
|
|
|
"--install-config") fugitive_install_config "local";;
|
2010-09-04 23:18:25 +02:00
|
|
|
*) fugitive_usage >&2;;
|
2010-07-23 02:52:43 +02:00
|
|
|
esac
|
2010-09-24 15:12:41 +02:00
|
|
|
cd - >/dev/null
|