X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/82ecf0aa9dbf42352401cbcab1fb19bfece45c02..64295da8aff69aec7bf7fd4df6225e67c894635e:/ikiwiki-transition diff --git a/ikiwiki-transition b/ikiwiki-transition index 0177f98a9..3e2c89bf9 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 { + require IkiWiki::Setup; + require IkiWiki::Plugin::aggregate; + + %config = (IkiWiki::defaultconfig(), IkiWiki::Setup::load(shift)); + IkiWiki::checkconfig(); + + 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 setupfile\n"; exit 1; } @@ -85,9 +127,15 @@ 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(); }