2 $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
3 delete @ENV{qw{IFS CDPATH ENV BASH_ENV}};
9 use lib '.'; # For use in nonstandard directory, munged by Makefile.
13 die gettext("usage: ikiwiki [options] source dest"), "\n";
16 sub getconfig () { #{{{
17 if (! exists $ENV{WRAPPED_OPTIONS}) {
18 %config=defaultconfig();
19 eval q{use Getopt::Long};
20 Getopt::Long::Configure('pass_through');
23 require IkiWiki::Setup;
24 IkiWiki::Setup::load($_[1]);
27 "dumpsetup|s=s" => \$config{dumpsetup},
28 "wikiname=s" => \$config{wikiname},
29 "verbose|v!" => \$config{verbose},
30 "syslog!" => \$config{syslog},
31 "rebuild!" => \$config{rebuild},
32 "refresh!" => \$config{refresh},
33 "post-commit" => \$config{post_commit},
34 "render=s" => \$config{render},
35 "wrappers!" => \$config{genwrappers},
36 "usedirs!" => \$config{usedirs},
37 "prefix-directives!" => \$config{prefix_directives},
38 "getctime" => \$config{getctime},
39 "numbacklinks=i" => \$config{numbacklinks},
40 "rcs=s" => \$config{rcs},
41 "no-rcs" => sub { $config{rcs}="" },
42 "cgi!" => \$config{cgi},
43 "discussion!" => \$config{discussion},
44 "w3mmode!" => \$config{w3mmode},
45 "url=s" => \$config{url},
46 "cgiurl=s" => \$config{cgiurl},
47 "historyurl=s" => \$config{historyurl},
48 "diffurl=s" => \$config{diffurl},
49 "svnpath" => \$config{svnpath},
50 "adminemail=s" => \$config{adminemail},
51 "timeformat=s" => \$config{timeformat},
52 "sslcookie!" => \$config{sslcookie},
53 "userdir=s" => \$config{userdir},
54 "htmlext=s" => \$config{htmlext},
55 "libdir=s" => \$config{libdir},
57 push @{$config{wiki_file_prune_regexps}}, $_[1];
59 "adminuser=s@" => sub {
60 push @{$config{adminuser}}, $_[1]
62 "templatedir=s" => sub {
63 $config{templatedir}=possibly_foolish_untaint($_[1])
65 "underlaydir=s" => sub {
66 $config{underlaydir}=possibly_foolish_untaint($_[1])
69 $config{wrapper}=$_[1] ? possibly_foolish_untaint($_[1]) : "ikiwiki-wrap"
71 "wrappermode=i" => sub {
72 $config{wrappermode}=possibly_foolish_untaint($_[1])
75 push @{$config{add_plugins}}, $_[1];
77 "disable-plugin=s@" => sub {
78 push @{$config{disable_plugins}}, $_[1];
81 my ($var, $val)=split('=', $_[1], 2);
82 if (! defined $var || ! defined $val) {
83 die gettext("usage: --set var=value"), "\n";
88 print "ikiwiki version $IkiWiki::version\n";
93 if (! $config{setup} && ! $config{render}) {
96 $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
97 $config{destdir} = possibly_foolish_untaint(shift @ARGV);
101 usage() unless $config{dumpsetup};
106 # wrapper passes a full config structure in the environment
108 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
110 error("WRAPPED_OPTIONS: $@");
112 delete $ENV{WRAPPED_OPTIONS};
121 if ($config{setup}) {
122 delete $config{setup};
126 if (@{$config{wrappers}} &&
127 ! $config{render} && ! $config{dumpsetup} &&
128 (! $config{refresh} || $config{genwrappers})) {
129 debug(gettext("generating wrappers.."));
130 require IkiWiki::Wrapper;
131 my %origconfig=(%config);
132 my @wrappers=@{$config{wrappers}};
133 delete $config{wrappers};
134 delete $config{genwrappers};
135 foreach my $wrapper (@wrappers) {
136 %config=(%origconfig,
142 if (! $config{cgi} && ! $config{post_commit}) {
143 $config{post_commit}=1;
147 %config=(%origconfig);
150 # setup implies a wiki rebuild by default
151 if (! $config{refresh}) {
156 if ($config{dumpsetup}) {
157 require IkiWiki::Setup;
158 IkiWiki::Setup::dump($config{dumpsetup});
160 elsif ($config{wrapper}) {
162 require IkiWiki::Wrapper;
165 elsif ($config{cgi}) {
166 require IkiWiki::CGI;
172 elsif ($config{render}) {
173 require IkiWiki::Render;
174 commandline_render();
176 elsif ($config{post_commit} && ! commit_hook_enabled()) {
180 if (! $config{refresh}) {
181 debug(gettext("rebuilding wiki.."));
184 debug(gettext("refreshing wiki.."));
188 require IkiWiki::Render;
192 debug(gettext("done"));