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