6 use lib
'.'; # For use in nonstandard directory, munged by Makefile.
10 die gettext
("usage: ikiwiki [options] source dest"), "\n",
11 gettext
(" ikiwiki --setup configfile"), "\n";
15 require IkiWiki
::Setup
;
16 my $verbose=$config{verbose
};
17 my $syslog=$config{syslog
};
18 IkiWiki
::Setup
::load
($_[1]);
19 $config{setupverbose
}=$config{verbose
};
20 $config{setupsyslog
}=$config{syslog
};
21 $config{verbose
}=$verbose || $config{setupverbose
};
22 $config{syslog
}=$syslog;
27 if (! exists $ENV{WRAPPED_OPTIONS
}) {
28 %config=defaultconfig
();
29 eval q{use Getopt::Long};
30 Getopt
::Long
::Configure
('pass_through');
32 "setup|s=s" => \
&setup
,
33 "dumpsetup|s=s" => \
$config{dumpsetup
},
34 "changesetup|s=s" => sub {
35 $config{changesetup
}=$_[1];
36 $config{genwrappers
}=1;
40 "wikiname=s" => \
$config{wikiname
},
41 "verbose|v!" => \
$config{verbose
},
42 "syslog!" => \
$config{syslog
},
43 "rebuild!" => \
$config{rebuild
},
44 "refresh!" => \
$config{refresh
},
45 "clean!" => \
$config{clean
},
46 "post-commit" => \
$config{post_commit
},
47 "render=s" => \
$config{render
},
48 "wrappers!" => \
$config{genwrappers
},
49 "wrappergroup=s" => \
$config{wrappergroup
},
50 "usedirs!" => \
$config{usedirs
},
51 "prefix-directives!" => \
$config{prefix_directives
},
52 "getctime" => \
$config{gettime
},
53 "gettime!" => \
$config{gettime
},
54 "numbacklinks=i" => \
$config{numbacklinks
},
55 "rcs=s" => \
$config{rcs
},
56 "no-rcs" => sub { $config{rcs
}="" },
57 "cgi!" => \
$config{cgi
},
58 "discussion!" => \
$config{discussion
},
59 "w3mmode!" => \
$config{w3mmode
},
60 "url=s" => \
$config{url
},
61 "cgiurl=s" => \
$config{cgiurl
},
62 "historyurl=s" => \
$config{historyurl
},
63 "diffurl=s" => \
$config{diffurl
},
64 "svnpath" => \
$config{svnpath
},
65 "adminemail=s" => \
$config{adminemail
},
66 "timeformat=s" => \
$config{timeformat
},
67 "sslcookie!" => \
$config{sslcookie
},
68 "userdir=s" => \
$config{userdir
},
69 "htmlext=s" => \
$config{htmlext
},
70 "libdir=s" => \
$config{libdir
},
72 push @
{$config{wiki_file_prune_regexps
}}, $_[1];
75 $config{include
}=defined $config{include
} && length $config{include
} ?
"$config{include}|$_[1]" : $_[1];
77 "adminuser=s@" => sub {
78 push @
{$config{adminuser
}}, $_[1]
80 "templatedir=s" => sub {
81 $config{templatedir
}=possibly_foolish_untaint
($_[1])
83 "underlaydir=s" => sub {
84 $config{underlaydir
}=possibly_foolish_untaint
($_[1])
87 $config{wrapper
}=$_[1] ? possibly_foolish_untaint
($_[1]) : "ikiwiki-wrap"
89 "wrappermode=i" => sub {
90 $config{wrappermode
}=possibly_foolish_untaint
($_[1])
93 push @
{$config{add_plugins
}}, $_[1]
94 unless grep { $_ eq $_[1] } @
{$config{add_plugins
}};
96 "disable-plugin=s@" => sub {
97 push @
{$config{disable_plugins
}}, $_[1];
100 my ($var, $val)=split('=', $_[1], 2);
101 if (! defined $var || ! defined $val) {
102 die gettext
("usage: --set var=value"), "\n";
106 "set-yaml=s" => sub {
107 my ($var, $val)=split('=', $_[1], 2);
108 if (! defined $var || ! defined $val) {
109 die gettext
("usage: --set-yaml var=value"), "\n";
111 eval q{use YAML::Any};
112 eval q{use YAML} if $@
;
114 eval q{$YAML::Syck::ImplicitUnicode=1};
115 $config{$var}=Load($val."\n");
118 print "ikiwiki version $IkiWiki::version\n";
121 "help|h" => sub { $SIG{__WARN__}=sub {}; die },
124 if (! $config{setup}) {
127 $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
128 $config{destdir} = possibly_foolish_untaint(shift @ARGV);
132 usage() unless $config{dumpsetup};
137 # wrapper passes a full config structure in the environment
139 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
141 error("WRAPPED_OPTIONS: $@");
143 delete $ENV{WRAPPED_OPTIONS};
153 if ($config{setup}) {
154 delete $config{setup};
158 if (@{$config{wrappers}} &&
159 ! $config{render} && ! $config{dumpsetup} &&
161 ((! $config{refresh} && ! $config{post_commit})
162 || $config{genwrappers})) {
163 require IkiWiki::Wrapper;
167 # setup implies a wiki rebuild by default
168 if (! $config{refresh} && ! $config{render} &&
169 ! $config{post_commit} && ! $config{clean}) {
174 if ($config{changesetup}) {
175 require IkiWiki::Setup;
176 IkiWiki::Setup::dump($config{changesetup});
179 if ($config{dumpsetup}) {
180 $config{srcdir}="" if ! defined $config{srcdir};
181 $config{destdir}="" if ! defined $config{destdir};
182 $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"));