start rsync on stale pid file
[cloudstore.git] / rsync-piper.pl
index cdb23a2..0edf8b0 100755 (executable)
@@ -95,6 +95,12 @@ while(<$p>) {
 
        my ( $login, undef, $uid, $gid, $email, $path, $shell ) = split(/:/,$_,7);
 
+       if ( -d $path && -f "$path/.secrets" && ! -e "$path/.meta/secrets" ) {
+               $store->api->mkbasepath( "$path/.meta/secrets" );
+               rename "$path/.secrets", "$path/.meta/secrets";
+               warn "UPGRADE $login rsync secrets location\n";
+       }
+
        if ( -d $path && -f "$path/.meta/secrets" ) {
                my @secrets = map { chomp; $_ } read_file "$path/.meta/secrets";
                my $auth_users = join(', ', map { s/:.+$//; $_ } @secrets );
@@ -174,7 +180,7 @@ sub REAPER {
 $SIG{CHLD} = \&REAPER;
 
 
-if ( ! -e $pid_file ) {
+if ( ! -e $pid_file || ! kill( 0, rsync_running_pid ) ) {
        my $exec = "$rsync --daemon --config $cfg_file --no-detach --port=$port";
        warn "START $exec\n";