/[smecontribs]/rpms/smeserver-arkeia/contribs7/smeserver-arkeia-1.0-configdb.patch
ViewVC logotype

Contents of /rpms/smeserver-arkeia/contribs7/smeserver-arkeia-1.0-configdb.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Tue Nov 25 16:20:18 2008 UTC (16 years ago) by slords
Branch: MAIN
CVS Tags: smeserver-arkeia-1_0-22_el4_sme, smeserver-arkeia-1_0-21_el4_sme, smeserver-arkeia-1_0-26_el4_sme, smeserver-arkeia-1_0-29_el4_sme, smeserver-arkeia-1_0-20_el4_sme, smeserver-arkeia-1_0-18_el4_sme, smeserver-arkeia-1_0-27_el4_sme, smeserver-arkeia-1_0-19_el4_sme, HEAD
Changes since 1.2: +0 -0 lines
Error occurred while calculating annotation data.
Restore

1 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Drive mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Drive
2 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Drive 1969-12-31 17:00:00.000000000 -0700
3 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Drive 2007-01-24 22:45:02.000000000 -0700
4 @@ -0,0 +1 @@
5 +none
6 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Label mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Label
7 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Label 1969-12-31 17:00:00.000000000 -0700
8 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Label 2007-01-24 22:45:02.000000000 -0700
9 @@ -0,0 +1 @@
10 +Tape #
11 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/status mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/status
12 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/status 1969-12-31 17:00:00.000000000 -0700
13 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/status 2007-01-24 22:45:02.000000000 -0700
14 @@ -0,0 +1 @@
15 +enabled
16 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Tape mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Tape
17 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Tape 1969-12-31 17:00:00.000000000 -0700
18 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Tape 2007-01-24 22:45:02.000000000 -0700
19 @@ -0,0 +1 @@
20 +none
21 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/type mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/type
22 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/type 1969-12-31 17:00:00.000000000 -0700
23 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/type 2007-01-24 22:45:02.000000000 -0700
24 @@ -0,0 +1 @@
25 +backupservice
26 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-delete-dumped-catalog mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-delete-dumped-catalog
27 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-delete-dumped-catalog 2004-07-26 10:30:48.000000000 -0600
28 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-delete-dumped-catalog 2007-01-24 22:45:02.000000000 -0700
29 @@ -3,31 +3,25 @@
30 package esmith;
31
32 use strict;
33 -use Errno;
34 -use esmith::config;
35 -use esmith::db;
36 -use esmith::util;
37 -
38 -tie my %conf, 'esmith::config';
39 -
40 -my $program=db_get_prop(\%conf, 'backup', 'Program') || 'flexbackup';
41 -my $status=db_get_prop(\%conf, 'backup', 'status') || 'disabled';
42 -my $tapetype=db_get_prop(\%conf, 'arkeia', 'Tape') || 'none';
43 +use esmith::ConfigDB;
44 +
45 +my $cdb = esmith::ConfigDB->open_ro;
46 +my $backup = $cdb->get('backup') or die "No backup db entry found\n";
47 +
48 +my $program = $backup->prop('Program') || 'flexbackup';
49 +my $status = $backup->prop('status') || 'disabled';
50
51 if ($status eq 'enabled' && $program eq 'arkeia')
52 {
53 open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |');
54 - while (<BACKUP>) {
55 - if (m#tag=(.*)#) {
56 - die("Another arkeia backup is already running ($1).");
57 - }
58 - }
59 + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } <BACKUP>;
60 close BACKUP;
61 + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag};
62 }
63
64 # Always remove the dumped tables.
65
66 -system qw(/bin/rm -rf /home/e-smith/db/arkeia);
67 +system(qw(/bin/rm -rf /home/e-smith/db/arkeia));
68
69 # Recreate the directories.
70
71 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-dump-catalog mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-dump-catalog
72 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-dump-catalog 2004-07-26 10:30:57.000000000 -0600
73 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-dump-catalog 2007-01-24 22:45:02.000000000 -0700
74 @@ -3,26 +3,20 @@
75 package esmith;
76
77 use strict;
78 -use Errno;
79 -use esmith::config;
80 -use esmith::db;
81 -use esmith::util;
82 -
83 -tie my %conf, 'esmith::config';
84 -
85 -my $program=db_get_prop(\%conf, 'backup', 'Program') || 'flexbackup';
86 -my $status=db_get_prop(\%conf, 'backup', 'status') || 'disabled';
87 -my $tapetype=db_get_prop(\%conf, 'arkeia', 'Tape') || 'none';
88 +use esmith::ConfigDB;
89 +
90 +my $cdb = esmith::ConfigDB->open_ro;
91 +my $backup = $cdb->get('backup') or die "No backup db entry found\n";
92 +
93 +my $program = $backup->prop('Program') || 'flexbackup';
94 +my $status = $backup->prop('status') || 'disabled';
95
96 if ($status eq 'enabled' && $program eq 'arkeia')
97 {
98 open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |');
99 - while (<BACKUP>) {
100 - if (m#tag=(.*)#) {
101 - die("Another arkeia backup is already running ($1).");
102 - }
103 - }
104 + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } <BACKUP>;
105 close BACKUP;
106 + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag};
107
108 #----------------------------------------------------------
109 # Check that the dump directory exists. This should have been
110 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-readtape mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-readtape
111 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-readtape 1969-12-31 17:00:00.000000000 -0700
112 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-readtape 2007-01-24 22:45:02.000000000 -0700
113 @@ -0,0 +1,45 @@
114 +#!/usr/bin/perl -w
115 +
116 +package esmith;
117 +
118 +use strict;
119 +use esmith::ConfigDB;
120 +use esmith::lockfile;
121 +
122 +my $cdb = esmith::ConfigDB->open_ro;
123 +my $backup = $cdb->get('backup') or die "No backup db entry found\n";
124 +my $arkeia = $cdb->get('arkeia') or die "No arkeia db entry found\n";
125 +
126 +my $program = $backup->prop('Program') || 'flexbackup';
127 +my $status = $backup->prop('status') || 'disabled';
128 +my $device = $backup->prop('Device') || '/dev/st0';
129 +my $drive = $arkeia->prop('Drive') || 'none';
130 +my $tape = $arkeia->prop('Tape') || 'none';
131 +
132 +if ($status eq 'enabled' && $program eq 'arkeia')
133 +{
134 + open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |');
135 + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } <BACKUP>;
136 + close BACKUP;
137 + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag};
138 +}
139 +
140 +open(DRIVETYPE, '/usr/bin/arkc -drive -type -noinfo 2>&1 |');
141 +my %drivetype = map { chomp; /name=(.*)/; $1 => 1 } <DRIVETYPE>;
142 +close DRIVETYPE;
143 +exit(0) unless $drivetype{$drive};
144 +
145 +open(TAPETYPE, '/usr/bin/arkc -tape -type -noinfo 2>&1 |');
146 +my %tapetype = map { chomp; /name=(.*)/; $1 => 1 } <TAPETYPE>;
147 +close TAPETYPE;
148 +exit(0) unless $tapetype{$tape};
149 +
150 +my $lock_file = "/var/lock/subsys/arkeia-recover";
151 +my $file_handle = &esmith::lockfile::LockFileOrReturn($lock_file);
152 +
153 +if ($file_handle) {
154 + $ENV{'PATH'} = "/bin:/usr/bin:/sbin:/opt/arkeia/bin";
155 + system(qw(/opt/arkeia/bin/arkrstdb), "-d$device", "-t$tape", "-r$drive", "-pTape Pool");
156 + &esmith::lockfile::UnlockFile($file_handle);
157 + `/bin/rm -f $lock_file`;
158 +}
159 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-recycle-tape mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-recycle-tape
160 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-recycle-tape 2006-05-14 16:19:44.000000000 -0600
161 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-recycle-tape 2007-01-24 22:45:02.000000000 -0700
162 @@ -3,105 +3,81 @@
163 package esmith;
164
165 use strict;
166 -use Errno;
167 -use esmith::config;
168 -use esmith::db;
169 -use esmith::util;
170 -
171 -tie my %conf, 'esmith::config';
172 -
173 -my $program=db_get_prop(\%conf, 'backup', 'Program') || 'flexbackup';
174 -my $status=db_get_prop(\%conf, 'backup', 'status') || 'disabled';
175 -my $tapetype=db_get_prop(\%conf, 'arkeia', 'Tape') || 'none';
176 -my $device = db_get_prop(\%conf, 'backup', 'Device') || '/dev/st0';
177 -my $label = db_get_prop(\%conf, 'arkeia', 'Label') || 'Tape #';
178 +use esmith::ConfigDB;
179 +
180 +my $cdb = esmith::ConfigDB->open_ro;
181 +my $backup = $cdb->get('backup') or die "No backup db entry found\n";
182 +my $arkeia = $cdb->get('arkeia') or die "No arkeia db entry found\n";
183 +
184 +my $program = $backup->prop('Program') || 'flexbackup';
185 +my $status = $backup->prop('status') || 'disabled';
186 +my $device = $backup->prop('Device') || '/dev/st0';
187 +my $tape = $arkeia->prop('Tape') || 'none';
188 +my $label = $arkeia->prop('Label') || 'Tape #';
189
190 if ($status eq 'enabled' && $program eq 'arkeia')
191 {
192 open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |');
193 - while (<BACKUP>) {
194 - die("Backup aborted: Another arkeia backup is already running ($_)") if (m/tag=(.*)/);
195 - }
196 + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } <BACKUP>;
197 close BACKUP;
198 + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag};
199 +}
200
201 - my $foundtape=0;
202 - open(TAPELOADED, "/bin/mt -f $device status 2>&1 |");
203 - while (<TAPELOADED>) {
204 - $foundtape=1 if (m/ONLINE/);
205 - }
206 - close TAPELOADED;
207 - die("Backup aborded: No tape loaded in drive") unless $foundtape;
208 +die('Invalid Tape property for arkeia') if ($tape eq 'none');
209
210 - die('Backup aborted: Invalid Tape property for arkeia') if ($tapetype eq 'none');
211 +my $foundtape=0;
212 +open(TAPELOADED, "/bin/mt -f $device status 2>&1 |");
213 +while (<TAPELOADED>) {
214 + $foundtape=1 if (m/ONLINE/);
215 +}
216 +close TAPELOADED;
217 +die("No tape loaded in drive") unless $foundtape;
218
219 - my $tapecount = {$label => 0};
220 - open(TAPES, '/usr/bin/arkc -tape -list -noinfo 2>&1 |');
221 - while (<TAPES>) {
222 - if (m/^name=(.*[^\d])(\d+)$/) {
223 - $tapecount->{$1} = $2 unless defined $tapecount->{$1};
224 - $tapecount->{$1} = $2 if $tapecount->{$1} < $2;
225 - }
226 +my $tapecount = {$label => 0};
227 +open(TAPES, '/usr/bin/arkc -tape -list -noinfo 2>&1 |');
228 +while (<TAPES>) {
229 + if (m/^name=(.*[^\d])(\d+)$/) {
230 + $tapecount->{$1} = $2 unless defined $tapecount->{$1};
231 + $tapecount->{$1} = $2 if $tapecount->{$1} < $2;
232 }
233 - close TAPES;
234 +}
235 +close TAPES;
236
237 - my $tapename='';
238 - my $tapefound=0;
239 - open(TAPE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |');
240 - while (<TAPE>) {
241 - if (m/tpname=(.*)/) {
242 - $tapename=$1;
243 - ++$tapefound;
244 - last;
245 - }
246 - }
247 - close TAPE;
248 +open(TAPEDRIVE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |');
249 +my %tapedrive = map { chomp; /(.*)=(.*)/; $1 => $2; } <TAPEDRIVE>;
250 +close TAPEDRIVE;
251 +
252 +unless ($tapedrive{tpname}) {
253 + ++$tapecount->{$label};
254 + my $tapename="$label$tapecount->{$label}";
255 + print "Unrecognized tape. Creating new tape [$tapename]\n";
256 +
257 + system(qw(/usr/bin/arkc -tape -create -noinfo -D), "name=[$tapename]", "type=[$tape]", "plname=[Tape Pool]");
258 + system(qw(/usr/bin/arkc -drive -write -noinfo -D), 'name=[Tape Drive]', "tpname=[$tapename]", 'overwrite=YES');
259 +
260 + open(TAPEDRIVE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |');
261 + %tapedrive = map { chomp; /(.*)=(.*)/; $1 => $2; } <TAPEDRIVE>;
262 + close TAPEDRIVE;
263 +
264 + if ($tapedrive{tpname} eq $tapename) {
265 + system ("/usr/bin/printf \"%b\" \"".
266 + "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" .
267 + "A new tape [$tapename] of type [$tape] was created\n" .
268 + "in arkeia and added to the pool [Tape Pool].\n\n" .
269 + "If you find the same tape continuously being relabeled, this is\n" .
270 + "probably in indication that the tape is bad or failing." .
271 + "\" | mail -s \"New tape [$tapename] created\" admin");
272 + } else {
273 + system ("/usr/bin/printf \"%b\" \"".
274 + "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" .
275 + "An attempt to label the tape FAILED.\n\n" .
276 + "Please check both the tape drive and the tape for problems.\n\n" .
277 + "If you find the same tape continuously being relabeled, this is\n" .
278 + "probably in indication that the tape is bad or failing." .
279 + "\" | mail -s \"Create new tape FAILED!\" admin");
280
281 - unless ($tapefound) {
282 - ++$tapecount->{$label};
283 - $tapename="$label$tapecount->{$label}";
284 - print "Unrecognized tape. Creating new tape [$tapename]\n";
285 -
286 - system('/usr/bin/arkc','-tape','-create','-noinfo','-D',
287 - "name=[$tapename]",
288 - "type=[$tapetype]",
289 - "plname=[Tape Pool]");
290 - system('/usr/bin/arkc','-drive','-write','-noinfo','-D',
291 - 'name=[Tape Drive]',
292 - "tpname=[$tapename]",
293 - 'overwrite=YES');
294 -
295 - $tapefound=0;
296 - open(TAPE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |');
297 - while (<TAPE>) {
298 - if (m/tpname=(.*)/ && $1 eq $tapename) {
299 - ++$tapefound;
300 - last;
301 - }
302 - }
303 - close TAPE;
304 -
305 - if ($tapefound) {
306 - system ("/usr/bin/printf \"%b\" \"".
307 - "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" .
308 - "A new tape [$tapename] of type [$tapetype] was created\n" .
309 - "in arkeia and added to the pool [Tape Pool].\n\n" .
310 - "If you find the same tape continuously being relabeled, this is\n" .
311 - "probably in indication that the tape is bad or failing." .
312 - "\" | mail -s \"New tape [$tapename] created\" admin");
313 - } else {
314 - system ("/usr/bin/printf \"%b\" \"".
315 - "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" .
316 - "An attempt to label the tape FAILED.\n\n" .
317 - "Please check both the tape drive and the tape for problems.\n\n" .
318 - "If you find the same tape continuously being relabeled, this is\n" .
319 - "probably in indication that the tape is bad or failing." .
320 - "\" | mail -s \"Create new tape FAILED!\" admin");
321 -
322 - system('/usr/bin/arkc','-tape','-delete','-noinfo','-D', "name=[$tapename]");
323 - die('Backup aborted: Creation of new tape FAILED');
324 - }
325 + system(qw(/usr/bin/arkc -tape -delete -noinfo -D), "name=[$tapename]");
326 + die('Creation of new tape FAILED');
327 }
328 -
329 - system('/usr/bin/arkc','-tape','-recycle','-noinfo','-D',
330 - "name=[$tapename]");
331 }
332 +system(qw(/usr/bin/arkc -tape -recycle -noinfo -D), "name=[$tapedrive{tpname}]") if $tapedrive{tpname};
333 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/conf-arkeia mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/conf-arkeia
334 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/conf-arkeia 2005-11-17 11:24:53.000000000 -0700
335 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/conf-arkeia 2007-01-24 22:45:02.000000000 -0700
336 @@ -3,198 +3,88 @@
337 package esmith;
338
339 use strict;
340 -use Errno;
341 -use esmith::config;
342 -use esmith::util;
343 -use esmith::db;
344 +use esmith::ConfigDB;
345 +use esmith::templates;
346 +use Data::Dumper;
347 +
348 +sub check_arkc {
349 + my $object = shift;
350 + my $name = shift;
351 + my @params = @_;
352 +
353 + open(ARKC, "/usr/bin/arkc -$object -list -noinfo 2>&1 |");
354 + my %list = map { chomp; /name=(.*)/; $1 => 1 } <ARKC>;
355 + close ARKC;
356
357 -my %conf;
358 -tie %conf, 'esmith::config';
359 -
360 -my $machinename = $conf{'SystemName'} . '.' . $conf{'DomainName'};
361 -
362 -my $type = db_get_type(\%conf, 'arkeia');
363 -
364 -
365 -unless (defined $type && $type eq 'backupservice') {
366 - my $model = 'none';
367 - my $device = '/dev/st0';
368 -
369 - open(DETECTHARDWARE, '/opt/arkeia/bin/arkdetect 2>&1 |');
370 - while (<DETECTHARDWARE>) {
371 - $model = $1 if (m#PROP : 'ARK_MODEL 'VAL : '(.*)'#);
372 - $device = $1 if (m#PROP : 'DEVICE 'VAL : '(.*)'#);
373 - }
374 - close DETECTHARDWARE;
375 -
376 - db_delete(\%conf, 'arkeia') if (defined $type && $type ne 'backupservice');
377 - db_set(\%conf, 'arkeia', 'backupservice', { Drive => "$model", Tape => 'none', status => 'enabled', });
378 - db_set_prop(\%conf, 'backup', 'Device', $device);
379 + system(qw(/usr/bin/arkc -create), "-$object", qw(-noinfo -D), "name=[$name]", @params) unless $list{$name}
380 }
381
382 -my $ip = '';
383 -my $hostfound = 0;
384 -open(HOSTFILE, 'cat /etc/hosts 2>&1 |');
385 -while (<HOSTFILE>) {
386 - if (m#^[ ]*([0-9.]+)[ ]+.*$machinename#) {
387 - $ip = $1;
388 - ++$hostfound;
389 - last;
390 - }
391 +my $cdb = esmith::ConfigDB->open;
392 +my $backup = $cdb->get('backup') or die "No backup db entry found\n";
393 +my $arkeia = $cdb->get('arkeia') or die "No arkeia db entry found\n";
394 +my $machinename = $cdb->get('SystemName')->value.".".$cdb->get('DomainName')->value;
395 +
396 +open(DETECTHARDWARE, '/opt/arkeia/bin/arkdetect 2>&1 |');
397 +while (<DETECTHARDWARE>) {
398 + $arkeia->set_prop('Drive', $1) if m#PROP : 'ARK_MODEL 'VAL : '(.*)'#;
399 + $backup->set_prop('Device', $1) if m#PROP : 'DEVICE 'VAL : '(.*)'#;
400 }
401 -close HOSTFILE;
402 -
403 -die("$machinename not found in hosts file.") unless ($hostfound);
404 +close DETECTHARDWARE;
405
406 my $networkfound = 0;
407 open(NETWORK, '/sbin/ifconfig 2>&1 |');
408 while (<NETWORK>) {
409 - ++$networkfound if (m#$ip#);
410 + ++$networkfound if (m#inet addr:\s*\d+\.#);
411 }
412 close NETWORK;
413 +exit(0) unless $networkfound;
414
415 -if ($networkfound) {
416 - esmith::templates::processTemplate({
417 - TEMPLATE_PATH => '/opt/arkeia/arkc/arkc.param',
418 - PERMS => 0640,
419 - UID => 'root',
420 - GID => 'root'
421 - });
422 -
423 - my $userfound = 0;
424 - open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |');
425 - while (<USERLIST>) {
426 - if (m#name=admin#) {
427 - ++$userfound;
428 - last;
429 - }
430 - }
431 - close USERLIST;
432 -
433 - unless ($userfound) {
434 - my $password = esmith::util::LdapPassword();
435 - system('/usr/bin/arkc','-user','-create','-noinfo','-D',
436 - 'name=admin',
437 - 'role=ADMINISTRATOR',
438 - "email=[admin\@$conf{'DomainName'}]",
439 - "node=$machinename",
440 - "passwd=[$password]",
441 - "vpasswd=[$password]");
442 -
443 - esmith::templates::processTemplate({
444 - TEMPLATE_PATH => '/opt/arkeia/arkc/arkc.param',
445 - PERMS => 0640,
446 - UID => 'root',
447 - GID => 'root'
448 - });
449 - }
450 -
451 - my $drivetype = db_get_prop(\%conf, 'arkeia', 'Drive') || 'none';
452 - my $drivetypefound = 0;
453 - open(DRIVETYPE, '/usr/bin/arkc -drive -type -noinfo 2>&1 |');
454 - while (<DRIVETYPE>) {
455 - if (m#$drivetype#) {
456 - ++$drivetypefound;
457 - last;
458 - }
459 - }
460 - close DRIVETYPE;
461 -
462 - my $devicetype = db_get_prop(\%conf, 'backup', 'Device') || 'none';
463 - if ($drivetypefound) {
464 - my $drivefound = 0;
465 - my $devicefound = 0;
466 - open(DRIVE, '/usr/bin/arkc -drive -list -noinfo -D name=[Tape Drive] 2>&1 |');
467 - while (<DRIVE>) {
468 - ++$drivefound if (m#$drivetype#);
469 - ++$devicefound if (m#$devicetype#);
470 - }
471 - close DRIVE;
472 -
473 - unless ($drivefound && $devicefound) {
474 - system('/usr/bin/arkc','-drivepack','-delete','-noinfo','-D',
475 - 'name=[Drive Pack]');
476 - system('/usr/bin/arkc','-drive','-delete','-noinfo','-D',
477 - 'name=[Tape Drive]');
478 - system('/usr/bin/arkc','-drive','-create','-noinfo','-D',
479 - 'name=[Tape Drive]',
480 - "type=[$drivetype]",
481 - "rewind_dev=[$devicetype]");
482 - }
483 - }
484 -
485 - my $drivepackfound = 0;
486 - open(DRIVEPACK, '/usr/bin/arkc -drivepack -list -noinfo 2>&1 |');
487 - while (<DRIVEPACK>) {
488 - if (m#Drive Pack#) {
489 - ++$drivepackfound;
490 - last;
491 - }
492 - }
493 - close DRIVEPACK;
494 -
495 - unless ($drivepackfound) {
496 - system('/usr/bin/arkc','-drivepack','-create','-noinfo','-D',
497 - 'name=[Drive Pack]',
498 - 'drvname=[Tape Drive]');
499 - ++$drivepackfound;
500 - }
501 -
502 - my $poolfound = 0;
503 - open(POOL, '/usr/bin/arkc -pool -list -noinfo 2>&1 |');
504 - while (<POOL>) {
505 - if (m#Tape Pool#) {
506 - ++$poolfound;
507 - last;
508 - }
509 - }
510 - close POOL;
511 -
512 - unless ($poolfound) {
513 - system('/usr/bin/arkc','-pool','-create','-noinfo','-D',
514 - 'name=[Tape Pool]');
515 - ++$poolfound;
516 - }
517 -
518 - my $savepackfound = 0;
519 - open(SAVEPACK, '/usr/bin/arkc -savepack -list -noinfo 2>&1 |');
520 - while (<SAVEPACK>) {
521 - if (m#Save Pack#) {
522 - ++$savepackfound;
523 - last;
524 - }
525 - }
526 - close SAVEPACK;
527 -
528 - if ($savepackfound) {
529 - my $savepackmachine = 0;
530 - open(SAVEPACK, '/usr/bin/arkc -savepack -list -noinfo -D name=[Save Pack] 2>&1 |');
531 - while (<SAVEPACK>) {
532 - if (m#=$machinename#) {
533 - ++$savepackmachine;
534 - last;
535 - }
536 - }
537 - close SAVEPACK;
538 -
539 - unless ($savepackmachine) {
540 - system('/usr/bin/arkc','-savepack','-delete','-noinfo','-D',
541 - 'name=[Save Pack]');
542 - system('/usr/bin/arkc','-savepack','-create','-noinfo','-D',
543 - 'name=[Save Pack]');
544 - system('/usr/bin/arkc','-savepack','-modify','-noinfo','-D',
545 - 'name=[Save Pack]',
546 - "tree_name=$machinename");
547 - }
548 - ++$savepackfound;
549 - } else {
550 - system('/usr/bin/arkc','-savepack','-create','-noinfo','-D',
551 - 'name=[Save Pack]');
552 - system('/usr/bin/arkc','-savepack','-modify','-noinfo','-D',
553 - 'name=[Save Pack]',
554 - "tree_name=$machinename");
555 - ++$savepackfound;
556 - }
557 +processTemplate ({TEMPLATE_PATH => "/opt/arkeia/arkc/arkc.param"});
558 +
559 +open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |');
560 +my %userlist = map { chomp; /name=(.*)/; $1 => 1; } <USERLIST>;
561 +close USERLIST;
562 +
563 +unless ($userlist{admin}) {
564 + my $password = esmith::util::LdapPassword();
565 + system(qw(/usr/bin/arkc -user -create -noinfo -D name=admin role=ADMINISTRATOR),
566 + "email=[admin\@".$cdb->get('DomainName')->value."]", "node=$machinename", "passwd=[$password]", "vpasswd=[$password]");
567 +
568 + processTemplate ({TEMPLATE_PATH => "/opt/arkeia/arkc/arkc.param"});
569 }
570
571 -exit (0);
572 +open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |');
573 +%userlist = map { chomp; /name=(.*)/; $1 => 1; } <USERLIST>;
574 +close USERLIST;
575 +exit(0) unless $userlist{admin};
576 +
577 +my $device = $backup->prop('Device') || '/dev/st0';
578 +my $drive = $arkeia->prop('Drive') || 'none';
579 +
580 +open(DRIVETYPE, '/usr/bin/arkc -drive -type -noinfo 2>&1 |');
581 +my %drivetype = map { chomp; /name=(.*)/; $1 => 1 } <DRIVETYPE>;
582 +close DRIVETYPE;
583 +exit(0) unless $drivetype{$drive};
584 +
585 +open(DRIVE, '/usr/bin/arkc -drive -list -noinfo -D name=[Tape Drive] 2>&1 |');
586 +my %driveinfo = map { chomp; /(.*)=(.*)/; $1 => $2 } <DRIVE>;
587 +close DRIVE;
588 +
589 +unless (($driveinfo{DRV_TYPE} || '') eq $drive && ($driveinfo{REWIND_DEV} || '') eq $device) {
590 + system(qw(/usr/bin/arkc -drivepack -delete -noinfo -D), "name=[Drive Pack]");
591 + system(qw(/usr/bin/arkc -drive -delete -noinfo -D), "name=[Tape Drive]");
592 + system(qw(/usr/bin/arkc -drive -create -noinfo -D), "name=[Tape Drive]", "type=[$drive]", "rewind_dev=[$device]");
593 +}
594 +
595 +check_arkc('drivepack', 'Drive Pack', 'drvname=[Tape Drive]');
596 +check_arkc('pool', 'Tape Pool');
597 +
598 +open(SAVEPACK, '/usr/bin/arkc -savepack -list -noinfo -D name=[Save Pack] 2>&1 |');
599 +my %savepack = map { chomp; /(.*)=(.*)/; $1 => $2 } grep /=/, <SAVEPACK>;
600 +close SAVEPACK;
601 +
602 +unless (($savepack{FULLNAME} || '') eq $machinename) {
603 + system(qw(/usr/bin/arkc -savepack -delete -noinfo -D), "name=[Save Pack]");
604 + system(qw(/usr/bin/arkc -savepack -create -noinfo -D), "name=[Save Pack]");
605 + system(qw(/usr/bin/arkc -savepack -modify -noinfo -D), "name=[Save Pack]", "tree_name=$machinename");
606 +}
607 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/events/actions/tape-restore-arkeia mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/tape-restore-arkeia
608 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/tape-restore-arkeia 2004-07-29 11:14:30.000000000 -0600
609 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/tape-restore-arkeia 2007-01-24 22:54:40.000000000 -0700
610 @@ -1,49 +1,52 @@
611 #!/usr/bin/perl -w
612
613 -use strict;
614 package esmith;
615 -use esmith::config;
616 -use esmith::db;
617 +
618 +use strict;
619 +use esmith::ConfigDB;
620 use esmith::Backup;
621 use English;
622
623 -my %conf;
624 -tie %conf, 'esmith::config';
625 +my $cdb = esmith::ConfigDB->open_ro;
626 +my $backup = $cdb->get('backup') or die "No backup db entry found\n";
627
628 -my $backup_program = db_get_prop(\%conf, 'backup', 'Program');
629 -exit(0) unless (defined $backup_program && $backup_program eq 'arkeia');
630 -
631 -my $tapename;
632 -open(TAPE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |');
633 -while (<TAPE>) {
634 - if (m#tpname=(.*)#) {
635 - $tapename=$1;
636 - last;
637 - }
638 +my $program = $backup->prop('Program') || 'flexbackup';
639 +my $status = $backup->prop('status') || 'disabled';
640 +exit(0) unless $program eq 'arkeia';
641 +
642 +if ($status eq 'enabled' && $program eq 'arkeia')
643 +{
644 + open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |');
645 + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } <BACKUP>;
646 + close BACKUP;
647 + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag};
648 }
649 -close TAPE;
650 -die 'Unrecognized tape. Has it been added to the catalog?' unless defined($tapename);
651
652 -my $hostfound=0;
653 -my $host;
654 +open(TAPEDRIVE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |');
655 +my %tapedrive = map { chomp; /(.*)=(.*)/; $1 => $2; } <TAPEDRIVE>;
656 +close TAPEDRIVE;
657 +die 'Unrecognized tape. Has it been added to the catalog?' unless $tapedrive{tpname};
658 +
659 +my ($host, $found);
660 open(HOSTS, '/bin/ls /opt/arkeia/server/dbase/o3dbtree 2>&1 |');
661 while (<HOSTS>) {
662 chomp;
663 - next if (m#o3_cpnt#);
664 + next if (m#^o3_cpnt#);
665 + next if (m#\.(lck|lst)$#);
666
667 $host=$_;
668 - open (FINDHOST, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/etc/passwd]\" \"tpname=[$tapename]\" 2>&1 |");
669 + open (FINDHOST, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/etc/passwd]\" \"tpname=[$tapedrive{tpname}]\" 2>&1 |");
670 while (<FINDHOST>) {
671 - if (m#$tapename#) {
672 - ++$hostfound;
673 + if (m#$tapedrive{tpname}#) {
674 + $found++;
675 last;
676 }
677 }
678 close FINDHOST;
679 - last if ($hostfound);
680 + last if $found;
681 }
682 close HOSTS;
683 -die 'Can\'t do automated restore from this tape.' unless ($hostfound);
684 +die 'Can\'t do automated restore from this tape.' unless $found;
685
686 my ($bksid,$tempid);
687 open(BACKUP, '/usr/bin/arkc -backup -done 2>&1 |');
688 @@ -52,12 +55,9 @@
689 $tempid = $1;
690 open(WHICHTAPE, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/etc/passwd]\" start_bksid=$tempid end_bksid=$tempid 2>&1 |");
691 while (<WHICHTAPE>) {
692 - if (m#tpname=$tapename#) {
693 - if (defined($bksid)) {
694 - die 'Tape contains more than one backup. Can\'t do automated restore from this tape.';
695 - } else {
696 - $bksid=$tempid;
697 - }
698 + if (m#tpname=$tapedrive{tpname}#) {
699 + die 'Tape contains more than one backup. Can\'t do automated restore from this tape.' if (defined($bksid));
700 + $bksid=$tempid;
701 }
702 }
703 close WHICHTAPE;
704 @@ -67,12 +67,12 @@
705 die 'Tape doesn\'t contain any parts necessary for restore.' unless defined($bksid);
706
707 my @restore;
708 -my $backup = new esmith::Backup or die 'Couldn\'t create Backup object';
709 -foreach my $file ($backup->restore_list) {
710 +my $bobj = new esmith::Backup or die 'Couldn\'t create Backup object';
711 +foreach my $file ($bobj->restore_list) {
712 open (FINDFILE, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/$file]\" start_bksid=$bksid end_bksid=$bksid 2>&1 |");
713 while (<FINDFILE>) {
714 if (m#tpname=(.*)#) {
715 - die 'Restore will require more than one tape. Can\'t do automated restore.' unless ($tapename eq $1);
716 + die 'Restore will require more than one tape. Can\'t do automated restore.' unless ($tapedrive{tpname} eq $1);
717 push @restore, "file=[$host!file:/$file]";
718 last;
719 }
720 @@ -81,16 +81,10 @@
721 }
722
723 if ($#restore >= 0) {
724 - my $machinename = $conf{'SystemName'} . '.' . $conf{'DomainName'};
725 - system('/usr/bin/arkc','-restore','-start','-noinfo','-D',
726 - @restore,
727 - 'drvname=[Tape Drive]',
728 - "start_bksid=$bksid",
729 - "end_bksid=$bksid",
730 - "from=[$host!file:/]",
731 - "to=[$machinename!file:/]",
732 - 'rstopt=[RST_TIMES RST_PERMS RST_BYID ~RST_CHKTIME]',
733 - 'wait=YES');
734 + my $machinename = $cdb->get('SystemName')->value . '.' . $cdb->get('DomainName')->value;
735 + system(qw(/usr/bin/arkc -restore -start -noinfo -D), @restore, 'drvname=[Tape Drive]',
736 + "start_bksid=$bksid", "end_bksid=$bksid", "from=[$host!file:/]", "to=[$machinename!file:/]",
737 + 'rstopt=[RST_TIMES RST_PERMS RST_BYNAME ~RST_CHKTIME]', 'wait=YES');
738
739 die 'Tape restore failed: arkeia error.' if ($CHILD_ERROR)
740 } else {
741 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/templates/opt/arkeia/arkc/arkc.param/20user mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/templates/opt/arkeia/arkc/arkc.param/20user
742 --- smeserver-arkeia-1.0/root/etc/e-smith/templates/opt/arkeia/arkc/arkc.param/20user 2004-07-23 13:10:02.000000000 -0600
743 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/templates/opt/arkeia/arkc/arkc.param/20user 2007-01-24 22:45:02.000000000 -0700
744 @@ -1,16 +1,9 @@
745 {
746 - local $found = 0;
747 -
748 - open(USERLIST, "/usr/bin/arkc -user -list 2>&1 |");
749 - while (<USERLIST>) {
750 - if (m#name=admin#) {
751 - ++$found;
752 - last;
753 - }
754 - }
755 + open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |');
756 + local %userlist = map { chomp; /name=(.*)/; $1 => 1; } <USERLIST>;
757 close USERLIST;
758
759 - if ($found) {
760 + if ($userlist{admin}) {
761 local $password = esmith::util::LdapPassword();
762
763 $OUT .= "LOGIN \"admin\"\n";
764 diff -Nur -x '*.orig' -x '*.rej' smeserver-arkeia-1.0/root/etc/e-smith/templates.metadata/opt/arkeia/arkc/arkc.param mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/templates.metadata/opt/arkeia/arkc/arkc.param
765 --- smeserver-arkeia-1.0/root/etc/e-smith/templates.metadata/opt/arkeia/arkc/arkc.param 1969-12-31 17:00:00.000000000 -0700
766 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/templates.metadata/opt/arkeia/arkc/arkc.param 2007-01-24 22:45:02.000000000 -0700
767 @@ -0,0 +1,3 @@
768 +PERMS=640
769 +UID="root"
770 +GID="root"

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed