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 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Drive 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Drive 2007-01-24 22:45:02.000000000 -0700 @@ -0,0 +1 @@ +none 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 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Label 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Label 2007-01-24 22:45:02.000000000 -0700 @@ -0,0 +1 @@ +Tape # 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 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/status 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/status 2007-01-24 22:45:02.000000000 -0700 @@ -0,0 +1 @@ +enabled 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 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Tape 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/Tape 2007-01-24 22:45:02.000000000 -0700 @@ -0,0 +1 @@ +none 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 --- smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/type 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/db/configuration/defaults/arkeia/type 2007-01-24 22:45:02.000000000 -0700 @@ -0,0 +1 @@ +backupservice 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-delete-dumped-catalog 2004-07-26 10:30:48.000000000 -0600 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-delete-dumped-catalog 2007-01-24 22:45:02.000000000 -0700 @@ -3,31 +3,25 @@ package esmith; use strict; -use Errno; -use esmith::config; -use esmith::db; -use esmith::util; - -tie my %conf, 'esmith::config'; - -my $program=db_get_prop(\%conf, 'backup', 'Program') || 'flexbackup'; -my $status=db_get_prop(\%conf, 'backup', 'status') || 'disabled'; -my $tapetype=db_get_prop(\%conf, 'arkeia', 'Tape') || 'none'; +use esmith::ConfigDB; + +my $cdb = esmith::ConfigDB->open_ro; +my $backup = $cdb->get('backup') or die "No backup db entry found\n"; + +my $program = $backup->prop('Program') || 'flexbackup'; +my $status = $backup->prop('status') || 'disabled'; if ($status eq 'enabled' && $program eq 'arkeia') { open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |'); - while () { - if (m#tag=(.*)#) { - die("Another arkeia backup is already running ($1)."); - } - } + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } ; close BACKUP; + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag}; } # Always remove the dumped tables. -system qw(/bin/rm -rf /home/e-smith/db/arkeia); +system(qw(/bin/rm -rf /home/e-smith/db/arkeia)); # Recreate the directories. 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-dump-catalog 2004-07-26 10:30:57.000000000 -0600 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-dump-catalog 2007-01-24 22:45:02.000000000 -0700 @@ -3,26 +3,20 @@ package esmith; use strict; -use Errno; -use esmith::config; -use esmith::db; -use esmith::util; - -tie my %conf, 'esmith::config'; - -my $program=db_get_prop(\%conf, 'backup', 'Program') || 'flexbackup'; -my $status=db_get_prop(\%conf, 'backup', 'status') || 'disabled'; -my $tapetype=db_get_prop(\%conf, 'arkeia', 'Tape') || 'none'; +use esmith::ConfigDB; + +my $cdb = esmith::ConfigDB->open_ro; +my $backup = $cdb->get('backup') or die "No backup db entry found\n"; + +my $program = $backup->prop('Program') || 'flexbackup'; +my $status = $backup->prop('status') || 'disabled'; if ($status eq 'enabled' && $program eq 'arkeia') { open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |'); - while () { - if (m#tag=(.*)#) { - die("Another arkeia backup is already running ($1)."); - } - } + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } ; close BACKUP; + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag}; #---------------------------------------------------------- # Check that the dump directory exists. This should have been 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-readtape 1969-12-31 17:00:00.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-readtape 2007-01-24 22:45:02.000000000 -0700 @@ -0,0 +1,45 @@ +#!/usr/bin/perl -w + +package esmith; + +use strict; +use esmith::ConfigDB; +use esmith::lockfile; + +my $cdb = esmith::ConfigDB->open_ro; +my $backup = $cdb->get('backup') or die "No backup db entry found\n"; +my $arkeia = $cdb->get('arkeia') or die "No arkeia db entry found\n"; + +my $program = $backup->prop('Program') || 'flexbackup'; +my $status = $backup->prop('status') || 'disabled'; +my $device = $backup->prop('Device') || '/dev/st0'; +my $drive = $arkeia->prop('Drive') || 'none'; +my $tape = $arkeia->prop('Tape') || 'none'; + +if ($status eq 'enabled' && $program eq 'arkeia') +{ + open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |'); + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } ; + close BACKUP; + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag}; +} + +open(DRIVETYPE, '/usr/bin/arkc -drive -type -noinfo 2>&1 |'); +my %drivetype = map { chomp; /name=(.*)/; $1 => 1 } ; +close DRIVETYPE; +exit(0) unless $drivetype{$drive}; + +open(TAPETYPE, '/usr/bin/arkc -tape -type -noinfo 2>&1 |'); +my %tapetype = map { chomp; /name=(.*)/; $1 => 1 } ; +close TAPETYPE; +exit(0) unless $tapetype{$tape}; + +my $lock_file = "/var/lock/subsys/arkeia-recover"; +my $file_handle = &esmith::lockfile::LockFileOrReturn($lock_file); + +if ($file_handle) { + $ENV{'PATH'} = "/bin:/usr/bin:/sbin:/opt/arkeia/bin"; + system(qw(/opt/arkeia/bin/arkrstdb), "-d$device", "-t$tape", "-r$drive", "-pTape Pool"); + &esmith::lockfile::UnlockFile($file_handle); + `/bin/rm -f $lock_file`; +} 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-recycle-tape 2006-05-14 16:19:44.000000000 -0600 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/arkeia-recycle-tape 2007-01-24 22:45:02.000000000 -0700 @@ -3,105 +3,81 @@ package esmith; use strict; -use Errno; -use esmith::config; -use esmith::db; -use esmith::util; - -tie my %conf, 'esmith::config'; - -my $program=db_get_prop(\%conf, 'backup', 'Program') || 'flexbackup'; -my $status=db_get_prop(\%conf, 'backup', 'status') || 'disabled'; -my $tapetype=db_get_prop(\%conf, 'arkeia', 'Tape') || 'none'; -my $device = db_get_prop(\%conf, 'backup', 'Device') || '/dev/st0'; -my $label = db_get_prop(\%conf, 'arkeia', 'Label') || 'Tape #'; +use esmith::ConfigDB; + +my $cdb = esmith::ConfigDB->open_ro; +my $backup = $cdb->get('backup') or die "No backup db entry found\n"; +my $arkeia = $cdb->get('arkeia') or die "No arkeia db entry found\n"; + +my $program = $backup->prop('Program') || 'flexbackup'; +my $status = $backup->prop('status') || 'disabled'; +my $device = $backup->prop('Device') || '/dev/st0'; +my $tape = $arkeia->prop('Tape') || 'none'; +my $label = $arkeia->prop('Label') || 'Tape #'; if ($status eq 'enabled' && $program eq 'arkeia') { open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |'); - while () { - die("Backup aborted: Another arkeia backup is already running ($_)") if (m/tag=(.*)/); - } + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } ; close BACKUP; + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag}; +} - my $foundtape=0; - open(TAPELOADED, "/bin/mt -f $device status 2>&1 |"); - while () { - $foundtape=1 if (m/ONLINE/); - } - close TAPELOADED; - die("Backup aborded: No tape loaded in drive") unless $foundtape; +die('Invalid Tape property for arkeia') if ($tape eq 'none'); - die('Backup aborted: Invalid Tape property for arkeia') if ($tapetype eq 'none'); +my $foundtape=0; +open(TAPELOADED, "/bin/mt -f $device status 2>&1 |"); +while () { + $foundtape=1 if (m/ONLINE/); +} +close TAPELOADED; +die("No tape loaded in drive") unless $foundtape; - my $tapecount = {$label => 0}; - open(TAPES, '/usr/bin/arkc -tape -list -noinfo 2>&1 |'); - while () { - if (m/^name=(.*[^\d])(\d+)$/) { - $tapecount->{$1} = $2 unless defined $tapecount->{$1}; - $tapecount->{$1} = $2 if $tapecount->{$1} < $2; - } +my $tapecount = {$label => 0}; +open(TAPES, '/usr/bin/arkc -tape -list -noinfo 2>&1 |'); +while () { + if (m/^name=(.*[^\d])(\d+)$/) { + $tapecount->{$1} = $2 unless defined $tapecount->{$1}; + $tapecount->{$1} = $2 if $tapecount->{$1} < $2; } - close TAPES; +} +close TAPES; - my $tapename=''; - my $tapefound=0; - open(TAPE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |'); - while () { - if (m/tpname=(.*)/) { - $tapename=$1; - ++$tapefound; - last; - } - } - close TAPE; +open(TAPEDRIVE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |'); +my %tapedrive = map { chomp; /(.*)=(.*)/; $1 => $2; } ; +close TAPEDRIVE; + +unless ($tapedrive{tpname}) { + ++$tapecount->{$label}; + my $tapename="$label$tapecount->{$label}"; + print "Unrecognized tape. Creating new tape [$tapename]\n"; + + system(qw(/usr/bin/arkc -tape -create -noinfo -D), "name=[$tapename]", "type=[$tape]", "plname=[Tape Pool]"); + system(qw(/usr/bin/arkc -drive -write -noinfo -D), 'name=[Tape Drive]', "tpname=[$tapename]", 'overwrite=YES'); + + open(TAPEDRIVE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |'); + %tapedrive = map { chomp; /(.*)=(.*)/; $1 => $2; } ; + close TAPEDRIVE; + + if ($tapedrive{tpname} eq $tapename) { + system ("/usr/bin/printf \"%b\" \"". + "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" . + "A new tape [$tapename] of type [$tape] was created\n" . + "in arkeia and added to the pool [Tape Pool].\n\n" . + "If you find the same tape continuously being relabeled, this is\n" . + "probably in indication that the tape is bad or failing." . + "\" | mail -s \"New tape [$tapename] created\" admin"); + } else { + system ("/usr/bin/printf \"%b\" \"". + "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" . + "An attempt to label the tape FAILED.\n\n" . + "Please check both the tape drive and the tape for problems.\n\n" . + "If you find the same tape continuously being relabeled, this is\n" . + "probably in indication that the tape is bad or failing." . + "\" | mail -s \"Create new tape FAILED!\" admin"); - unless ($tapefound) { - ++$tapecount->{$label}; - $tapename="$label$tapecount->{$label}"; - print "Unrecognized tape. Creating new tape [$tapename]\n"; - - system('/usr/bin/arkc','-tape','-create','-noinfo','-D', - "name=[$tapename]", - "type=[$tapetype]", - "plname=[Tape Pool]"); - system('/usr/bin/arkc','-drive','-write','-noinfo','-D', - 'name=[Tape Drive]', - "tpname=[$tapename]", - 'overwrite=YES'); - - $tapefound=0; - open(TAPE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |'); - while () { - if (m/tpname=(.*)/ && $1 eq $tapename) { - ++$tapefound; - last; - } - } - close TAPE; - - if ($tapefound) { - system ("/usr/bin/printf \"%b\" \"". - "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" . - "A new tape [$tapename] of type [$tapetype] was created\n" . - "in arkeia and added to the pool [Tape Pool].\n\n" . - "If you find the same tape continuously being relabeled, this is\n" . - "probably in indication that the tape is bad or failing." . - "\" | mail -s \"New tape [$tapename] created\" admin"); - } else { - system ("/usr/bin/printf \"%b\" \"". - "An unrecognized tape was found in the tape drive [Tape Drive].\n\n" . - "An attempt to label the tape FAILED.\n\n" . - "Please check both the tape drive and the tape for problems.\n\n" . - "If you find the same tape continuously being relabeled, this is\n" . - "probably in indication that the tape is bad or failing." . - "\" | mail -s \"Create new tape FAILED!\" admin"); - - system('/usr/bin/arkc','-tape','-delete','-noinfo','-D', "name=[$tapename]"); - die('Backup aborted: Creation of new tape FAILED'); - } + system(qw(/usr/bin/arkc -tape -delete -noinfo -D), "name=[$tapename]"); + die('Creation of new tape FAILED'); } - - system('/usr/bin/arkc','-tape','-recycle','-noinfo','-D', - "name=[$tapename]"); } +system(qw(/usr/bin/arkc -tape -recycle -noinfo -D), "name=[$tapedrive{tpname}]") if $tapedrive{tpname}; 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/conf-arkeia 2005-11-17 11:24:53.000000000 -0700 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/conf-arkeia 2007-01-24 22:45:02.000000000 -0700 @@ -3,198 +3,88 @@ package esmith; use strict; -use Errno; -use esmith::config; -use esmith::util; -use esmith::db; +use esmith::ConfigDB; +use esmith::templates; +use Data::Dumper; + +sub check_arkc { + my $object = shift; + my $name = shift; + my @params = @_; + + open(ARKC, "/usr/bin/arkc -$object -list -noinfo 2>&1 |"); + my %list = map { chomp; /name=(.*)/; $1 => 1 } ; + close ARKC; -my %conf; -tie %conf, 'esmith::config'; - -my $machinename = $conf{'SystemName'} . '.' . $conf{'DomainName'}; - -my $type = db_get_type(\%conf, 'arkeia'); - - -unless (defined $type && $type eq 'backupservice') { - my $model = 'none'; - my $device = '/dev/st0'; - - open(DETECTHARDWARE, '/opt/arkeia/bin/arkdetect 2>&1 |'); - while () { - $model = $1 if (m#PROP : 'ARK_MODEL 'VAL : '(.*)'#); - $device = $1 if (m#PROP : 'DEVICE 'VAL : '(.*)'#); - } - close DETECTHARDWARE; - - db_delete(\%conf, 'arkeia') if (defined $type && $type ne 'backupservice'); - db_set(\%conf, 'arkeia', 'backupservice', { Drive => "$model", Tape => 'none', status => 'enabled', }); - db_set_prop(\%conf, 'backup', 'Device', $device); + system(qw(/usr/bin/arkc -create), "-$object", qw(-noinfo -D), "name=[$name]", @params) unless $list{$name} } -my $ip = ''; -my $hostfound = 0; -open(HOSTFILE, 'cat /etc/hosts 2>&1 |'); -while () { - if (m#^[ ]*([0-9.]+)[ ]+.*$machinename#) { - $ip = $1; - ++$hostfound; - last; - } +my $cdb = esmith::ConfigDB->open; +my $backup = $cdb->get('backup') or die "No backup db entry found\n"; +my $arkeia = $cdb->get('arkeia') or die "No arkeia db entry found\n"; +my $machinename = $cdb->get('SystemName')->value.".".$cdb->get('DomainName')->value; + +open(DETECTHARDWARE, '/opt/arkeia/bin/arkdetect 2>&1 |'); +while () { + $arkeia->set_prop('Drive', $1) if m#PROP : 'ARK_MODEL 'VAL : '(.*)'#; + $backup->set_prop('Device', $1) if m#PROP : 'DEVICE 'VAL : '(.*)'#; } -close HOSTFILE; - -die("$machinename not found in hosts file.") unless ($hostfound); +close DETECTHARDWARE; my $networkfound = 0; open(NETWORK, '/sbin/ifconfig 2>&1 |'); while () { - ++$networkfound if (m#$ip#); + ++$networkfound if (m#inet addr:\s*\d+\.#); } close NETWORK; +exit(0) unless $networkfound; -if ($networkfound) { - esmith::templates::processTemplate({ - TEMPLATE_PATH => '/opt/arkeia/arkc/arkc.param', - PERMS => 0640, - UID => 'root', - GID => 'root' - }); - - my $userfound = 0; - open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |'); - while () { - if (m#name=admin#) { - ++$userfound; - last; - } - } - close USERLIST; - - unless ($userfound) { - my $password = esmith::util::LdapPassword(); - system('/usr/bin/arkc','-user','-create','-noinfo','-D', - 'name=admin', - 'role=ADMINISTRATOR', - "email=[admin\@$conf{'DomainName'}]", - "node=$machinename", - "passwd=[$password]", - "vpasswd=[$password]"); - - esmith::templates::processTemplate({ - TEMPLATE_PATH => '/opt/arkeia/arkc/arkc.param', - PERMS => 0640, - UID => 'root', - GID => 'root' - }); - } - - my $drivetype = db_get_prop(\%conf, 'arkeia', 'Drive') || 'none'; - my $drivetypefound = 0; - open(DRIVETYPE, '/usr/bin/arkc -drive -type -noinfo 2>&1 |'); - while () { - if (m#$drivetype#) { - ++$drivetypefound; - last; - } - } - close DRIVETYPE; - - my $devicetype = db_get_prop(\%conf, 'backup', 'Device') || 'none'; - if ($drivetypefound) { - my $drivefound = 0; - my $devicefound = 0; - open(DRIVE, '/usr/bin/arkc -drive -list -noinfo -D name=[Tape Drive] 2>&1 |'); - while () { - ++$drivefound if (m#$drivetype#); - ++$devicefound if (m#$devicetype#); - } - close DRIVE; - - unless ($drivefound && $devicefound) { - system('/usr/bin/arkc','-drivepack','-delete','-noinfo','-D', - 'name=[Drive Pack]'); - system('/usr/bin/arkc','-drive','-delete','-noinfo','-D', - 'name=[Tape Drive]'); - system('/usr/bin/arkc','-drive','-create','-noinfo','-D', - 'name=[Tape Drive]', - "type=[$drivetype]", - "rewind_dev=[$devicetype]"); - } - } - - my $drivepackfound = 0; - open(DRIVEPACK, '/usr/bin/arkc -drivepack -list -noinfo 2>&1 |'); - while () { - if (m#Drive Pack#) { - ++$drivepackfound; - last; - } - } - close DRIVEPACK; - - unless ($drivepackfound) { - system('/usr/bin/arkc','-drivepack','-create','-noinfo','-D', - 'name=[Drive Pack]', - 'drvname=[Tape Drive]'); - ++$drivepackfound; - } - - my $poolfound = 0; - open(POOL, '/usr/bin/arkc -pool -list -noinfo 2>&1 |'); - while () { - if (m#Tape Pool#) { - ++$poolfound; - last; - } - } - close POOL; - - unless ($poolfound) { - system('/usr/bin/arkc','-pool','-create','-noinfo','-D', - 'name=[Tape Pool]'); - ++$poolfound; - } - - my $savepackfound = 0; - open(SAVEPACK, '/usr/bin/arkc -savepack -list -noinfo 2>&1 |'); - while () { - if (m#Save Pack#) { - ++$savepackfound; - last; - } - } - close SAVEPACK; - - if ($savepackfound) { - my $savepackmachine = 0; - open(SAVEPACK, '/usr/bin/arkc -savepack -list -noinfo -D name=[Save Pack] 2>&1 |'); - while () { - if (m#=$machinename#) { - ++$savepackmachine; - last; - } - } - close SAVEPACK; - - unless ($savepackmachine) { - system('/usr/bin/arkc','-savepack','-delete','-noinfo','-D', - 'name=[Save Pack]'); - system('/usr/bin/arkc','-savepack','-create','-noinfo','-D', - 'name=[Save Pack]'); - system('/usr/bin/arkc','-savepack','-modify','-noinfo','-D', - 'name=[Save Pack]', - "tree_name=$machinename"); - } - ++$savepackfound; - } else { - system('/usr/bin/arkc','-savepack','-create','-noinfo','-D', - 'name=[Save Pack]'); - system('/usr/bin/arkc','-savepack','-modify','-noinfo','-D', - 'name=[Save Pack]', - "tree_name=$machinename"); - ++$savepackfound; - } +processTemplate ({TEMPLATE_PATH => "/opt/arkeia/arkc/arkc.param"}); + +open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |'); +my %userlist = map { chomp; /name=(.*)/; $1 => 1; } ; +close USERLIST; + +unless ($userlist{admin}) { + my $password = esmith::util::LdapPassword(); + system(qw(/usr/bin/arkc -user -create -noinfo -D name=admin role=ADMINISTRATOR), + "email=[admin\@".$cdb->get('DomainName')->value."]", "node=$machinename", "passwd=[$password]", "vpasswd=[$password]"); + + processTemplate ({TEMPLATE_PATH => "/opt/arkeia/arkc/arkc.param"}); } -exit (0); +open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |'); +%userlist = map { chomp; /name=(.*)/; $1 => 1; } ; +close USERLIST; +exit(0) unless $userlist{admin}; + +my $device = $backup->prop('Device') || '/dev/st0'; +my $drive = $arkeia->prop('Drive') || 'none'; + +open(DRIVETYPE, '/usr/bin/arkc -drive -type -noinfo 2>&1 |'); +my %drivetype = map { chomp; /name=(.*)/; $1 => 1 } ; +close DRIVETYPE; +exit(0) unless $drivetype{$drive}; + +open(DRIVE, '/usr/bin/arkc -drive -list -noinfo -D name=[Tape Drive] 2>&1 |'); +my %driveinfo = map { chomp; /(.*)=(.*)/; $1 => $2 } ; +close DRIVE; + +unless (($driveinfo{DRV_TYPE} || '') eq $drive && ($driveinfo{REWIND_DEV} || '') eq $device) { + system(qw(/usr/bin/arkc -drivepack -delete -noinfo -D), "name=[Drive Pack]"); + system(qw(/usr/bin/arkc -drive -delete -noinfo -D), "name=[Tape Drive]"); + system(qw(/usr/bin/arkc -drive -create -noinfo -D), "name=[Tape Drive]", "type=[$drive]", "rewind_dev=[$device]"); +} + +check_arkc('drivepack', 'Drive Pack', 'drvname=[Tape Drive]'); +check_arkc('pool', 'Tape Pool'); + +open(SAVEPACK, '/usr/bin/arkc -savepack -list -noinfo -D name=[Save Pack] 2>&1 |'); +my %savepack = map { chomp; /(.*)=(.*)/; $1 => $2 } grep /=/, ; +close SAVEPACK; + +unless (($savepack{FULLNAME} || '') eq $machinename) { + system(qw(/usr/bin/arkc -savepack -delete -noinfo -D), "name=[Save Pack]"); + system(qw(/usr/bin/arkc -savepack -create -noinfo -D), "name=[Save Pack]"); + system(qw(/usr/bin/arkc -savepack -modify -noinfo -D), "name=[Save Pack]", "tree_name=$machinename"); +} 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 --- smeserver-arkeia-1.0/root/etc/e-smith/events/actions/tape-restore-arkeia 2004-07-29 11:14:30.000000000 -0600 +++ mezzanine_patched_smeserver-arkeia-1.0/root/etc/e-smith/events/actions/tape-restore-arkeia 2007-01-24 22:54:40.000000000 -0700 @@ -1,49 +1,52 @@ #!/usr/bin/perl -w -use strict; package esmith; -use esmith::config; -use esmith::db; + +use strict; +use esmith::ConfigDB; use esmith::Backup; use English; -my %conf; -tie %conf, 'esmith::config'; +my $cdb = esmith::ConfigDB->open_ro; +my $backup = $cdb->get('backup') or die "No backup db entry found\n"; -my $backup_program = db_get_prop(\%conf, 'backup', 'Program'); -exit(0) unless (defined $backup_program && $backup_program eq 'arkeia'); - -my $tapename; -open(TAPE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |'); -while () { - if (m#tpname=(.*)#) { - $tapename=$1; - last; - } +my $program = $backup->prop('Program') || 'flexbackup'; +my $status = $backup->prop('status') || 'disabled'; +exit(0) unless $program eq 'arkeia'; + +if ($status eq 'enabled' && $program eq 'arkeia') +{ + open(BACKUP, '/usr/bin/arkc -backup -running -noinfo 2>&1 |'); + my %backup = map { chomp; /(.*)=(.*)/; $1 => $2; } ; + close BACKUP; + die("Another arkeia backup is already running ($backup{tag}.") if $backup{tag}; } -close TAPE; -die 'Unrecognized tape. Has it been added to the catalog?' unless defined($tapename); -my $hostfound=0; -my $host; +open(TAPEDRIVE, '/usr/bin/arkc -drive -read -noinfo -D name=[Tape Drive] 2>&1 |'); +my %tapedrive = map { chomp; /(.*)=(.*)/; $1 => $2; } ; +close TAPEDRIVE; +die 'Unrecognized tape. Has it been added to the catalog?' unless $tapedrive{tpname}; + +my ($host, $found); open(HOSTS, '/bin/ls /opt/arkeia/server/dbase/o3dbtree 2>&1 |'); while () { chomp; - next if (m#o3_cpnt#); + next if (m#^o3_cpnt#); + next if (m#\.(lck|lst)$#); $host=$_; - open (FINDHOST, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/etc/passwd]\" \"tpname=[$tapename]\" 2>&1 |"); + open (FINDHOST, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/etc/passwd]\" \"tpname=[$tapedrive{tpname}]\" 2>&1 |"); while () { - if (m#$tapename#) { - ++$hostfound; + if (m#$tapedrive{tpname}#) { + $found++; last; } } close FINDHOST; - last if ($hostfound); + last if $found; } close HOSTS; -die 'Can\'t do automated restore from this tape.' unless ($hostfound); +die 'Can\'t do automated restore from this tape.' unless $found; my ($bksid,$tempid); open(BACKUP, '/usr/bin/arkc -backup -done 2>&1 |'); @@ -52,12 +55,9 @@ $tempid = $1; open(WHICHTAPE, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/etc/passwd]\" start_bksid=$tempid end_bksid=$tempid 2>&1 |"); while () { - if (m#tpname=$tapename#) { - if (defined($bksid)) { - die 'Tape contains more than one backup. Can\'t do automated restore from this tape.'; - } else { - $bksid=$tempid; - } + if (m#tpname=$tapedrive{tpname}#) { + die 'Tape contains more than one backup. Can\'t do automated restore from this tape.' if (defined($bksid)); + $bksid=$tempid; } } close WHICHTAPE; @@ -67,12 +67,12 @@ die 'Tape doesn\'t contain any parts necessary for restore.' unless defined($bksid); my @restore; -my $backup = new esmith::Backup or die 'Couldn\'t create Backup object'; -foreach my $file ($backup->restore_list) { +my $bobj = new esmith::Backup or die 'Couldn\'t create Backup object'; +foreach my $file ($bobj->restore_list) { open (FINDFILE, "/usr/bin/arkc -file -where -noinfo -D \"file=[$host!file:/$file]\" start_bksid=$bksid end_bksid=$bksid 2>&1 |"); while () { if (m#tpname=(.*)#) { - die 'Restore will require more than one tape. Can\'t do automated restore.' unless ($tapename eq $1); + die 'Restore will require more than one tape. Can\'t do automated restore.' unless ($tapedrive{tpname} eq $1); push @restore, "file=[$host!file:/$file]"; last; } @@ -81,16 +81,10 @@ } if ($#restore >= 0) { - my $machinename = $conf{'SystemName'} . '.' . $conf{'DomainName'}; - system('/usr/bin/arkc','-restore','-start','-noinfo','-D', - @restore, - 'drvname=[Tape Drive]', - "start_bksid=$bksid", - "end_bksid=$bksid", - "from=[$host!file:/]", - "to=[$machinename!file:/]", - 'rstopt=[RST_TIMES RST_PERMS RST_BYID ~RST_CHKTIME]', - 'wait=YES'); + my $machinename = $cdb->get('SystemName')->value . '.' . $cdb->get('DomainName')->value; + system(qw(/usr/bin/arkc -restore -start -noinfo -D), @restore, 'drvname=[Tape Drive]', + "start_bksid=$bksid", "end_bksid=$bksid", "from=[$host!file:/]", "to=[$machinename!file:/]", + 'rstopt=[RST_TIMES RST_PERMS RST_BYNAME ~RST_CHKTIME]', 'wait=YES'); die 'Tape restore failed: arkeia error.' if ($CHILD_ERROR) } else { 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 --- smeserver-arkeia-1.0/root/etc/e-smith/templates/opt/arkeia/arkc/arkc.param/20user 2004-07-23 13:10:02.000000000 -0600 +++ 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 @@ -1,16 +1,9 @@ { - local $found = 0; - - open(USERLIST, "/usr/bin/arkc -user -list 2>&1 |"); - while () { - if (m#name=admin#) { - ++$found; - last; - } - } + open(USERLIST, '/usr/bin/arkc -user -list -noinfo 2>&1 |'); + local %userlist = map { chomp; /name=(.*)/; $1 => 1; } ; close USERLIST; - if ($found) { + if ($userlist{admin}) { local $password = esmith::util::LdapPassword(); $OUT .= "LOGIN \"admin\"\n"; 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 --- smeserver-arkeia-1.0/root/etc/e-smith/templates.metadata/opt/arkeia/arkc/arkc.param 1969-12-31 17:00:00.000000000 -0700 +++ 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 @@ -0,0 +1,3 @@ +PERMS=640 +UID="root" +GID="root"