<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -T
$ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
delete @ENV{qw{IFS CDPATH ENV BASH_ENV}};

package IkiWiki;
use warnings;
use strict;
use lib '.'; # For use without installation, removed by Makefile.
use IkiWiki;

sub usage () { #{{{
	die "usage: ikiwiki [options] source dest\n";
} #}}}

sub getconfig () { #{{{
	if (! exists $ENV{WRAPPED_OPTIONS}) {
		%config=defaultconfig();
		eval q{use Getopt::Long};
		Getopt::Long::Configure('pass_through');
		GetOptions(
			"setup|s=s" =&gt; \$config{setup},
			"wikiname=s" =&gt; \$config{wikiname},
			"verbose|v!" =&gt; \$config{verbose},
			"rebuild!" =&gt; \$config{rebuild},
			"refresh!" =&gt; \$config{refresh},
			"wrappers!" =&gt; \$config{wrappers},
			"getctime" =&gt; \$config{getctime},
			"wrappermode=i" =&gt; \$config{wrappermode},
			"rcs=s" =&gt; \$config{rcs},
			"no-rcs" =&gt; sub { $config{rcs}="" },
			"anonok!" =&gt; \$config{anonok},
			"rss!" =&gt; \$config{rss},
			"cgi!" =&gt; \$config{cgi},
			"discussion!" =&gt; \$config{discussion},
			"w3mmode!" =&gt; \$config{w3mmode},
			"notify!" =&gt; \$config{notify},
			"url=s" =&gt; \$config{url},
			"cgiurl=s" =&gt; \$config{cgiurl},
			"historyurl=s" =&gt; \$config{historyurl},
			"diffurl=s" =&gt; \$config{diffurl},
			"svnrepo" =&gt; \$config{svnrepo},
			"svnpath" =&gt; \$config{svnpath},
			"adminemail=s" =&gt; \$config{adminemail},
			"timeformat=s" =&gt; \$config{timeformat},
			"exclude=s@" =&gt; sub {
				$config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
			},
			"adminuser=s@" =&gt; sub {
				push @{$config{adminuser}}, $_[1]
			},
			"templatedir=s" =&gt; sub {
				$config{templatedir}=possibly_foolish_untaint($_[1])
			},
			"underlaydir=s" =&gt; sub {
				$config{underlaydir}=possibly_foolish_untaint($_[1])
			},
			"wrapper:s" =&gt; sub {
				$config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
			},
			"plugin=s@" =&gt; sub {
				push @{$config{plugin}}, $_[1];
			},
			"disable-plugin=s@" =&gt; sub {
				$config{plugin}=[grep { $_ ne $_[1] } @{$config{plugin}}];
			},
			"pingurl" =&gt; sub {
				push @{$config{pingurl}}, $_[1];
			}
		) || usage();

		if (! $config{setup}) {
			loadplugins();
			usage() unless @ARGV == 2;
			$config{srcdir} = possibly_foolish_untaint(shift @ARGV);
			$config{destdir} = possibly_foolish_untaint(shift @ARGV);
			checkconfig();
		}
	}
	else {
		# wrapper passes a full config structure in the environment
		# variable
		eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
		if ($@) {
			error("WRAPPED_OPTIONS: $@");
		}
		loadplugins();
		checkconfig();
	}
} #}}}

sub main () { #{{{
	getconfig();
	
	if ($config{cgi}) {
		lockwiki();
		loadindex();
		require IkiWiki::CGI;
		cgi();
	}
	elsif ($config{setup}) {
		require IkiWiki::Setup;
		setup();
	}
	elsif ($config{wrapper}) {
		lockwiki();
		require IkiWiki::Wrapper;
		gen_wrapper();
	}
	else {
		lockwiki();
		loadindex();
		require IkiWiki::Render;
		rcs_update();
		refresh();
		rcs_notify() if $config{notify};
		saveindex();
	}
} #}}}

main;
</pre></body></html>