#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @part = `cat /proc/partitions | grep sd | awk '{ print \$4; }'`;

for (@part) {
  chop;
  next if /\d/;
  my $hdd = $_;
  my $out = `mount | grep $hdd`;
  chop($out);

  if (! $out) {
    my $dev = "/dev/".$hdd."1";
    my $mount = "/media/usbhd-".$hdd."1";

    if (! -d $mount) {
      mkdir($mount);
    }

    print STDERR "WILL MOUNT $dev IN $mount\n";
    system("mount $dev $mount");
  }
}

