));
if ( $confirm !~ /(y|Y)/) { goto TOP; }
else { print "confirmed.\n"; system("$fixup /$path_name/$file_name"); }
}
elsif ($select eq 4) {
system(clear);
print "\nYou have selected to exit this program\n"; exit 0; }
elsif (($select ne "4") || ($select !~ /\d/)) {
system(clear);
print "\nThat was not a valid selection.\n"; }
#
goto(TOP);
# end of script
Here is the automatic version...
#!/usr/bin/perl
#
# NotesAutoMM.pl
# Monthly Maintenance for Lotus Domino server
# written Nov 2002, LM-UNIX, Daniel Sprouse
#
#
########################
# ~/~ HOUSEKEEPING ~/~ #
########################
# ~/~ VARIABLE DECLARATIONS ~/~ #
%file_list=(names => ["names.nsf", "queued", "queued", "queued"],
admin4 => ["admin4.nsf", "queued", "queued", "queued"],
car => ["car.nsf", "queued", "queued", "queued"],
ceab => ["ceab.nsf", "queued", "queued", "queued"],
cldb => ["cldbdir.nsf", "queued", "queued", "queued"],
mgp => ["mailgroups.nsf", "queued", "queued", "queued"],
strp => ["statrep.nsf", "queued", "queued", "queued"],
eve => ["events.nsf", "queued", "queued", "queued"],
m0b => ["mail.box", "queued", "queued", "queued"],
m1b => ["mail1.box", "queued", "queued", "queued"],
m2b => ["mail2.box", "queued", "queued", "queued"],
m3b => ["mail3.box", "queued", "queued", "queued"],
m4b => ["mail4.box", "queued", "queued", "queued"],
ced => ["common/ced.nsf", "queued", "queued", "queued"]);
#
#
$month=`date +%b`; $date=`date`; chomp($user=`whoami`);
$down_yet="";
$server_name="$user" . "a";
$path_name="$server_name" . "/notes/data";
chomp($start_file=`grep -l "$user" /etc/rc2.d/S*`);
$compact="/opt/lotus/bin/compact"; $updall="/opt/lotus/bin/updall"; $fixup="/opt/lotus/bin/fixup";
$log_file_base="/usr/users/$user/logfiles/MasterMMLog$month";
#
chomp($down_yet=`ps -fu $user | grep /opt/lotus/notes/latest/sunspa/server | grep -v grep`);
if ("$down_yet" ne "") {
print"Domino server $user is still running. Attempting shutdown.\n";
(open(SERVERQ, "server -q 2>&1>$log_file_base/tmp_errors1.txt |") || open(NSDKILL, "nsd -kill 2>&1>$log_file_base/tmp_errors2.txt |"))
|| die "Could not stop domino server $user, stop manually and retry. Aborting Maintenance\n";
open(MAILER, "/usr/bin/mail [email protected] < $log_file_base/tmp_errors1.txt |"); close MAILER;
open(MAILER, "/usr/bin/mail [email protected] < $log_file_base/tmp_errors2.txt |"); close MAILER;
print "Domino server $user stopped\n";
}
# ~/~ End of Housekepping ~/~ #
#
#############################
# ~/~ MAIN PROGRAM BODY ~/~ #
#############################
MAIN:
foreach $file(keys %file_list) {
#/$path_name/$file_name{$file}[0]
FILE_TEST:
$mm_file="$path_name" . "/" . "$file_list{$file}[0]"; #print "$mm_file\n\n";
if (-r $mm_file) {
COMPACT(); UPDALL(); FIXUP(); }
else { NO_FILE(); }
EXCEPTION:
}
END_RUN();
#
##############################
# ~/~ SUBROUTINES SECTION ~/~#
##############################
sub REPORT {
$date=`date`;
open(STATUSREPORT, ">/usr/users/$user/logfiles/Status");
write (STATUSREPORT) ; close STATUSREPORT; }
#
sub COMPACT {
$file_list{$file}[1]="Running";
$current_message1="Now running COMPACT on domino server $server_name $file_list"; REPORT();
#open(COMPACT, "$compact $mm_file -B -D 2>&1>$log_file_base/$file.compact.log |");
print "$compact $mm_file -B -D 2>&1>$log_file_base/$file.compact.log\n";
$file_list{$file}[1]="Done";
open(MAILER, "/usr/bin/mail [email protected] < $log_file_base/$file.compact.log |"); close MAILER;
$current_message1="Finished running COMPACT on server $server_name."; REPORT();
}
#
sub UPDALL {
$file_list{$file}[2]="Running";
$current_message1="Now running UPDALL on domino server $server_name $file_list"; REPORT();
#open(UPDALL, "$updall $mm_file 2>&1>$log_file_base/$file.updall.log |");
print "$updall $mm_file 2>&1>$log_file_base/$file.updall.log\n";
$file_list{$file}[2]="Done";
open(MAILER, "/usr/bin/mail [email protected] < $log_file_base/$file.compact.log |"); close MAILER;
$current_message1="Finished running UPDALL on server $server_name."; REPORT();
}
#
sub FIXUP {
$file_list{$file}[3]="Running";
$current_message1="Now running FIXUP on domino server $server_name $file_list"; REPORT();
#open(UPDALL, "$fixup $mm_file 2>&1>$log_file_base/$file.fixup.log |");
print "$fixup $mm_file 2>&1>$log_file_base/$file.fixup.log\n";
$file_list{$file}[3]="Done";
open(MAILER, "/usr/bin/mail [email protected] < $log_file_base/$file.compact.log |"); close MAILER;
$current_message1="Finished running FIXUP on server $server_name."; REPORT();
}
#
sub NO_FILE {
$file_list{$file}[1]="missing"; $file_list{$file}[2]="missing"; $file_list{$file}[3]="missing";
$current_message1="$file_list{$file} not found on domino server $server_name"; REPORT();}
#
sub END_RUN {
$current_message1="Monthly Maintenance has COMPLETED on $server_name.";
$current_message2="Restarting domino server."; REPORT();
open(STARTUPDOMINO, "$start_file start 2>&1>$log_file_base/tmp_errors3.txt|");
if ($? eq "0") {
$current_message2="Domino server has been restarted."; REPORT(); }
else { $current_message2="Domino server will need to be restarted manually."; REPORT(); }
open(MAILER, "/usr/bin/mail [email protected] < $log_file_base/tmp_errors3.txt |"); close MAILER;
}
#
format STATUSREPORT =
Monthly Maintenance for @<<<<<<<<
$user
@<<<<<<<<<<<<<<<<<<<<<<<
$date
Monthly Maintenance Status Report
names admin4 car ceab cldbdir statrep events
compact @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<
$file_list{names}[1], $file_list{admin4}[1], $file_list{car}[1], $file_list{ceab}[1], $file_list{cldb}[1], $file_list{strp}[1], $file_list{eve}[1]
updall @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<
$file_list{names}[2], $file_list{admin4}[2], $file_list{car}[2], $file_list{ceab}[2], $file_list{cldb}[2], $file_list{strp}[2], $file_list{eve}[2]
fixup @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<
$file_list{names}[3], $file_list{admin4}[3], $file_list{car}[3], $file_list{ceab}[3], $file_list{cldb}[3], $file_list{strp}[3], $file_list{eve}[3]
mailgroups mail.box mail1.box mail2.box mail3.box mail4.box ced
compact @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<
$file_list{mgp}[1], $file_list{m0b}[1], $file_list{m1b}[1], $file_list{m2b}[1], $file_list{m3b}[1], $file_list{m4b}[1], $file_list{ced}[1]
updall @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<
$file_list{mgp}[2], $file_list{m0b}[2], $file_list{m1b}[2], $file_list{m2b}[2], $file_list{m3b}[2], $file_list{m4b}[2], $file_list{ced}[2]
fixup @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<
$file_list{mgp}[3], $file_list{m0b}[3], $file_list{m1b}[3], $file_list{m2b}[3], $file_list{m3b}[3], $file_list{m4b}[3], $file_list{ced}[3]
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$current_message1
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$current_message2
.
# that period on the line above - marks the end of the format, leave it the hell alone.
# end of script
This one greps the motd for the UNIX Tru64 version...
#!/usr/bin/perl.
#.
open (OS_LIST, "/usr/local/scripts/cust_file_bkp_dir/data_file_dir/unix_os_list.txt").
|| die "cannot open unix_os_list.txt\n";.
#.
foreach $line() {.
@split_line = split(/\s/,$line);.
if ($split_line[1] eq OSF1) {.
push (@unix_tru64_list, $split_line[0]."\n"); }}.
;
close OS_LIST;.
#.
open (T64_LIST, ">/usr/local/scripts/cust_file_bkp_dir/data_file_dir/unix_tru64.txt").
|| die "cannot open unix_tru64.txt\n"; close T64_LIST;.
open (T64_LIST, ">>/usr/local/scripts/cust_file_bkp_dir/data_file_dir/unix_tru64.txt").
|| die "cannot open unix_tru64.txt\n";.
#.
for ($i=0; $i<@unix_tru64_list; $i++) {.
chomp($server=@unix_tru64_list[$i]);.
print "$server\n";.
(open(GET_OS, "rsh $server grep V /etc/motd |"));.
chomp($t64server=);.
print T64_LIST "$server $t64server\n\n";.
close(GET_OS);.
}.
This moves a symbolic link and cofirms it in a report...
#!/usr/bin/perl
#
open (OS_LIST, "/usr/local/scripts/cust_file_bkp_dir/data_file_dir/unix_os_list.txt")
|| die "cannot open unix_os_list.txt\n";
open (T64LIST, ">/usr/local/scripts/cust_file_bkp_dir/data_file_dir/T64list.txt");
close T64LIST;
foreach $line() {
@split_line = split(/\s/,$line);
if ($split_line[1] eq OSF1) {
push (@unix_tru64_list, $split_line[0]."\n"); }}
close OS_LIST;
#
for ($i=0; $i<@unix_tru64_list; $i++) {
chomp($server=@unix_tru64_list[$i]);
open (T64LIST, ">>/usr/local/scripts/cust_file_bkp_dir/data_file_dir/T64list.txt");
(open(UNLINK_SSH, "rsh $server /usr/sbin/unlink /sbin/rc2.d/S*ssh |"));
close UNLINK_SSH;
(open(RELINK_SSH, "rsh $server /usr/bin/ln -s /sbin/init.d/ssh /sbin/rc3.d/S80ssh |"));
close RELINK_SSH;
print T64LIST "$server -- ";
(open(GET_LS, "rsh $server /usr/bin/ls -lF /sbin/rc3.d/S*ssh |"));
$data=;
print T64LIST "$data";
close T64LIST; close(GET_LS);
}