/[psinib]/psinib.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /psinib.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by dpavlin, Sun Oct 26 14:04:17 2003 UTC revision 1.19 by dpavlin, Mon Oct 27 19:07:32 2003 UTC
# Line 199  sub xlog { Line 199  sub xlog {
199          my $share = shift;          my $share = shift;
200          my $t = strftime $LOG_TIME_FMT, localtime;          my $t = strftime $LOG_TIME_FMT, localtime;
201          my $m = shift || '[no log entry]';          my $m = shift || '[no log entry]';
202          my $l = shift || 1;          my $l = shift;
203            $l = 1 if (! defined $l);       # default verbosity is 1
204          print STDERR $m,"\n" if ($verbose >= $l);          print STDERR $m,"\n" if ($verbose >= $l);
205          print L "$t $share\t$m\n";          print L "$t $share\t$m\n";
206  }  }
207    
208  # dump warn and dies into log  # dump warn and dies into log
209  BEGIN { $SIG{'__WARN__'} = sub { xlog('WARN',$_[0]) ; warn $_[0] } }  BEGIN { $SIG{'__WARN__'} = sub { xlog('WARN',$_[0],1) ; warn $_[0] } }
210  BEGIN { $SIG{'__DIE__'} = sub { xlog('DIE',$_[0]) ; die $_[0] } }  BEGIN { $SIG{'__DIE__'} = sub { xlog('DIE',$_[0],0) ; die $_[0] } }
211    
212    
213  # split share name to host, dir and currnet date dir  # split share name to host, dir and currnet date dir
# Line 248  sub snap_share { Line 249  sub snap_share {
249          if (-l $bl) {          if (-l $bl) {
250                  $real_bl=readlink($bl) || die "can't read link $bl: $!";                  $real_bl=readlink($bl) || die "can't read link $bl: $!";
251                  $real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/");                  $real_bl="$BACKUP_DEST/$host/$dir/$real_bl" if (substr($real_bl,0,1) ne "/");
252          } else {                  if (! -e $real_bl) {
253                  xlog($share,"no old backup, trying to find last backup,");                          xlog($share,"latest link $bl -> $real_bl not valid, removing it");
254                            unlink $bl || die "can't remove link $bl: $!";
255                            undef $real_bl;
256                    }
257            }
258            if (! $real_bl) {
259                    xlog($share,"no old backup, trying to find last backup");
260                  if (opendir(BL_DIR, "$BACKUP_DEST/$host/$dir")) {                  if (opendir(BL_DIR, "$BACKUP_DEST/$host/$dir")) {
261                          my @bl_dirs = sort grep { !/^\./ && -d "$BACKUP_DEST/$host/$dir/$_" } readdir(BL_DIR);                          my @bl_dirs = sort grep { !/^\./ && -d "$BACKUP_DEST/$host/$dir/$_" } readdir(BL_DIR);
262                          closedir(BL_DIR);                          closedir(BL_DIR);
# Line 382  sub snap_share { Line 389  sub snap_share {
389                  my $pf = norm_dir($d,"smb:$share/");    # path full                  my $pf = norm_dir($d,"smb:$share/");    # path full
390                  my $D = $smb->opendir($pf);                  my $D = $smb->opendir($pf);
391                  if (! $D) {                  if (! $D) {
392                          xlog($share,"FATAL: $share [$pf]: $!");                          xlog($share,"FATAL: $share [$pf] as $param{username}/$param{workgroup}: $!",0);
393                          # remove failing dir                          # remove failing dir
394                          delete $smb_dirs[$di];                          delete $smb_dirs[$di];
395                          return 0;                       # failed                          return 0;                       # failed

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.26