summaryrefslogtreecommitdiff
path: root/localikiwikicreatesite
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2008-02-13 17:03:49 +0000
committerJonas Smedegaard <dr@jones.dk>2008-02-13 17:03:49 +0000
commit4201e6c17c1aaa5474f3a3827d6557cb1beeb041 (patch)
tree6c438664cc79bc711982fb2fe096ac85670b2f56 /localikiwikicreatesite
parent9b873f0335b3b035146413182522f2f1d59293a0 (diff)
write git initializations as functions.
Diffstat (limited to 'localikiwikicreatesite')
-rwxr-xr-xlocalikiwikicreatesite65
1 files changed, 32 insertions, 33 deletions
diff --git a/localikiwikicreatesite b/localikiwikicreatesite
index 95653d0..3bd3019 100755
--- a/localikiwikicreatesite
+++ b/localikiwikicreatesite
@@ -3,7 +3,7 @@
# /usr/local/bin/localikiwikicreatesite
# Copyright 2008 Jonas Smedegaard <dr@jones.dk>
#
-# $Id: localikiwikicreatesite,v 1.13 2008-02-13 15:32:13 jonas Exp $
+# $Id: localikiwikicreatesite,v 1.14 2008-02-13 17:03:49 jonas Exp $
#
# Initialize ikiwiki site
#
@@ -55,6 +55,32 @@ exit1() {
exit 1
}
+git_init_pub() {
+ repo="$DESTSRCDIR/$1.git"
+
+ mkdir -p $repo
+ (cd $repo
+ git --bare init --shared
+ )
+}
+
+git_init_work() {
+ repo="$DESTSRCDIR/$1.git"
+ targetdir="$2"
+
+ (cd $targetdir
+ git init
+ echo /.ikiwiki > .gitignore
+ git add .
+ git commit -m "initial commit"
+ git remote add origin $repo
+ git config branch.master.remote origin
+ git config branch.master.merge refs/heads/master
+ git push --all
+ )
+ chmod +x $repo/hooks/post-update
+}
+
while true ; do
case "$1" in
-d|--domain) domain="$1"; shift 2;;
@@ -85,13 +111,8 @@ DESTDIR=~/public_websites/$host
DESTSRCDIR=~/public_websites/$srchost
## Init public RCS repositories
-mkdir -p $DESTSRCDIR/${project}.git $DESTSRCDIR/${project}_content.git
-(cd $DESTSRCDIR/${project}_content.git
-git --bare init --shared
-)
-(cd $DESTSRCDIR/${project}.git
-git --bare init --shared
-)
+git_init_pub "$project"
+git_init_pub "${project}_content"
## Create initial content
mkdir -p $SRCDIR
@@ -109,31 +130,9 @@ EOF
mkdir -p $CFGDIR
cp /usr/share/doc/ikiwiki/html/ikiwiki.setup $CFGDIR
-## Init content RCS
-(cd $SRCDIR
-git init
-echo /.ikiwiki > .gitignore
-git add .
-git commit -m "initial commit"
-git remote add origin $DESTSRCDIR/${project}_content.git
-git config branch.master.remote origin
-git config branch.master.merge refs/heads/master
-git push --all
-chmod +x $DESTSRCDIR/${project}_content.git/hooks/post-update
-)
-
-## Init backend RCS
-(cd $CFGDIR
-git init
-echo /content > .gitignore
-git add .
-git commit -m "initial commit"
-git remote add origin $DESTSRCDIR/$project.git
-git config branch.master.remote origin
-git config branch.master.merge refs/heads/master
-git push --all
-chmod +x $DESTSRCDIR/${project}.git/hooks/post-update
-)
+## Init working RCS repositories
+git_init_work "$project" "$CFGDIR"
+git_init_work "${project}_content" "$SRCDIR"
## Adjust backend to actual paths, and enable Git post-update wrapper
perl -pi -e '