summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--doc/bugs.mdwn2
-rw-r--r--doc/index.mdwn2
-rw-r--r--doc/post-commit.mdwn10
-rw-r--r--doc/setup.mdwn68
-rw-r--r--doc/wrapperparamstrick.mdwn20
-rwxr-xr-xikiwiki35
7 files changed, 121 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 3a39c957c..a9e177a27 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
all:
- ./ikiwiki doc html --wikiname="ikiwiki" --verbose --offline
+ ./ikiwiki doc html --wikiname="ikiwiki" --verbose --nosvn
clean:
rm -rf html
diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn
index 53c82a00c..b1332fae5 100644
--- a/doc/bugs.mdwn
+++ b/doc/bugs.mdwn
@@ -8,3 +8,5 @@
show as just Baz there.
* If I try to do a web commit, to a svn+ssh repo, it fails with
"Host key verification failed."
+ I think that the setuid isn't fully taking; it should be running as me,
+ but commit log shows www-data. So maybe it has the wrong username?
diff --git a/doc/index.mdwn b/doc/index.mdwn
index 92d3c9357..984d2c9b9 100644
--- a/doc/index.mdwn
+++ b/doc/index.mdwn
@@ -32,6 +32,8 @@ unchanged by ikiwiki as it builds your wiki. So you can check in an image,
program, or other special file and link to it from your wiki pages.
ikiwiki also supports making one page that is a [[SubPage]] of another.
+[[Setup]] has a tutorial for setting up ikiwki.
+
[[TODO]] lists things that need to be added to ikiwiki before most people
would consider it a full-fledged wiki.
diff --git a/doc/post-commit.mdwn b/doc/post-commit.mdwn
index 6e768ce24..8dff290fd 100644
--- a/doc/post-commit.mdwn
+++ b/doc/post-commit.mdwn
@@ -1,23 +1,23 @@
The best way to run ikiwiki in a [[Subversion]] post-commit hook is using
-a wrapper, which can be generated using `ikiwiki --gen-wrapper`.
+a wrapper, which can be generated using `ikiwiki --wrapper`.
First, set up the subversion checkout that ikiwiki will update and compile
into your wiki at each subversion commit. Run ikiwiki a few times by hand
-to get a feel for it. Now, generate the wrapper by adding "--gen-wrapper"
+to get a feel for it. Now, generate the wrapper by adding "--wrapper"
to whatever command line you've been using to run ikiwiki. For example:
~/wiki-checkout> ikiwiki . ~/public_html/wiki
- ~/wiki-checkout> ikiwiki . ~/public_html/wiki --gen-wrapper
+ ~/wiki-checkout> ikiwiki . ~/public_html/wiki --wrapper
successfully generated ikiwiki-wrap
The generated wrapper is a C program that is designed to safely be made
suid if necessary. It's hardcoded to run ikiwiki with the settings
-specified when you ran --gen-wrapper, and can only be used to update and
+specified when you ran --wrapper, and can only be used to update and
compile that one checkout into the specified html directory.
Now, put the wrapper somewhere convenient, and create a post-commit hook
script in your subversion repository for the wiki. All the post-commit
-hook has to do is run ikiwiki-wrap (with no parameters).
+hook has to do is run the wrapper (with no parameters).
Depending on your Subversion setup, the post-commit hook might end up
getting called by users who have write access to subversion, but not to
diff --git a/doc/setup.mdwn b/doc/setup.mdwn
new file mode 100644
index 000000000..a4632dba1
--- /dev/null
+++ b/doc/setup.mdwn
@@ -0,0 +1,68 @@
+So you want to set up your own wiki using ikiwiki? This turorial will walk
+you through setting up a wiki that is stored in [[Subversion]] and that has
+optional support for commits from the web.
+
+1. [[Install]] ikiwiki.
+
+ apt-get install ikiwiki
+
+2. Create the subversion repository for your wiki.
+
+ svnadmin create /svn/wikirepo
+ svn mkdir file:///svn/wikirepo/trunk -m create
+
+3. Check out the repository to make the working copy that ikiwiki will use.
+
+ svn co file:///svn/wikirepo/trunk ~/wikiwc
+
+4. Create some files them into subversion.
+
+ echo "Welcome to my empty wiki." > ~/wikiwc/index.mdwn
+ echo "Feel free to edit this page" > ~/wikiwc/sandbox.mdwn
+ svn add ~/wikiwc/*.mdwn
+ svn commit ~/wikiwc -m add
+
+5. Build your wiki for the first time.
+
+ ikiwiki --verbose ~/wikiwc/ ~/public_html/wiki/ \
+ --url=http://host/~you/wiki/
+
+ Replace the url with the right url to your wiki. You should now
+ be able to visit the url and see your page that you created earlier.
+
+6. Repeat steps 4 and 5 as desired, editing or adding pages and rebuilding
+ the wiki. You can play around with other ikiwiki parameters such as
+ --wikiname too. Get conformatble with its command line.
+
+7. Set up a Subversion [[post-commit]] hook to automatically rebuild your
+ wiki when you commit to it.
+
+ ikiwiki ~/wikiwc/ ~/public_html/wiki/ \
+ --url=http://host/~you/wiki/ --wrapper
+ mv ikiwiki-wrap /svn/wikirepo/hooks/post-commit
+
+8. Set up a [[CGI]] to allow editing the wiki from the web.
+
+ ikiwiki ~/wikiwc/ ~/public_html/wiki/ \
+ --url=http://host/~you/wiki/ --wrapper --cgi
+ chmod 6755 ikiwiki-wrap
+ mv wrapper ~/public_html/wiki/ikiwki.cgi
+
+ Note that this assumes that your web server will run CGI scripts from
+ your public_html directory. You might need to put it somewhere else
+ depending on your web server configuration.
+
+9. Add links to the CGI to all the pages in your wiki, and update your
+ post-commit hook to add such links when updating the wiki in the
+ future. Note the use of the [[WrapperParamsTrick]].
+
+ ikiwiki $(/svn/wikirepo/hooks/post-commit --params) --rebuild
+ ikiwiki $(/svn/wikirepo/hooks/post-commit --params) \
+ --cgiurl=http://host/~you/wiki/ikiwiki.cgi \
+ --wrapper
+ mv ikiwiki-wrap /svn/wikirepo/hooks/post-commit
+
+ Be sure to change the cgiurl to the actual url to the wiki.cgi you
+ installed in step 9.
+
+10. Enjoy your new wiki!
diff --git a/doc/wrapperparamstrick.mdwn b/doc/wrapperparamstrick.mdwn
new file mode 100644
index 000000000..d55629a79
--- /dev/null
+++ b/doc/wrapperparamstrick.mdwn
@@ -0,0 +1,20 @@
+ikiwiki --wrapper can be used to generate a wrapper
+program that runs ikiwiki with the specified parameters. This is used for
+[[post-commit]] hooks, [[CGI]], etc, both for convenience and because these
+things often need suid wrapper scripts to make ikiwiki run as the right
+user.
+
+The generated wrapper is a binary program. What if you want to regenerate
+it with different parameters, or just run ikiwiki like it would but with
+some parameter changed? To easily accomomplish this, the wrappers all
+support being run with --params, which causes them to print out the
+parameters they run ikiwiki with.
+
+You can use this trick to regenerate a wrapper, adding or changing a
+parameter:
+
+ ikiwiki $(./ikiwiki-wrap --params) --wikiname="newname" --wrapper
+
+Or just to run ikiwiki like the wrapper would, and add a parameter:
+
+ ikiwiki $(./ikiwiki-wrap --params) --rebuild
diff --git a/ikiwiki b/ikiwiki
index 044fde11b..fcf081ccb 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -497,13 +497,19 @@ sub gen_wrapper ($$) {
if (! -x $this) {
error("$this doesn't seem to be executable");
}
-
- my $call=qq{"$this", "$this", "$srcdir", "$destdir", "--wikiname=$wikiname"};
- $call.=', "--verbose"' if $verbose;
- $call.=', "--rebuild"' if $rebuild;
- $call.=', "--nosvn"' if !$svn;
- $call.=', "--cgi"' if $cgi;
- $call.=', "--url='.$url.'"' if $url;
+
+ my @params=($srcdir, $destdir, "--wikiname=$wikiname");
+ push @params, "--verbose" if $verbose;
+ push @params, "--rebuild" if $rebuild;
+ push @params, "--nosvn" if !$svn;
+ push @params, "--cgi" if $cgi;
+ push @params, "--url=$url" if $url;
+ my $params=join(" ", @params);
+ my $call='';
+ foreach my $p ($this, $this, @params) {
+ $call.=qq{"$p", };
+ }
+ $call.="NULL";
my @envsave;
push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
@@ -511,8 +517,8 @@ sub gen_wrapper ($$) {
my $envsave="";
foreach my $var (@envsave) {
$envsave.=<<"EOF"
- if ((s=getenv("$var")))
- asprintf(&newenviron[i++], "%s=%s", "$var", s);
+ if ((s=getenv("$var")))
+ asprintf(&newenviron[i++], "%s=%s", "$var", s);
EOF
}
@@ -527,17 +533,22 @@ EOF
extern char **environ;
-int main (void) {
+int main (int argc, char **argv) {
/* Sanitize environment. */
char *s;
char *newenviron[$#envsave+3];
int i=0;
- $envsave;
+$envsave
newenviron[i++]="HOME=$ENV{HOME}";
newenviron[i]=NULL;
environ=newenviron;
- execl($call, NULL);
+ if (argc == 2 && strcmp(argv[1], "--params") == 0) {
+ printf("$params\\n");
+ exit(0);
+ }
+
+ execl($call);
perror("failed to run $this");
exit(1);
}