From 610ce90fb625484e1c5dd707315b171ba7d065fa Mon Sep 17 00:00:00 2001 From: Bert Burgemeister Date: Tue, 22 Dec 2009 11:22:48 +0100 Subject: [PATCH] Beginnings of a fsck helper --- fsck-pokinom | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 fsck-pokinom diff --git a/fsck-pokinom b/fsck-pokinom new file mode 100755 index 0000000..a662e41 --- /dev/null +++ b/fsck-pokinom @@ -0,0 +1,56 @@ +#! /usr/bin/perl +use strict; +use warnings; + +# Where to read local configuration: +my $pokinom_config = 'pokinom.config'; + +######################################## +# Settings +######################################## +# Possible mount points +my @possible_mount_points; + +# Other settings from $pokinom_config, not used here. +my $path_under_mount_point; +my $path_under_mount_point_backed_up; +my $path_under_mount_point_being_deleted; +my $destination; +my $rsync_username; +my $rsync_password; +my $rsync_log_prefix; +my $interrupted_prefix; +my $shut_down_when_done; +my $shut_down_action; +my $rsync_partial_dir_name; + +# Local changes to the above. +eval `cat $pokinom_config`; + +# Return sorted intersection of arrays which are supposed to have unique +# elements. +sub intersection { + my @intersection = (); + my %count = (); + my $element; + foreach $element (@_) { $count{$element}++ } + foreach $element (keys %count) { + push @intersection, $element if $count{$element} > 1; + } + sort @intersection; +} + +if (qx(whoami) eq "bertb\n") { + qx(killall pokinom &> /dev/null); +# Find checkable (i.e. mounted) disks + my @raw_mount_points = grep (s/\S+ on (.*) type .*/$1/, qx/mount/); + chomp @raw_mount_points; + my @sources = intersection @raw_mount_points, @possible_mount_points; + print "SOURCES:\n"; + print @sources; + map { +# qx(umount /dev/disk/by-label/Platte_* && fsck -fp /dev/disk/by-label/Platte_*); + } @sources; +} else { + print "$0: only root can run this.\n"; +} -- 2.11.4.GIT