hddOp 546 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my $disk = "/dev/sdb1";
  5. my $volume = "hddVolume";
  6. my $mountpoint = "/mnt/hddDisk";
  7. if ( ! defined $ARGV[0] ) {
  8. print "Pass either --mount or --umount\n";
  9. exit 1;
  10. }
  11. my $opt = $ARGV[0];
  12. if ( $opt eq "mount" ) {
  13. system("sudo cryptsetup luksOpen $disk $volume");
  14. system("sudo mount /dev/mapper/$volume $mountpoint");
  15. } elsif ( $opt eq "umount" ) {
  16. system("sudo umount $mountpoint");
  17. system("sudo cryptsetup luksClose /dev/mapper/$volume");
  18. } else {
  19. print "Did not recognize opt, exiting...\n";
  20. }