2012-03-27 17:37:21 +00:00
|
|
|
#!/usr/bin/perl
|
2011-03-29 17:41:03 +00:00
|
|
|
|
2012-03-27 17:37:21 +00:00
|
|
|
use strict;
|
|
|
|
use FindBin qw($Bin);
|
|
|
|
use Getopt::Long;
|
|
|
|
require "$Bin/misc/devlib.pl";
|
2011-03-29 17:41:03 +00:00
|
|
|
|
2012-04-29 04:29:51 +00:00
|
|
|
my @blobref_arg;
|
|
|
|
|
|
|
|
if (@ARGV) {
|
|
|
|
my $blobref = shift;
|
|
|
|
unless ($blobref && $blobref =~ /^\w+-[0-9a-f]{10,}$/) {
|
|
|
|
die "Usage: dev-cammount [<blobref>]\n";
|
|
|
|
}
|
|
|
|
push @blobref_arg, $blobref;
|
2012-03-27 17:37:21 +00:00
|
|
|
}
|
2012-04-29 04:29:51 +00:00
|
|
|
|
2012-03-27 17:37:21 +00:00
|
|
|
my $cammount = build_bin("./cmd/cammount");
|
2011-03-29 17:41:03 +00:00
|
|
|
|
2012-03-27 17:37:21 +00:00
|
|
|
my $dir = "/tmp/cammount-dir";
|
|
|
|
mkdir $dir, 0700 unless -d $dir;
|
2011-03-29 17:41:03 +00:00
|
|
|
|
2012-03-27 17:37:21 +00:00
|
|
|
try_unmount();
|
|
|
|
print "Mounting on $dir ...\n";
|
2013-02-07 05:56:44 +00:00
|
|
|
$ENV{"CAMLI_AUTH"} = "userpass:camlistore:pass3179";
|
2013-01-26 00:23:31 +00:00
|
|
|
system("$cammount", "--server=http://localhost:3179/bs", $dir, @blobref_arg)
|
2012-03-27 17:37:21 +00:00
|
|
|
and warn "cammount failure: $!\n";
|
|
|
|
warn "Failed to unmount\n" unless try_unmount();
|
2012-03-19 06:58:36 +00:00
|
|
|
|
2012-03-27 17:37:21 +00:00
|
|
|
sub try_unmount {
|
|
|
|
if ($^O eq "linux" && system("fusermount", "-u", $dir) == 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 1 if system("umount", $dir) == 0;
|
|
|
|
return 1 if system("umount", "-f", $dir) == 0;
|
|
|
|
return 0;
|
|
|
|
}
|