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