3 # Called when a new tape is needed for some backup, to update its status
4 # file. Only exits when the user has actually clicked the 'new tape' button
7 delete($ENV{'SCRIPT_NAME'}); # force use of $0 to determine module
8 delete($ENV{'FOREIGN_MODULE_NAME'});
9 require './fsdump-lib.pl';
10 $dump = &get_dump($ARGV[0]);
11 $dump->{'id'} || die "Dump $ARGV[0] does not exist!";
13 # Find the status file
14 opendir(DIR, $module_config_directory);
15 foreach $f (readdir(DIR)) {
16 if ($f =~ /^(\d+)\.(\d+)\.status$/ && $1 eq $dump->{'id'}) {
18 $sfile = "$module_config_directory/$f";
22 $sfile || die "Failed to find status file for dump $ARGV[0]";
24 # Update it to indicate that a new tape is needed
25 &read_file($sfile, \%status);
26 $status{'status'} = 'tape';
27 $status{'tapepid'} = $$;
28 $status{'tapecount'}++;
29 &write_file($sfile, \%status);
31 # Email the backup address
32 if ($dump->{'email'} && &foreign_check("mailboxes")) {
33 &foreign_require("mailboxes", "mailboxes-lib.pl");
34 $host = &get_system_hostname();
35 $c = $status{'tapecount'};
36 @dirs = &dump_directories($dump);
37 $dirs = join(", ", @dirs);
38 $subject = &text('newtape_subject', $c, $dirs, $host);
39 $data = &text('newtape_body', $c, $dirs, $host)."\n";
40 &mailboxes::send_text_mail(&mailboxes::get_from_address(),
45 $config{'smtp_server'});
48 # Wait until signalled with a HUP
49 $SIG{'HUP'} = \&got_hup;
57 $status{'status'} = 'running';
58 &write_file($sfile, \%status);