7 use FindBin; use lib $FindBin::Bin; # For use in nonstandard directory, munged by Makefile.
11 die gettext("usage: ikiwiki [options] source dest"), "\n",
12 gettext(" ikiwiki --setup my.setup [options]"), "\n";
16 require IkiWiki::Setup;
17 my $verbose=$config{verbose};
18 my $syslog=$config{syslog};
19 IkiWiki::Setup::load($_[1]);
20 $config{setupverbose}=$config{verbose};
21 $config{setupsyslog}=$config{syslog};
22 $config{verbose}=$verbose || $config{setupverbose};
23 $config{syslog}=$syslog;
28 if (! exists $ENV{WRAPPED_OPTIONS}) {
29 %config=defaultconfig();
30 eval q{use Getopt::Long};
31 Getopt::Long::Configure('pass_through');
33 "setup|s=s" => \&setup,
34 "dumpsetup|s=s" => \$config{dumpsetup},
35 "changesetup|s=s" => sub {
36 $config{changesetup}=$_[1];
37 $config{genwrappers}=1;
41 "wikiname=s" => \$config{wikiname},
42 "verbose|v!" => \$config{verbose},
43 "syslog!" => \$config{syslog},
44 "rebuild!" => \$config{rebuild},
45 "refresh!" => \$config{refresh},
46 "clean!" => \$config{clean},
47 "post-commit" => \$config{post_commit},
48 "render=s" => \$config{render},
49 "wrappers!" => \$config{genwrappers},
50 "wrappergroup=s" => \$config{wrappergroup},
51 "usedirs!" => \$config{usedirs},
52 "prefix-directives!" => \$config{prefix_directives},
53 "getctime" => \$config{gettime},
54 "gettime!" => \$config{gettime},
55 "numbacklinks=i" => \$config{numbacklinks},
56 "rcs=s" => \$config{rcs},
57 "no-rcs" => sub { $config{rcs}="" },
58 "cgi!" => \$config{cgi},
59 "discussion!" => \$config{discussion},
60 "w3mmode!" => \$config{w3mmode},
61 "url=s" => \$config{url},
62 "cgiurl=s" => \$config{cgiurl},
63 "historyurl=s" => \$config{historyurl},
64 "diffurl=s" => \$config{diffurl},
65 "svnpath" => \$config{svnpath},
66 "adminemail=s" => \$config{adminemail},
67 "timeformat=s" => \$config{timeformat},
68 "sslcookie!" => \$config{sslcookie},
69 "userdir=s" => \$config{userdir},
70 "htmlext=s" => \$config{htmlext},
71 "libdir=s" => \$config{libdir},
73 push @{$config{wiki_file_prune_regexps}}, $_[1];
76 $config{include}=defined $config{include} && length $config{include} ? "$config{include}|$_[1]" : $_[1];
78 "adminuser=s@" => sub {
79 push @{$config{adminuser}}, $_[1]
81 "templatedir=s" => sub {
82 $config{templatedir}=possibly_foolish_untaint($_[1])
84 "underlaydir=s" => sub {
85 $config{underlaydir}=possibly_foolish_untaint($_[1])
88 $config{wrapper}=$_[1] ? possibly_foolish_untaint($_[1]) : "ikiwiki-wrap"
90 "wrappermode=i" => sub {
91 $config{wrappermode}=possibly_foolish_untaint($_[1])
94 push @{$config{add_plugins}}, $_[1]
95 unless grep { $_ eq $_[1] } @{$config{add_plugins}};
97 "disable-plugin=s@" => sub {
98 push @{$config{disable_plugins}}, $_[1];
101 my ($var, $val)=split('=', $_[1], 2);
102 if (! defined $var || ! defined $val) {
103 die gettext("usage: --set var=value"), "\n";
107 "set-yaml=s" => sub {
108 my ($var, $val)=split('=', $_[1], 2);
109 if (! defined $var || ! defined $val) {
110 die gettext("usage: --set-yaml var=value"), "\n";
112 eval q{use YAML::XS; use Encode};
114 $config{$var}=Load(encode_utf8($val)."\n");
117 print "ikiwiki version $IkiWiki::version\n";
120 "help|h" => sub { $SIG{__WARN__}=sub {}; die },
123 if (! $config{setup}) {
126 $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
127 $config{destdir} = possibly_foolish_untaint(shift @ARGV);
131 usage() unless $config{dumpsetup};
136 # wrapper passes a full config structure in the environment
138 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
140 error("WRAPPED_OPTIONS: $@");
142 delete $ENV{WRAPPED_OPTIONS};
152 if ($config{setup}) {
153 delete $config{setup};
157 if (@{$config{wrappers}} &&
158 ! $config{render} && ! $config{dumpsetup} &&
160 ((! $config{refresh} && ! $config{post_commit})
161 || $config{genwrappers})) {
162 require IkiWiki::Wrapper;
166 # setup implies a wiki rebuild by default
167 if (! $config{refresh} && ! $config{render} &&
168 ! $config{post_commit} && ! $config{clean}) {
173 if ($config{changesetup}) {
174 require IkiWiki::Setup;
175 IkiWiki::Setup::dump($config{changesetup});
178 if ($config{dumpsetup}) {
179 $config{srcdir}="" if ! defined $config{srcdir};
180 $config{destdir}="" if ! defined $config{destdir};
181 $config{syslog}=1 if $config{setupsyslog};
183 require IkiWiki::Setup;
184 IkiWiki::Setup::dump($config{dumpsetup});
186 elsif ($config{wrapper}) {
188 require IkiWiki::Wrapper;
191 elsif ($config{cgi}) {
192 require IkiWiki::CGI;
198 elsif ($config{render}) {
199 require IkiWiki::Render;
200 commandline_render();
202 elsif ($config{post_commit} && ! commit_hook_enabled()) {
205 elsif ($config{clean}) {
206 require IkiWiki::Render;
207 foreach my $wrapper (@{$config{wrappers}}) {
208 prune($wrapper->{wrapper});
211 system("rm", "-rf", $config{wikistatedir});
214 if ($config{rebuild}) {
215 debug(gettext("rebuilding wiki.."));
218 debug(gettext("refreshing wiki.."));
222 require IkiWiki::Render;
226 debug(gettext("done"));