+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});
+ }
+ }
+}
+