2 $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
7 use lib '.'; # For use without installation, removed by Makefile.
11 die "usage: ikiwiki [options] source dest\n";
14 sub getconfig () { #{{{
15 if (! exists $ENV{WRAPPED_OPTIONS}) {
16 %config=defaultconfig();
17 eval q{use Getopt::Long};
18 Getopt::Long::Configure('pass_through');
20 "setup|s=s" => \$config{setup},
21 "wikiname=s" => \$config{wikiname},
22 "verbose|v!" => \$config{verbose},
23 "rebuild!" => \$config{rebuild},
24 "refresh!" => \$config{refresh},
25 "getctime" => \$config{getctime},
26 "wrappermode=i" => \$config{wrappermode},
27 "rcs=s" => \$config{rcs},
28 "no-rcs" => sub { $config{rcs}="" },
29 "anonok!" => \$config{anonok},
30 "rss!" => \$config{rss},
31 "cgi!" => \$config{cgi},
32 "discussion!" => \$config{discussion},
33 "w3mmode!" => \$config{w3mmode},
34 "notify!" => \$config{notify},
35 "url=s" => \$config{url},
36 "cgiurl=s" => \$config{cgiurl},
37 "historyurl=s" => \$config{historyurl},
38 "diffurl=s" => \$config{diffurl},
39 "svnrepo" => \$config{svnrepo},
40 "svnpath" => \$config{svnpath},
41 "adminemail=s" => \$config{adminemail},
42 "timeformat=s" => \$config{timeformat},
44 $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
46 "adminuser=s@" => sub {
47 push @{$config{adminuser}}, $_[1]
49 "templatedir=s" => sub {
50 $config{templatedir}=possibly_foolish_untaint($_[1])
52 "underlaydir=s" => sub {
53 $config{underlaydir}=possibly_foolish_untaint($_[1])
56 $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
59 push @{$config{plugin}}, $_[1];
61 "disable-plugin=s@" => sub {
62 $config{plugin}=[grep { $_ ne $_[1] } @{$config{plugin}}];
65 push @{$config{pingurl}}, $_[1];
69 if (! $config{setup}) {
71 if (exists $hooks{getopt}) {
72 foreach my $id (keys %{$hooks{getopt}}) {
73 $hooks{getopt}{$id}{call}->();
76 if (grep /^-/, @ARGV) {
77 print STDERR "Unknown option: $_\n"
78 foreach grep /^-/, @ARGV;
81 usage() unless @ARGV == 2;
82 $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
83 $config{destdir} = possibly_foolish_untaint(shift @ARGV);
88 # wrapper passes a full config structure in the environment
90 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
92 error("WRAPPED_OPTIONS: $@");
105 require IkiWiki::CGI;
108 elsif ($config{setup}) {
109 require IkiWiki::Setup;
112 elsif ($config{wrapper}) {
114 require IkiWiki::Wrapper;
120 require IkiWiki::Render;
123 rcs_notify() if $config{notify};