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