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