Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Apr 5, 2021
1 parent d26c5e0 commit b8f62f9
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/modules/UsersRoutines.pm
Expand Up @@ -66,22 +66,30 @@ sub btrfs_subvolume {
sub copy_skel {
my ( $skel, $home ) = @_;

if ( $skel ne "" && %{ SCR->Read( ".target.stat", $skel ) } ) {
my $cmd = sprintf(
"/usr/bin/cp -r '%s/.' '%s'",
String->Quote($skel),
String->Quote($home)
);
my %cmd_out = %{ SCR->Execute( ".target.bash_output", $cmd ) };
my $stderr = $cmd_out{"stderr"} || "";

if ( $stderr ne "" ) {
y2error( "Error calling $cmd: $stderr" );
return 0;
}
if ( $skel eq "" || $home eq "" ) {
y2error("skel cannot be copied, wrong arguments: skel: '$skel', home: '$home'.");
return 0;
}

if ( ! %{ SCR->Read( ".target.stat", $skel ) } ) {
y2error("skel file '$skel' does not exist.");
return 0;
}

y2usernote("Home skeleton copied: '$cmd'.");
my $cmd = sprintf(
"/usr/bin/cp -r '%s/.' '%s'",
String->Quote($skel),
String->Quote($home)
);
my %cmd_out = %{ SCR->Execute( ".target.bash_output", $cmd ) };
my $stderr = $cmd_out{"stderr"} || "";

if ( $stderr ne "" ) {
y2error( "Error calling $cmd: $stderr" );
return 0;
}

y2milestone("Home skeleton copied: '$cmd'.");
}

##-------------------------------------------------------------------------
Expand Down Expand Up @@ -158,10 +166,7 @@ sub CreateHome {
}
}

if ($copy_usr_skel) {
copy_skel($usr_skel, $home);
}

copy_skel($usr_skel, $home) if ($copy_usr_skel);
copy_skel($skel, $home);

y2milestone("The directory $home was successfully created.");
Expand Down

0 comments on commit b8f62f9

Please sign in to comment.