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');
22 "setup|s=s" => \$config{setup},
23 "dumpsetup|s=s" => \$config{dumpsetup},
24 "wikiname=s" => \$config{wikiname},
25 "verbose|v!" => \$config{verbose},
26 "syslog!" => \$config{syslog},
27 "rebuild!" => \$config{rebuild},
28 "refresh!" => \$config{refresh},
29 "post-commit" => \$config{post_commit},
30 "render=s" => \$config{render},
31 "wrappers!" => \$config{genwrappers},
32 "usedirs!" => \$config{usedirs},
33 "prefix-directives!" => \$config{prefix_directives},
34 "getctime" => \$config{getctime},
35 "numbacklinks=i" => \$config{numbacklinks},
36 "rcs=s" => \$config{rcs},
37 "no-rcs" => sub { $config{rcs}="" },
38 "cgi!" => \$config{cgi},
39 "discussion!" => \$config{discussion},
40 "w3mmode!" => \$config{w3mmode},
41 "url=s" => \$config{url},
42 "cgiurl=s" => \$config{cgiurl},
43 "historyurl=s" => \$config{historyurl},
44 "diffurl=s" => \$config{diffurl},
45 "svnpath" => \$config{svnpath},
46 "adminemail=s" => \$config{adminemail},
47 "timeformat=s" => \$config{timeformat},
48 "sslcookie!" => \$config{sslcookie},
49 "userdir=s" => \$config{userdir},
50 "htmlext=s" => \$config{htmlext},
51 "libdir=s" => \$config{libdir},
53 push @{$config{wiki_file_prune_regexps}}, $_[1];
55 "adminuser=s@" => sub {
56 push @{$config{adminuser}}, $_[1]
58 "templatedir=s" => sub {
59 $config{templatedir}=possibly_foolish_untaint($_[1])
61 "underlaydir=s" => sub {
62 $config{underlaydir}=possibly_foolish_untaint($_[1])
65 $config{wrapper}=$_[1] ? possibly_foolish_untaint($_[1]) : "ikiwiki-wrap"
67 "wrappermode=i" => sub {
68 $config{wrappermode}=possibly_foolish_untaint($_[1])
71 push @{$config{add_plugins}}, $_[1];
73 "disable-plugin=s@" => sub {
74 push @{$config{disable_plugins}}, $_[1];
77 my ($var, $val)=split('=', $_[1], 2);
78 if (! defined $var || ! defined $val) {
79 die gettext("usage: --set var=value"), "\n";
84 print "ikiwiki version $IkiWiki::version\n";
89 if (! $config{setup} && ! $config{render}) {
91 usage() unless @ARGV == 2;
92 $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
93 $config{destdir} = possibly_foolish_untaint(shift @ARGV);
98 # wrapper passes a full config structure in the environment
100 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
102 error("WRAPPED_OPTIONS: $@");
112 if ($config{setup}) {
113 require IkiWiki::Setup;
114 IkiWiki::Setup::load($config{setup});
115 if (@{$config{wrappers}} &&
116 ! $config{render} && ! $config{dumpsetup} &&
117 (! $config{refresh} || $config{genwrappers})) {
118 debug(gettext("generating wrappers.."));
119 require IkiWiki::Wrapper;
120 my %origconfig=(%config);
121 my @wrappers=@{$config{wrappers}};
122 delete $config{wrappers};
123 delete $config{genwrappers};
124 foreach my $wrapper (@wrappers) {
125 %config=(%origconfig,
131 if (! $config{cgi} && ! $config{post_commit}) {
132 $config{post_commit}=1;
136 %config=(%origconfig);
139 # setup implies a wiki rebuild by default
140 if (! $config{refresh}) {
144 # ignore syslog setting from setup file
145 # while doing initial setup
146 $config{syslog}=0 unless $config{dumpsetup};
152 if ($config{dumpsetup}) {
153 require IkiWiki::Setup;
154 IkiWiki::Setup::dump($config{dumpsetup});
156 elsif ($config{wrapper}) {
158 require IkiWiki::Wrapper;
161 elsif ($config{cgi}) {
162 require IkiWiki::CGI;
168 elsif ($config{render}) {
169 require IkiWiki::Render;
170 commandline_render();
172 elsif ($config{post_commit} && ! commit_hook_enabled()) {
176 if (! $config{refresh}) {
177 debug(gettext("rebuilding wiki.."));
180 debug(gettext("refreshing wiki.."));
184 require IkiWiki::Render;
188 debug(gettext("done"));