summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalikiwikicreatesite38
1 files changed, 24 insertions, 14 deletions
diff --git a/localikiwikicreatesite b/localikiwikicreatesite
index 5fe16aa..fbb2935 100755
--- a/localikiwikicreatesite
+++ b/localikiwikicreatesite
@@ -296,26 +296,36 @@ git_setenv_work "$CFGDIR"
#perl_section_match_enable_param_match_enable "$CFGDIR/ikiwiki.setup" "git post-update wrapper" "wrappermode" "06755"
#shell_line_match_enable_appendlinebefore "$DESTSRCDIR/${project}_content.git/hooks/post-update" "^exec" "hooks/post-update-$project\n"
for cfgfile in $CFGDIR/ikiwiki*.setup; do
- perl -pi -e '
- s,^(\s*)#?(srcdir\s*=>\s*")[^"]*("\,\s*),$1$2'$SRCDIR'$3,;
- s,^(\s*)#?(destdir\s*=>\s*")[^"]*("\,\s*),$1$2'$DESTDIR'$3,;
- s,^(\s*)#?(url\s*=>\s*")[^"]*("\,\s*),$1$2http://'$host'$3,;
- s,^(\s*)#?(cgiurl\s*=>\s*")([^"]*)("\,\s*),$1#$2$3$4,;
- s,^(\s*)#?(rcs\s*=>\s*")(git)("\,\s*),$1$2$3$4,;
- ' "$cfgfile"
- perl -0 -pi -e '
- s,#{([\s#]*The git post-update wrapper[^}]*\s*)#(\s*wrapper =>\s*")[^"]*("\,\s*[^}]*)#(\s*wrappermode =>[^}]*)#},{$1$2'$DESTSRCDIR/${project}_content.git/hooks/post-update-$project'$3$4},;
- ' "$cfgfile"
+ perl -pi -e "
+ s,samplewiki,$project,g;
+ s,wiki\.example\.org,$host,g;
+ s,git\.example\.org,$srchost,g;
+ s,^(\s*)#?(rcs\s*=>\s*')[^']*('\,\s*),\$1\$2git\$3,;
+ s,^(\s*)#?(git_wrapper\s*=>),\$1\$2,;
+ s,^(\s*)#?(git_wrappermode\s*=>),\$1\$2,;
+ " "$cfgfile"
git add "$(basename "$cfgfile")"
done
-git commit -m "Adjust config files to use actual paths, and enable Git hooks."
+if [ -n "$origin" ]; then
+ git commit -m "Adjust config files to use actual paths, and enable Git hooks."
+else
+ perl -pi -e "
+ s,^(\s*)#?(srcdir\s*=>\s*')[^']*('\,\s*),\$1\$2$SRCDIR\$3,;
+ s,^(\s*)#?(destdir\s*=>\s*')[^']*('\,\s*),\$1\$2$DESTDIR\$3,;
+ s,^(\s*)#?(url\s*=>\s*')[^']*('\,\s*),\$1\$2http://$host\$3,;
+ s,^(\s*)#?(cgiurl\s*=>\s*')([^']*)('\,\s*),\$1#\$2\$3\$4,;
+ s,^(\s*)#?(git_wrapper\s*=>\s*')([^']*)('\,\s*),\$1\$2$DESTSRCDIR/${project}_content.git/hooks/post-update-ikiwiki\$4,;
+ " $CFGDIR/ikiwiki.setup
+ git add ikiwiki.setup
+ git commit -m "Add customized config file with Git hook enabled."
+fi
git_unsetenv
# Attach hooks to general post-update hook
# FIXME: Attach localized before master configs, and admin before non-admin
for hookfile in $DESTSRCDIR/${project}_content.git/hooks/post-update-*; do
- perl -0 -pi -e '
- s,\n(exec\s[^\n]*),\nhooks/'"$(basename "$hookfile")"'\n\n$1,;
- ' $DESTSRCDIR/${project}_content.git/hooks/post-update
+ perl -0 -pi -e "
+ s,\n(exec\s[^\n]*),\nhooks/$(basename "$hookfile")\n\n\$1,;
+ " $DESTSRCDIR/${project}_content.git/hooks/post-update
done
## Add Makefile for further customization