X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/3479809f96fa9c7a5d9f86c18c581f9a343a3aef..6ebea774c85502377681165e27093a3bd3a61f30:/ikiwiki-transition?ds=inline diff --git a/ikiwiki-transition b/ikiwiki-transition index 0e2bd4e22..6524297ee 100755 --- a/ikiwiki-transition +++ b/ikiwiki-transition @@ -57,6 +57,8 @@ sub indexdb { usage(); } + # Note: No lockwiki here because ikiwiki already locks it + # before calling this. if (! IkiWiki::oldloadindex()) { die "failed to load index\n"; } @@ -71,11 +73,51 @@ sub indexdb { } } +sub hashpassword { + $config{wikistatedir}=shift()."/.ikiwiki"; + + if (! defined $config{wikistatedir}) { + usage(); + } + + eval q{use IkiWiki::UserInfo}; + eval q{use Authen::Passphrase::BlowfishCrypt}; + if ($@) { + error("ikiwiki-transition hashpassword: failed to load Authen::Passphrase, passwords not hashed"); + } + + IkiWiki::lockwiki(); + IkiWiki::loadplugin("passwordauth"); + my $userinfo = IkiWiki::userinfo_retrieve(); + foreach my $user (keys %{$userinfo}) { + if (ref $userinfo->{$user} && + exists $userinfo->{$user}->{password} && + length $userinfo->{$user}->{password} && + ! exists $userinfo->{$user}->{cryptpassword}) { + IkiWiki::Plugin::passwordauth::setpassword($user, $userinfo->{$user}->{password}); + } + } +} + +sub aggregateinternal { + $config{srcdir} = shift; + $config{wikistatedir} = $config{srcdir}."/.ikiwiki"; + $config{htmlext} = (shift or "html"); + + require IkiWiki::Plugin::aggregate; + + IkiWiki::Plugin::aggregate::migrate_to_internal(); + + print "... now add aggregateinternal => 1 to your .setup file\n"; +} + sub usage { print STDERR "Usage: ikiwiki-transition type ...\n"; print STDERR "Currently supported transition subcommands:\n"; print STDERR " prefix_directives file\n"; print STDERR " indexdb srcdir\n"; + print STDERR " hashpassword srcdir\n"; + print STDERR " aggregateinternal srcdir [htmlext]\n"; exit 1; } @@ -85,15 +127,22 @@ my $mode=shift; if ($mode eq 'prefix_directives') { prefix_directives(@ARGV); } +elsif ($mode eq 'hashpassword') { + hashpassword(@ARGV); +} elsif ($mode eq 'indexdb') { indexdb(@ARGV); } +elsif ($mode eq 'aggregateinternal') { + aggregateinternal(@ARGV); +} else { usage(); } package IkiWiki; +# A slightly modified version of the old loadindex function. sub oldloadindex { %oldrenderedfiles=%pagectime=(); if (! $config{rebuild}) { @@ -131,5 +180,16 @@ sub oldloadindex { $oldrenderedfiles{$page}=[@{$items{dest}}]; $pagectime{$page}=$items{ctime}[0]; } + + # saveindex relies on %hooks being populated, else it won't save + # the page state owned by a given hook. But no plugins are loaded + # by this program, so populate %hooks with all hook ids that + # currently have page state. + foreach my $page (keys %pagemtime) { + foreach my $id (keys %{$pagestate{$page}}) { + $hooks{_dummy}{$id}=1; + } + } + return close($in); }