Handle hostnames with upper-case letters
[webmin.git] / fsdump / rmulti.pl
1 #!/usr/local/bin/perl
2 # rmulti.pl
3 # Called when a tape change is needed for a multi-file restore. Links the
4 # base filename to the next one in the ordered sequence of multi-files
5
6 $no_acl_check++;
7 delete($ENV{'SCRIPT_NAME'});    # force use of $0 to determine module
8 delete($ENV{'FOREIGN_MODULE_NAME'});
9 require './fsdump-lib.pl';
10
11 $ARGV[0] =~ /^(.*)\/([^\/]+)$/ || die "Missing filename";
12 $dir = $1;
13 $file = $2;
14
15 # Find out where we are up to
16 $lnk = readlink($ARGV[0]);
17 if ($lnk =~ /^\Q$file\E\.(\d+)$/ && -r "$dir/$lnk" && !$ARGV[1]) {
18         # Going to next file
19         $nxt = "$file.".($1 + 1);
20         }
21 else {
22         # First file
23         -r $ARGV[0] && !-l $ARGV[0] &&
24                 die "$ARGV[0] is not a link to the current archive!";
25         $nxt = "$file.1";
26         }
27
28 # Update the link
29 unlink($ARGV[0]);
30 symlink($nxt, $ARGV[0]);
31 exit(0);
32