Documentation processing and upload more mechanised.
[monikop.git] / fsck-pokinom
blobda0c2e47262c698522f2132e40f882c823cf669c
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
5 # Where to read local configuration:
6 my $pokinom_config = '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 if (qx(whoami) eq "root\n") {
34 qx(killall pokinom &> /dev/null);
35 # Find checkable (i.e. mounted) disks
36 my @mount_output = qx/mount/;
37 my %devices;
38 map {
39 my ($device, $mount_point) = /(\S+) on (.*) type .*/;
40 map {
41 if ($_ eq $mount_point) {
42 $devices{$mount_point} = $device;
44 } @usable_mount_points;
45 } @mount_output;
46 map {
47 my $device = $devices{$_};
48 open(PIPE, "umount $device && fsck -fp $device |");
49 while ( defined( my $line = <PIPE> ) ) {
50 chomp($line);
51 print "$line\n";
53 close PIPE;
55 } keys %devices;
56 } else {
57 print "$0: only root can run this.\n";