}
sub indexdb {
- my $dir=shift;
- if (! defined $dir) {
- usage();
- }
- $config{wikistatedir}=$dir."/.ikiwiki";
+ setstatedir(shift);
# Note: No lockwiki here because ikiwiki already locks it
# before calling this.
}
sub hashpassword {
- my $dir=shift;
- if (! defined $dir) {
- usage();
- }
- $config{wikistatedir}=$dir."/.ikiwiki";
+ setstatedir(shift);
eval q{use IkiWiki::UserInfo};
eval q{use Authen::Passphrase::BlowfishCrypt};
}
sub deduplinks {
- my $dir=shift;
- if (! defined $dir) {
- usage();
- }
- $config{wikistatedir}=$dir."/.ikiwiki";
+ setstatdir(shift);
IkiWiki::loadindex();
foreach my $page (keys %links) {
my %l;
IkiWiki::saveindex();
}
+sub setstatedir {
+ my $dir=shift;
+
+ if (! defined $dir) {
+ usage();
+ }
+
+ if (! -d $dir) {
+ error("ikiwiki-transition: $dir does not exist");
+ }
+
+ $config{wikistatedir}=$dir."/.ikiwiki";
+
+ if (! -d $config{wikistatedir}) {
+ error("ikiwiki-transition: $config{wikistatedir} does not exist");
+ }
+}
+
sub usage {
print STDERR "Usage: ikiwiki-transition type ...\n";
print STDERR "Currently supported transition subcommands:\n";