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