UI improvements.
[monikop.git] / fsck-pokinom
bloba662e412a03ff1bdf1efd14e237cc3c3a1644b35
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
5 # Where to read local configuration:
6 my $pokinom_config = 'pokinom.config';
8 ########################################
9 # Settings
10 ########################################
11 # Possible mount points
12 my @possible_mount_points;
14 # Other settings from $pokinom_config, not used here.
15 my $path_under_mount_point;
16 my $path_under_mount_point_backed_up;
17 my $path_under_mount_point_being_deleted;
18 my $destination;
19 my $rsync_username;
20 my $rsync_password;
21 my $rsync_log_prefix;
22 my $interrupted_prefix;
23 my $shut_down_when_done;
24 my $shut_down_action;
25 my $rsync_partial_dir_name;
27 # Local changes to the above.
28 eval `cat $pokinom_config`;
30 # Return sorted intersection of arrays which are supposed to have unique
31 # elements.
32 sub intersection {
33 my @intersection = ();
34 my %count = ();
35 my $element;
36 foreach $element (@_) { $count{$element}++ }
37 foreach $element (keys %count) {
38 push @intersection, $element if $count{$element} > 1;
40 sort @intersection;
43 if (qx(whoami) eq "bertb\n") {
44 qx(killall pokinom &> /dev/null);
45 # Find checkable (i.e. mounted) disks
46 my @raw_mount_points = grep (s/\S+ on (.*) type .*/$1/, qx/mount/);
47 chomp @raw_mount_points;
48 my @sources = intersection @raw_mount_points, @possible_mount_points;
49 print "SOURCES:\n";
50 print @sources;
51 map {
52 # qx(umount /dev/disk/by-label/Platte_* && fsck -fp /dev/disk/by-label/Platte_*);
53 } @sources;
54 } else {
55 print "$0: only root can run this.\n";