]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - ikiwiki.pl
* Fix a bug in the aggregator introduced last version that caused all
[git.ikiwiki.info.git] / ikiwiki.pl
1 #!/usr/bin/perl -T
2 $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
3 delete @ENV{qw{IFS CDPATH ENV BASH_ENV}};
5 package IkiWiki;
6 our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
8 use warnings;
9 use strict;
10 use lib '.'; # For use without installation, removed by Makefile.
11 use IkiWiki;
13 sub usage () { #{{{
14         die "usage: ikiwiki [options] source dest\n";
15 } #}}}
17 sub getconfig () { #{{{
18         if (! exists $ENV{WRAPPED_OPTIONS}) {
19                 %config=defaultconfig();
20                 eval q{use Getopt::Long};
21                 Getopt::Long::Configure('pass_through');
22                 GetOptions(
23                         "setup|s=s" => \$config{setup},
24                         "wikiname=s" => \$config{wikiname},
25                         "verbose|v!" => \$config{verbose},
26                         "syslog!" => \$config{syslog},
27                         "rebuild!" => \$config{rebuild},
28                         "refresh!" => \$config{refresh},
29                         "wrappers!" => \$config{wrappers},
30                         "getctime" => \$config{getctime},
31                         "wrappermode=i" => \$config{wrappermode},
32                         "rcs=s" => \$config{rcs},
33                         "no-rcs" => sub { $config{rcs}="" },
34                         "anonok!" => \$config{anonok},
35                         "rss!" => \$config{rss},
36                         "cgi!" => \$config{cgi},
37                         "discussion!" => \$config{discussion},
38                         "w3mmode!" => \$config{w3mmode},
39                         "notify!" => \$config{notify},
40                         "url=s" => \$config{url},
41                         "cgiurl=s" => \$config{cgiurl},
42                         "historyurl=s" => \$config{historyurl},
43                         "diffurl=s" => \$config{diffurl},
44                         "svnrepo" => \$config{svnrepo},
45                         "svnpath" => \$config{svnpath},
46                         "adminemail=s" => \$config{adminemail},
47                         "timeformat=s" => \$config{timeformat},
48                         "exclude=s@" => sub {
49                                 $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
50                         },
51                         "adminuser=s@" => sub {
52                                 push @{$config{adminuser}}, $_[1]
53                         },
54                         "templatedir=s" => sub {
55                                 $config{templatedir}=possibly_foolish_untaint($_[1])
56                         },
57                         "underlaydir=s" => sub {
58                                 $config{underlaydir}=possibly_foolish_untaint($_[1])
59                         },
60                         "wrapper:s" => sub {
61                                 $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
62                         },
63                         "plugin=s@" => sub {
64                                 push @{$config{plugin}}, $_[1];
65                         },
66                         "disable-plugin=s@" => sub {
67                                 $config{plugin}=[grep { $_ ne $_[1] } @{$config{plugin}}];
68                         },
69                         "pingurl" => sub {
70                                 push @{$config{pingurl}}, $_[1];
71                         },
72                         "version" => sub {
73                                 print "ikiwiki version $version\n";
74                                 exit;
75                         },
76                 ) || usage();
78                 if (! $config{setup}) {
79                         loadplugins();
80                         usage() unless @ARGV == 2;
81                         $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
82                         $config{destdir} = possibly_foolish_untaint(shift @ARGV);
83                         checkconfig();
84                 }
85         }
86         else {
87                 # wrapper passes a full config structure in the environment
88                 # variable
89                 eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
90                 if ($@) {
91                         error("WRAPPED_OPTIONS: $@");
92                 }
93                 loadplugins();
94                 checkconfig();
95         }
96 } #}}}
98 sub main () { #{{{
99         getconfig();
100         
101         if ($config{cgi}) {
102                 lockwiki();
103                 loadindex();
104                 require IkiWiki::CGI;
105                 cgi();
106         }
107         elsif ($config{setup}) {
108                 require IkiWiki::Setup;
109                 setup();
110         }
111         elsif ($config{wrapper}) {
112                 lockwiki();
113                 require IkiWiki::Wrapper;
114                 gen_wrapper();
115         }
116         else {
117                 lockwiki();
118                 loadindex();
119                 require IkiWiki::Render;
120                 rcs_update();
121                 refresh();
122                 rcs_notify() if $config{notify};
123                 saveindex();
124         }
125 } #}}}
127 main;