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