working shareid query, non working date ranges
[BackupPC.git] / lib / BackupPC / Config.pm
1 package BackupPC::Config;
2
3 use warnings;
4 use Data::Dumper;
5
6 our %ConfigDef;
7
8 # this currently isn't used (or completed)
9 sub CheckConfigInfo
10 {
11     my($self) = @_;
12     my $errstr = '';
13     
14     my($attr, $val, $def, $ref);
15     
16     foreach $attr (sort keys %{ $self->{Conf} }) {
17         $val = $self->{Conf}->{$attr};
18         $ref = ref $val;
19         $def = $ConfigDef{$attr};
20         
21         if (!defined $def) {
22             $errstr .= "Unknown attribute $attr; ";
23         } elsif ($def->{struct} eq 'SCALAR' && $ref) {
24             $errstr .= "$attr expected to be SCALAR but is $ref; ";
25         } elsif ($def->{struct} =~ /^ARRAY(OFHASH)$/ && $ref && $ref ne 'ARRAY') {
26             $errstr .= "$attr expected to be ARRAY but is $ref; ";
27         } elsif ($def->{struct} =~ /^HASH(OFARRAY)$/ && $ref && $ref ne 'HASH') {
28             $errstr .= "$attr expected to be HASH but is $ref; ";
29         # still working out this logic..
30         #} elsif (defined $val && !$ref) {
31         #    # if we got a scalar but were expecting a reference, fix it
32         #    
33         #    if($def->{struct} eq 'ARRAY') {
34         #        $val = [ $val ];
35         #    } elsif ($def->{struct} eq 'HASH') {
36         #        $val = { $val };
37         #    } elsif ($def->{struct} eq 'ARRAYOFHASH') {
38         #        $val = [ { $val } ];
39         #    } elsif ($def->{struct} eq 'HASHOFARRAY') {
40         #        $val = { [ $val ] };
41         #    }
42             
43         }
44     }
45     
46     return $errstr;
47 }
48
49 sub TopDir
50 {
51     my($self) = @_;
52     return $self->{TopDir};
53 }
54
55 sub BinDir
56 {
57     my($self) = @_;
58     return $self->{BinDir};
59 }
60
61 sub Version
62 {
63     my($self) = @_;
64     return $self->{Version};
65 }
66
67 sub Conf
68 {
69     my($self) = @_;
70     return %{$self->{Conf}};
71 }
72
73 sub ConfigDef
74 {
75     my($self) = @_;
76     return \%ConfigDef;
77 }
78
79 sub Lang
80 {
81     my($self) = @_;
82     return $self->{Lang};
83 }
84
85 sub adminJob
86 {
87     return " admin ";
88 }
89
90 sub trashJob
91 {
92     return " trashClean ";
93 }
94
95 sub timeStamp
96 {
97     my($self, $t, $noPad) = @_;
98     my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
99               = localtime($t || time);
100     $year += 1900;
101     $mon++;
102     return "$year/$mon/$mday " . sprintf("%02d:%02d:%02d", $hour, $min, $sec)
103             . ($noPad ? "" : " ");
104 }
105
106 sub ConnectData
107 {
108     # fallback routine in case no database used
109     return 1;
110
111 }
112
113 ###########################
114
115
116 %ConfigDef = (
117     ServerHost                   => {struct => 'SCALAR',
118                                      type   => 'STRING', },
119
120     ServerPort                   => {struct => 'SCALAR',
121                                      type   => 'INT', },
122
123     ServerMesgSecret             => {struct => 'SCALAR',
124                                      type   => 'STRING', },
125
126     MyPath                       => {struct => 'SCALAR',
127                                      type   => 'STRING', },
128
129     UmaskMode                    => {struct => 'SCALAR',
130                                      type   => 'INT', },
131
132     WakeupSchedule               => {struct => 'ARRAY',
133                                      type   => 'INT', },
134
135     MaxBackups                   => {struct => 'SCALAR',
136                                      type   => 'INT', },
137
138     MaxUserBackups               => {struct => 'SCALAR',
139                                      type   => 'INT', },
140
141     MaxPendingCmds               => {struct => 'SCALAR',
142                                      type   => 'INT', },
143
144     MaxOldLogFiles               => {struct => 'SCALAR',
145                                      type   => 'INT', },
146
147     DfPath                       => {struct => 'SCALAR',
148                                      type   => 'STRING', },
149
150     DfMaxUsagePct                => {struct => 'SCALAR',
151                                      type   => 'INT', },
152
153     TrashCleanSleepSec           => {struct => 'SCALAR',
154                                      type   => 'INT', },
155
156     DHCPAddressRanges            => {struct => 'ARRAYOFHASH',
157                                      type   => {ipAddrBase => 'STRING',
158                                                 first      => 'INT',
159                                                 last       => 'INT',}, },
160
161     BackupPCUser                 => {struct => 'SCALAR',
162                                      type   => 'STRING', },
163
164     CgiDir                       => {struct => 'SCALAR',
165                                      type   => 'STRING', },
166
167     InstallDir                   => {struct => 'SCALAR',
168                                      type   => 'STRING', },
169
170     BackupPCUserVerify           => {struct => 'SCALAR',
171                                      type   => 'BOOLEAN', },
172
173     SmbShareName                 => {struct => 'ARRAY',
174                                      type   => 'STRING', },
175
176     SmbShareUserName             => {struct => 'SCALAR',
177                                      type   => 'STRING', },
178
179     SmbSharePasswd               => {struct => 'SCALAR',
180                                      type   => 'STRING', },
181
182     TarShareName                 => {struct => 'ARRAY',
183                                      type   => 'STRING', },
184
185     FullPeriod                   => {struct => 'SCALAR',
186                                      type   => 'FLOAT', },
187
188     IncrPeriod                   => {struct => 'SCALAR',
189                                      type   => 'FLOAT', },
190
191     FullKeepCnt                  => {struct => 'SCALAR',
192                                      type   => 'INT', },
193
194     FullKeepCntMin               => {struct => 'SCALAR',
195                                      type   => 'INT', },
196
197     FullAgeMax                   => {struct => 'SCALAR',
198                                      type   => 'INT', },
199
200     IncrKeepCnt                  => {struct => 'SCALAR',
201                                      type   => 'INT', },
202
203     IncrKeepCntMin               => {struct => 'SCALAR',
204                                      type   => 'INT', },
205
206     IncrAgeMax                   => {struct => 'SCALAR',
207                                      type   => 'INT', },
208
209     IncrFill                     => {struct => 'SCALAR',
210                                      type   => 'BOOLEAN', },
211
212     RestoreInfoKeepCnt           => {struct => 'SCALAR',
213                                      type   => 'INT', },
214
215     BackupFilesOnly              => {struct => 'HASHOFARRAY',
216                                      type   => 'STRING', },
217
218     BackupFilesExclude           => {struct => 'HASHOFARRAY',
219                                      type   => 'STRING', },
220
221     BlackoutBadPingLimit         => {struct => 'SCALAR',
222                                      type   => 'INT', },
223
224     BlackoutGoodCnt              => {struct => 'SCALAR',
225                                      type   => 'INT', },
226
227     BlackoutHourBegin            => {struct => 'SCALAR',
228                                      type   => 'FLOAT', },
229
230     BlackoutHourEnd              => {struct => 'SCALAR',
231                                      type   => 'FLOAT', },
232
233     BlackoutWeekDays             => {struct => 'ARRAY',
234                                      type   => 'INT', },
235
236     XferMethod                   => {struct => 'SCALAR',
237                                      type   => 'STRING', },
238
239     SmbClientPath                => {struct => 'SCALAR',
240                                      type   => 'STRING', },
241
242     SmbClientArgs                => {struct => 'SCALAR',
243                                      type   => 'STRING', },
244
245     TarClientCmd                 => {struct => 'SCALAR',
246                                      type   => 'STRING', },
247
248     TarFullArgs                  => {struct => 'SCALAR',
249                                      type   => 'STRING', },
250
251     TarIncrArgs                  => {struct => 'SCALAR',
252                                      type   => 'STRING', },
253
254     TarClientRestoreCmd          => {struct => 'SCALAR',
255                                      type   => 'STRING', },
256
257     TarClientPath                => {struct => 'SCALAR',
258                                      type   => 'STRING', },
259
260     SshPath                      => {struct => 'SCALAR',
261                                      type   => 'STRING', },
262
263     NmbLookupPath                => {struct => 'SCALAR',
264                                      type   => 'STRING', },
265
266     FixedIPNetBiosNameCheck      => {struct => 'SCALAR',
267                                      type   => 'BOOLEAN', },
268
269     PingPath                     => {struct => 'SCALAR',
270                                      type   => 'STRING', },
271
272     PingArgs                     => {struct => 'SCALAR',
273                                      type   => 'STRING', },
274
275     CompressLevel                => {struct => 'SCALAR',
276                                      type   => 'INT', },
277
278     PingMaxMsec                  => {struct => 'SCALAR',
279                                      type   => 'INT', },
280
281     SmbClientTimeout             => {struct => 'SCALAR',
282                                      type   => 'INT', },
283
284     MaxOldPerPCLogFiles          => {struct => 'SCALAR',
285                                      type   => 'INT', },
286
287     SendmailPath                 => {struct => 'SCALAR',
288                                      type   => 'STRING', },
289
290     EMailNotifyMinDays           => {struct => 'SCALAR',
291                                      type   => 'INT', },
292
293     EMailFromUserName            => {struct => 'SCALAR',
294                                      type   => 'STRING', },
295
296     EMailAdminUserName           => {struct => 'SCALAR',
297                                      type   => 'STRING', },
298
299     EMailNoBackupEverMesg        => {struct => 'SCALAR',
300                                      type   => 'MEMO', },
301
302     EMailNotifyOldBackupDays     => {struct => 'SCALAR',
303                                      type   => 'INT', },
304
305     EMailNoBackupRecentMesg      => {struct => 'SCALAR',
306                                      type   => 'MEMO', },
307
308     EMailNotifyOldOutlookDays    => {struct => 'SCALAR',
309                                      type   => 'INT', },
310
311     EMailOutlookBackupMesg       => {struct => 'SCALAR',
312                                      type   => 'MEMO', },
313
314     CgiAdminUserGroup            => {struct => 'SCALAR',
315                                      type   => 'STRING', },
316
317     CgiAdminUsers                => {struct => 'SCALAR',
318                                      type   => 'STRING', },
319
320     Language                     => {struct => 'SCALAR',
321                                      type   => 'STRING', },
322
323     CgiUserHomePageCheck         => {struct => 'SCALAR',
324                                      type   => 'STRING', },
325
326     CgiUserUrlCreate             => {struct => 'SCALAR',
327                                      type   => 'STRING', },
328
329     CgiDateFormatMMDD            => {struct => 'SCALAR',
330                                      type   => 'BOOLEAN', },
331
332     CgiNavBarAdminAllHosts       => {struct => 'SCALAR',
333                                      type   => 'BOOLEAN', },
334
335     CgiHeaders                   => {struct => 'SCALAR',
336                                      type   => 'STRING', },
337
338     CgiImageDir                  => {struct => 'SCALAR',
339                                      type   => 'STRING', },
340
341     CgiImageDirURL               => {struct => 'SCALAR',
342                                      type   => 'STRING', },
343
344 );
345
346 1;