add more warning and rework warning logging and tests
This commit is contained in:
parent
2bdb63cfff
commit
e32ec08832
2
Makefile
2
Makefile
|
@ -1,8 +1,8 @@
|
|||
PREFIX=/usr/local
|
||||
|
||||
test:
|
||||
./impermanence.pl -v -t tests/impermanence.yml
|
||||
-./impermanence.pl -t tests/errored.yml
|
||||
./impermanence.pl -t tests/impermanence.yml
|
||||
|
||||
install:
|
||||
install -o root -g wheel -m 555 impermanence.pl ${PREFIX}/bin/impermanence
|
||||
|
|
|
@ -21,6 +21,13 @@ sub usage {
|
|||
exit 1;
|
||||
}
|
||||
|
||||
# display a warning inconditionnaly
|
||||
sub saywarning {
|
||||
my $msg = shift;
|
||||
say STDERR "WARNING: $msg";
|
||||
syslog(LOG_WARNING, "$msg");
|
||||
}
|
||||
|
||||
# display a message only if verbose flag is used
|
||||
sub saydebug {
|
||||
my $msg = shift;
|
||||
|
@ -69,7 +76,7 @@ sub remove_transclusion {
|
|||
foreach my $file (@files) {
|
||||
my($filename, $dirs, $suffix) = fileparse($file);
|
||||
if( $dirs =~ m/^$dir/ ) {
|
||||
say STDERR "WARNING: $dir contains $file";
|
||||
saywarning("WARNING: $dir contains $file");
|
||||
$file = "";
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +90,7 @@ sub remove_transclusion {
|
|||
my $dir2 = $directories[$j];
|
||||
next if ( $dir2 eq "" );
|
||||
if( $dir =~ m/$dir2/ ) {
|
||||
say STDERR "WARNING: $dir2 contains $dir";
|
||||
saywarning("$dir2 contains $dir");
|
||||
$directories[$i] = "";
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +141,7 @@ sub mount_mfs {
|
|||
}
|
||||
my $fs = `swapctl | tail -n 1 | cut -d ' ' -f 1 | tr -d '\n'`;
|
||||
|
||||
saydebug "mount the destination using mount_mfs from $fs";
|
||||
saydebug("mount the destination using mount_mfs from $fs");
|
||||
$ret = system("mount_mfs", "-s", $data->{size}, $fs, $impermanence_home);
|
||||
if( $ret != 0 ) {
|
||||
trap_error("ERROR: mounting the mfs filesystem errored with error $ret");
|
||||
|
@ -159,6 +166,10 @@ sub create_links {
|
|||
make_path($dirs, { chmod => 0700, owner => $user });
|
||||
}
|
||||
|
||||
if ( ! -e $old_file ) {
|
||||
saywarning("$old_file doesn't exist");
|
||||
}
|
||||
|
||||
if( symlink($old_file, $new_file) == 0 ) {
|
||||
trap_error("symlink $old_file to $new_file");
|
||||
} else {
|
||||
|
@ -183,7 +194,7 @@ sub main {
|
|||
|
||||
# check if using test mode to validate a configuration file
|
||||
if( defined $opts{t} ) {
|
||||
say STDERR "WARNING: test mode enabled";
|
||||
say("test mode enabled");
|
||||
$configuration_file = $opts{t};
|
||||
|
||||
# non-test mode, mount the ramdisk and populates it
|
||||
|
|
|
@ -18,6 +18,7 @@ directories:
|
|||
- Downloads
|
||||
- Datastore/Music
|
||||
- Datastore
|
||||
- Datastore/
|
||||
- Datastore/Music/Band1
|
||||
- .config
|
||||
- foo/bar
|
||||
|
|
Loading…
Reference in New Issue