specify max tag depth (default: 15)
[id3fs.git] / sbin / id3fsd
1 #!/usr/bin/perl -w
2 # Ian Beckwith <ianb@erislabs.net>
3 #
4
5 use lib '/home/ianb/projects/id3fs/id3fs/lib';
6 use strict;
7 use Getopt::Long qw(Configure);
8 use ID3FS::DB;
9 use ID3FS::Fuse;
10 use vars qw($me);
11 $me=($0=~/(?:.*\/)?(.*)/)[0];
12
13 our $VERSION="1.00";
14 my $verbose=0;
15 my $help=0;
16 my $dbpath=undef;
17 my $tagdepth=undef;
18
19 Configure(qw(bundling no_ignore_case));
20 my $optret=GetOptions(
21     "verbose|v"    => sub { $verbose++; },
22     "help|h"       => \$help,
23     "database|f=s" => \$dbpath,
24     "t|tagdepth=s" => \$tagdepth,
25     );
26
27 usage() if(scalar(@ARGV) != 2 || !$optret || $help);
28
29 my $source=shift;
30 my $mountpoint=shift;
31
32 my $db=ID3FS::DB->new($me, $verbose, 0, $dbpath, $source);
33 exit unless($db);
34
35 my $fuse=ID3FS::Fuse->new($db, $source, $mountpoint, $verbose, $tagdepth);
36 $fuse->run();
37
38 sub usage
39 {
40     die("Usage: $me [-vqh] [-f <dbfile>] [--] <sourcedir> <mountpoint>\n".
41         " -v\t\t\tVerbose (repeat for more verbosity)\n".
42         " -h\t\t\tThis help\n".
43         " -f|--database=FILE\tPath to database file\n" .
44         " --\t\t\tEnd of options\n");
45 }
46
47 __END__
48
49 =head1 NAME
50
51 id3fsd - FUSE filesystem for browsing id3 tags
52
53 =head1 SYNOPSIS
54
55 B<id3fsd> [B<-vh>] S<B<[-f >I<dbfile>]> [B<-->] I<SOURCEDIR> I<MOUNTPOINT>
56
57 =head1 DESCRIPTION
58
59 id3fsd provides a browsable filesystem of your music files, organised
60 into sub-directories by id3 tags (or flac/ogg comments).
61
62 An index should first be created with L<id3fs-index(1)>, then id3fsd
63 can mount the files in I<SOURCEDIR> on the directory I<MOUNTPOINT>.
64
65 If not explicitly specified (with B<-f>), the index is searched for
66 at I<SOURCEDIR>/B<.id3fs>.
67
68 The resulting filesystem is read-only. Tags appear as directories,
69 and files appear as symlinks to the actual files in I<SOURCEDIR>.
70
71 FIXME: better description, allow_others/fuse.conf, fstab, explain genre tag
72
73 =head1 OPTIONS
74
75 =over 4
76
77 =item B<-v>
78
79 Enable verbose operation. Repeat for more verbosity.
80
81 =item B<-h>
82
83 Show a short help message.
84
85 =item S<B<-f >I<FILE>> | S<B<--database=>I<FILE>>
86
87 Use database in I<FILE>. The default is I<SOURCEDIR>/B<.id3fs>.
88
89 =item B<-->
90
91 End of options.
92
93 =back
94
95 =head1 EXAMPLES
96
97 To mount an id3fs filesystem which indexes B<~/music/albums> on
98 B<~/music/tags>:
99
100 First create the index:
101
102     id3fs-index -v ~/music/albums
103
104 If you have a large collection of music, this may take some time.
105
106 Then create the mountpoint:
107
108     mkdir ~/music/tags
109
110 and mount the filesystem:
111
112     id3fsd ~/music/albums ~/music/tags
113
114 Then explore the tags in ~/music/tags/
115
116 FIXME: fstab
117
118 =head1 BUGS
119
120 Please report any found to ianb@erislabs.net
121
122 =head1 SEE ALSO
123
124 L<id3fs-index(1)>, L<http://fuse.sourceforge.net>
125
126 =head1 AUTHOR
127
128 Ian Beckwith <ianb@erislabs.net>
129
130 =head1 AVAILABILITY
131
132 The latest version can be found at:
133
134 B<http://erislabs.net/ianb/projects/id3fs/>
135
136 =head1 COPYRIGHT
137
138 Copyright 2010 Ian Beckwith <ianb@erislabs.net>
139
140 This program is free software: you can redistribute it and/or modify
141 it under the terms of the GNU General Public License as published by
142 the Free Software Foundation; either version 3 of the License, or
143 (at your option) any later version.
144
145 This program is distributed in the hope that it will be useful,
146 but WITHOUT ANY WARRANTY; without even the implied warranty of
147 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
148 GNU General Public License for more details.
149
150 You should have received a copy of the GNU General Public License
151 along with this program.  If not, see <http://www.gnu.org/licenses/>.
152
153 =cut