#!/usr/bin/perl

use strict;
use warnings;

use Pod::Usage;
use Getopt::Long qw(GetOptions);

use FindBin;
use lib "$FindBin::Bin/../lib";

use App::USBKeyCopyCon;

my(%opt);

if(!GetOptions(\%opt, 'help|?')) {
    pod2usage(-exitval => 1,  -verbose => 0);
}

pod2usage(-exitstatus => 0, -verbose => 2) if $opt{help};


App::USBKeyCopyCon->new->run;

exit 0;


__END__

=head1 NAME

usb-key-copy-con - GUI console for copying USB flash drives

=head1 SYNOPSIS

  sudo usb-key-copy-con

  Options:

   -?     detailed help message

=head1 DESCRIPTION

This program provides a GUI console for managing the process of bulk-copying
USB flash drives ('keys').  Launch the program and then:

=over 4

=item 1

insert a 'master' USB key when prompted - the contents of the key will be
copied into a temporary directory on the hard drive, after which the key can be
removed

=item 2

insert blank keys into all available USB ports - the app will detect when each
new key is inserted, start the copy process and alert the user on completion

=item 3

repeat step 2 as required

=back

The program must be run as root in order to mount/unmount and format the
blank flash drives.

The console window allows you to specify filtering parameters for recognising
USB keys as they are inserted.  If a key is inserted which matches the filter
then the copy process will start without requiring user interaction.  If a key
is inserted which does not match the filter then it will be ignored (the
console will display a greyed-out icon).  By default the filter parameters will
be set to exactly match the vendor name and drive capacity of the master key.

The default profile will format the blanks keys with a VFAT filesystem and the
volume label from the master key.  A file-by-file copy will be used to populate
the key and then MD5 checksums will be used to verify the copied files.

It is possible to create your own profiles that do anything you want with the
blank keys.  See L<App::USBKeyCopyCon> for more details.

=head2 Desktop Media Automount

The GNOME desktop environment (and probably others) will try to automatically
mount any USB storage device when it is plugged in.  This program is also
mounting and unmounting filesystems so things can get a bit confused.  You
probably want to disable this feature in your desktop environment before
running this program.

To disable automount in GNOME, run this command:

  gconftool-2 --type bool --set \
    /apps/nautilus/preferences/media_automount false

and to enable it again, use this command:

  gconftool-2 --type bool --set \
    /apps/nautilus/preferences/media_automount true

=head1 OPTIONS

=over 4

=item B<-?>

Display this documentation.

=back


=head1 COPYRIGHT & LICENSE

Copyright 2009 Grant McLean, all rights reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.


=cut



