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