summaryrefslogtreecommitdiff
path: root/ikiwiki
blob: 4801c5f92e734df7bf7f9c170519c59b31875c77 (plain)
  1. #!/usr/bin/perl -T
  2. $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
  3. package IkiWiki;
  4. use warnings;
  5. use strict;
  6. use lib '.'; # For use without installation, removed by Makefile.
  7. use IkiWiki;
  8. sub usage () { #{{{
  9. die "usage: ikiwiki [options] source dest\n";
  10. } #}}}
  11. sub getconfig () { #{{{
  12. if (! exists $ENV{WRAPPED_OPTIONS}) {
  13. %config=defaultconfig();
  14. eval q{use Getopt::Long};
  15. GetOptions(
  16. "setup|s=s" => \$config{setup},
  17. "wikiname=s" => \$config{wikiname},
  18. "verbose|v!" => \$config{verbose},
  19. "rebuild!" => \$config{rebuild},
  20. "refresh!" => \$config{refresh},
  21. "getctime" => \$config{getctime},
  22. "wrappermode=i" => \$config{wrappermode},
  23. "rcs=s" => \$config{rcs},
  24. "no-rcs" => sub { $config{rcs}="" },
  25. "anonok!" => \$config{anonok},
  26. "rss!" => \$config{rss},
  27. "cgi!" => \$config{cgi},
  28. "notify!" => \$config{notify},
  29. "sanitize!" => \$config{sanitize},
  30. "url=s" => \$config{url},
  31. "cgiurl=s" => \$config{cgiurl},
  32. "historyurl=s" => \$config{historyurl},
  33. "diffurl=s" => \$config{diffurl},
  34. "svnrepo" => \$config{svnrepo},
  35. "svnpath" => \$config{svnpath},
  36. "adminemail=s" => \$config{adminemail},
  37. "exclude=s@" => sub {
  38. $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
  39. },
  40. "adminuser=s@" => sub {
  41. push @{$config{adminuser}}, $_[1]
  42. },
  43. "templatedir=s" => sub {
  44. $config{templatedir}=possibly_foolish_untaint($_[1])
  45. },
  46. "underlaydir=s" => sub {
  47. $config{underlaydir}=possibly_foolish_untaint($_[1])
  48. },
  49. "wrapper:s" => sub {
  50. $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
  51. },
  52. "plugin=s@" => sub {
  53. push @{$config{plugin}}, $_[1];
  54. }
  55. ) || usage();
  56. if (! $config{setup}) {
  57. usage() unless @ARGV == 2;
  58. $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
  59. $config{destdir} = possibly_foolish_untaint(shift @ARGV);
  60. checkconfig();
  61. }
  62. }
  63. else {
  64. # wrapper passes a full config structure in the environment
  65. # variable
  66. eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
  67. if ($@) {
  68. error("WRAPPED_OPTIONS: $@");
  69. }
  70. checkconfig();
  71. }
  72. } #}}}
  73. sub main () { #{{{
  74. getconfig();
  75. if ($config{cgi}) {
  76. lockwiki();
  77. loadindex();
  78. require IkiWiki::CGI;
  79. cgi();
  80. }
  81. elsif ($config{setup}) {
  82. require IkiWiki::Setup;
  83. setup();
  84. }
  85. elsif ($config{wrapper}) {
  86. lockwiki();
  87. require IkiWiki::Wrapper;
  88. gen_wrapper();
  89. }
  90. else {
  91. lockwiki();
  92. loadindex();
  93. require IkiWiki::Render;
  94. rcs_update();
  95. rcs_getctime() if $config{getctime};
  96. refresh();
  97. rcs_notify() if $config{notify};
  98. saveindex();
  99. }
  100. } #}}}
  101. main;