Handle hostnames with upper-case letters
[webmin.git] / webalizer / backup_config.pl
1
2 do 'webalizer-lib.pl';
3
4 # backup_config_files()
5 # Returns files and directories that can be backed up
6 sub backup_config_files
7 {
8 local @rv = ( $config{'webalizer_conf'} );
9 local $f;
10 opendir(DIR, $module_config_directory);
11 while($f = readdir(DIR)) {
12         if ($f =~ /\.conf$/ || $f =~ /\.log$/) {
13                 push(@rv, "$module_config_directory/$f");
14                 }
15         }
16 closedir(DIR);
17 return @rv;
18 }
19
20 # pre_backup(&files)
21 # Called before the files are actually read
22 sub pre_backup
23 {
24 return undef;
25 }
26
27 # post_backup(&files)
28 # Called after the files are actually read
29 sub post_backup
30 {
31 return undef;
32 }
33
34 # pre_restore(&files)
35 # Called before the files are restored from a backup
36 sub pre_restore
37 {
38 return undef;
39 }
40
41 # post_restore(&files)
42 # Called after the files are restored from a backup
43 sub post_restore
44 {
45 # Re-setup all needed cron jobs
46 &foreign_require("cron", "cron-lib.pl");
47 local @jobs = &cron::list_cron_jobs();
48 foreach $log (&get_all_logs()) {
49         local $lconf = &get_log_config($log->{'file'});
50         if ($lconf->{'sched'}) {
51                 local ($job) = grep { $_->{'command'} eq
52                                       "$cron_cmd $log->{'file'}" } @jobs;
53                 if (!$job) {
54                         # Need to create!
55                         $job->{'user'} = 'root';
56                         $job->{'active'} = 1;
57                         $job->{'special'} = $lconf->{'special'};
58                         $job->{'mins'} = $lconf->{'mins'};
59                         $job->{'hours'} = $lconf->{'hours'};
60                         $job->{'days'} = $lconf->{'days'};
61                         $job->{'months'} = $lconf->{'months'};
62                         $job->{'weekdays'} = $lconf->{'weekdays'};
63                         $job->{'command'} = "$cron_cmd $log->{'file'}";
64                         &cron::create_cron_job($job);
65                         }
66                 }
67         }
68 return undef;
69 }
70
71 1;
72