summaryrefslogtreecommitdiff
path: root/ikiwiki
blob: e911eaff4de483cb9e1ffe680828b13ab91f6d2d (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. "url=s" => \$config{url},
  30. "cgiurl=s" => \$config{cgiurl},
  31. "historyurl=s" => \$config{historyurl},
  32. "diffurl=s" => \$config{diffurl},
  33. "svnrepo" => \$config{svnrepo},
  34. "svnpath" => \$config{svnpath},
  35. "adminemail=s" => \$config{adminemail},
  36. "exclude=s@" => sub {
  37. $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
  38. },
  39. "adminuser=s@" => sub {
  40. push @{$config{adminuser}}, $_[1]
  41. },
  42. "templatedir=s" => sub {
  43. $config{templatedir}=possibly_foolish_untaint($_[1])
  44. },
  45. "underlaydir=s" => sub {
  46. $config{underlaydir}=possibly_foolish_untaint($_[1])
  47. },
  48. "wrapper:s" => sub {
  49. $config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
  50. },
  51. "plugin=s@" => sub {
  52. push @{$config{plugin}}, $_[1];
  53. },
  54. "disable-plugin=s@" => sub {
  55. $config{plugin}=[grep { $_ ne $_[1] } @{$config{plugin}} ];
  56. },
  57. ) || usage();
  58. if (! $config{setup}) {
  59. usage() unless @ARGV == 2;
  60. $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
  61. $config{destdir} = possibly_foolish_untaint(shift @ARGV);
  62. checkconfig();
  63. }
  64. }
  65. else {
  66. # wrapper passes a full config structure in the environment
  67. # variable
  68. eval possibly_foolish_untaint($ENV{WRAPPED_OPTIONS});
  69. if ($@) {
  70. error("WRAPPED_OPTIONS: $@");
  71. }
  72. checkconfig();
  73. }
  74. } #}}}
  75. sub main () { #{{{
  76. getconfig();
  77. if ($config{cgi}) {
  78. lockwiki();
  79. loadindex();
  80. require IkiWiki::CGI;
  81. cgi();
  82. }
  83. elsif ($config{setup}) {
  84. require IkiWiki::Setup;
  85. setup();
  86. }
  87. elsif ($config{wrapper}) {
  88. lockwiki();
  89. require IkiWiki::Wrapper;
  90. gen_wrapper();
  91. }
  92. else {
  93. lockwiki();
  94. loadindex();
  95. require IkiWiki::Render;
  96. rcs_update();
  97. rcs_getctime() if $config{getctime};
  98. refresh();
  99. rcs_notify() if $config{notify};
  100. saveindex();
  101. }
  102. } #}}}
  103. main;